Commit | Line | Data |
---|---|---|
373e68b5 | 1 | /* |
1da177e4 LT |
2 | * Copyright (C) 2001 Ian da Silva, Jeremy Siegel |
3 | * Based largely on io_se.c. | |
4 | * | |
5 | * I/O routine for Hitachi 7751 SolutionEngine. | |
6 | * | |
7 | * Initial version only to support LAN access; some | |
8 | * placeholder code from io_se.c left in with the | |
9 | * expectation of later SuperIO and PCMCIA access. | |
10 | */ | |
1da177e4 LT |
11 | #include <linux/kernel.h> |
12 | #include <linux/types.h> | |
959f85f8 | 13 | #include <linux/pci.h> |
1da177e4 | 14 | #include <asm/io.h> |
939a24a6 | 15 | #include <mach-se/mach/se7751.h> |
1da177e4 LT |
16 | #include <asm/addrspace.h> |
17 | ||
959f85f8 | 18 | static inline volatile u16 *port2adr(unsigned int port) |
1da177e4 LT |
19 | { |
20 | if (port >= 0x2000) | |
21 | return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); | |
373e68b5 | 22 | maybebadio((unsigned long)port); |
1da177e4 LT |
23 | return (volatile __u16*)port; |
24 | } | |
25 | ||
1da177e4 LT |
26 | /* |
27 | * General outline: remap really low stuff [eventually] to SuperIO, | |
28 | * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) | |
29 | * is mapped through the PCI IO window. Stuff with high bits (PXSEG) | |
30 | * should be way beyond the window, and is used w/o translation for | |
31 | * compatibility. | |
32 | */ | |
33 | unsigned char sh7751se_inb(unsigned long port) | |
34 | { | |
35 | if (PXSEG(port)) | |
36 | return *(volatile unsigned char *)port; | |
959f85f8 PM |
37 | else if (is_pci_ioaddr(port)) |
38 | return *(volatile unsigned char *)pci_ioaddr(port); | |
1da177e4 | 39 | else |
959f85f8 | 40 | return (*port2adr(port)) & 0xff; |
1da177e4 LT |
41 | } |
42 | ||
43 | unsigned char sh7751se_inb_p(unsigned long port) | |
44 | { | |
45 | unsigned char v; | |
46 | ||
47 | if (PXSEG(port)) | |
48 | v = *(volatile unsigned char *)port; | |
959f85f8 PM |
49 | else if (is_pci_ioaddr(port)) |
50 | v = *(volatile unsigned char *)pci_ioaddr(port); | |
1da177e4 | 51 | else |
959f85f8 PM |
52 | v = (*port2adr(port)) & 0xff; |
53 | ctrl_delay(); | |
1da177e4 LT |
54 | return v; |
55 | } | |
56 | ||
57 | unsigned short sh7751se_inw(unsigned long port) | |
58 | { | |
59 | if (PXSEG(port)) | |
60 | return *(volatile unsigned short *)port; | |
959f85f8 PM |
61 | else if (is_pci_ioaddr(port)) |
62 | return *(volatile unsigned short *)pci_ioaddr(port); | |
1da177e4 LT |
63 | else if (port >= 0x2000) |
64 | return *port2adr(port); | |
65 | else | |
373e68b5 | 66 | maybebadio(port); |
1da177e4 LT |
67 | return 0; |
68 | } | |
69 | ||
70 | unsigned int sh7751se_inl(unsigned long port) | |
71 | { | |
72 | if (PXSEG(port)) | |
73 | return *(volatile unsigned long *)port; | |
959f85f8 PM |
74 | else if (is_pci_ioaddr(port)) |
75 | return *(volatile unsigned int *)pci_ioaddr(port); | |
1da177e4 LT |
76 | else if (port >= 0x2000) |
77 | return *port2adr(port); | |
78 | else | |
373e68b5 | 79 | maybebadio(port); |
1da177e4 LT |
80 | return 0; |
81 | } | |
82 | ||
83 | void sh7751se_outb(unsigned char value, unsigned long port) | |
84 | { | |
85 | ||
86 | if (PXSEG(port)) | |
87 | *(volatile unsigned char *)port = value; | |
959f85f8 PM |
88 | else if (is_pci_ioaddr(port)) |
89 | *((unsigned char*)pci_ioaddr(port)) = value; | |
1da177e4 LT |
90 | else |
91 | *(port2adr(port)) = value; | |
92 | } | |
93 | ||
94 | void sh7751se_outb_p(unsigned char value, unsigned long port) | |
95 | { | |
96 | if (PXSEG(port)) | |
97 | *(volatile unsigned char *)port = value; | |
959f85f8 PM |
98 | else if (is_pci_ioaddr(port)) |
99 | *((unsigned char*)pci_ioaddr(port)) = value; | |
1da177e4 LT |
100 | else |
101 | *(port2adr(port)) = value; | |
959f85f8 | 102 | ctrl_delay(); |
1da177e4 LT |
103 | } |
104 | ||
105 | void sh7751se_outw(unsigned short value, unsigned long port) | |
106 | { | |
107 | if (PXSEG(port)) | |
108 | *(volatile unsigned short *)port = value; | |
959f85f8 PM |
109 | else if (is_pci_ioaddr(port)) |
110 | *((unsigned short *)pci_ioaddr(port)) = value; | |
1da177e4 LT |
111 | else if (port >= 0x2000) |
112 | *port2adr(port) = value; | |
113 | else | |
373e68b5 | 114 | maybebadio(port); |
1da177e4 LT |
115 | } |
116 | ||
117 | void sh7751se_outl(unsigned int value, unsigned long port) | |
118 | { | |
119 | if (PXSEG(port)) | |
120 | *(volatile unsigned long *)port = value; | |
959f85f8 PM |
121 | else if (is_pci_ioaddr(port)) |
122 | *((unsigned long*)pci_ioaddr(port)) = value; | |
1da177e4 | 123 | else |
373e68b5 | 124 | maybebadio(port); |
1da177e4 LT |
125 | } |
126 | ||
127 | void sh7751se_insl(unsigned long port, void *addr, unsigned long count) | |
128 | { | |
373e68b5 | 129 | maybebadio(port); |
1da177e4 LT |
130 | } |
131 | ||
132 | void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count) | |
133 | { | |
373e68b5 | 134 | maybebadio(port); |
1da177e4 | 135 | } |