1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/module.h>
15#include <linux/io.h>
16#include <asm/machvec.h>
17
18#ifdef CONFIG_CPU_SH3
19
20
21
22#define dummy_read() ctrl_inb(0xba000000)
23#else
24#define dummy_read()
25#endif
26
27unsigned long generic_io_base;
28
29static inline void delay(void)
30{
31 ctrl_inw(0xa0000000);
32}
33
34u8 generic_inb(unsigned long port)
35{
36 return ctrl_inb((unsigned long __force)ioport_map(port, 1));
37}
38
39u16 generic_inw(unsigned long port)
40{
41 return ctrl_inw((unsigned long __force)ioport_map(port, 2));
42}
43
44u32 generic_inl(unsigned long port)
45{
46 return ctrl_inl((unsigned long __force)ioport_map(port, 4));
47}
48
49u8 generic_inb_p(unsigned long port)
50{
51 unsigned long v = generic_inb(port);
52
53 delay();
54 return v;
55}
56
57u16 generic_inw_p(unsigned long port)
58{
59 unsigned long v = generic_inw(port);
60
61 delay();
62 return v;
63}
64
65u32 generic_inl_p(unsigned long port)
66{
67 unsigned long v = generic_inl(port);
68
69 delay();
70 return v;
71}
72
73
74
75
76
77
78
79void generic_insb(unsigned long port, void *dst, unsigned long count)
80{
81 volatile u8 *port_addr;
82 u8 *buf = dst;
83
84 port_addr = (volatile u8 *)ioport_map(port, 1);
85 while (count--)
86 *buf++ = *port_addr;
87}
88
89void generic_insw(unsigned long port, void *dst, unsigned long count)
90{
91 volatile u16 *port_addr;
92 u16 *buf = dst;
93
94 port_addr = (volatile u16 *)ioport_map(port, 2);
95 while (count--)
96 *buf++ = *port_addr;
97
98 dummy_read();
99}
100
101void generic_insl(unsigned long port, void *dst, unsigned long count)
102{
103 volatile u32 *port_addr;
104 u32 *buf = dst;
105
106 port_addr = (volatile u32 *)ioport_map(port, 4);
107 while (count--)
108 *buf++ = *port_addr;
109
110 dummy_read();
111}
112
113void generic_outb(u8 b, unsigned long port)
114{
115 ctrl_outb(b, (unsigned long __force)ioport_map(port, 1));
116}
117
118void generic_outw(u16 b, unsigned long port)
119{
120 ctrl_outw(b, (unsigned long __force)ioport_map(port, 2));
121}
122
123void generic_outl(u32 b, unsigned long port)
124{
125 ctrl_outl(b, (unsigned long __force)ioport_map(port, 4));
126}
127
128void generic_outb_p(u8 b, unsigned long port)
129{
130 generic_outb(b, port);
131 delay();
132}
133
134void generic_outw_p(u16 b, unsigned long port)
135{
136 generic_outw(b, port);
137 delay();
138}
139
140void generic_outl_p(u32 b, unsigned long port)
141{
142 generic_outl(b, port);
143 delay();
144}
145
146
147
148
149
150
151void generic_outsb(unsigned long port, const void *src, unsigned long count)
152{
153 volatile u8 *port_addr;
154 const u8 *buf = src;
155
156 port_addr = (volatile u8 __force *)ioport_map(port, 1);
157
158 while (count--)
159 *port_addr = *buf++;
160}
161
162void generic_outsw(unsigned long port, const void *src, unsigned long count)
163{
164 volatile u16 *port_addr;
165 const u16 *buf = src;
166
167 port_addr = (volatile u16 __force *)ioport_map(port, 2);
168
169 while (count--)
170 *port_addr = *buf++;
171
172 dummy_read();
173}
174
175void generic_outsl(unsigned long port, const void *src, unsigned long count)
176{
177 volatile u32 *port_addr;
178 const u32 *buf = src;
179
180 port_addr = (volatile u32 __force *)ioport_map(port, 4);
181 while (count--)
182 *port_addr = *buf++;
183
184 dummy_read();
185}
186
187u8 generic_readb(void __iomem *addr)
188{
189 return ctrl_inb((unsigned long __force)addr);
190}
191
192u16 generic_readw(void __iomem *addr)
193{
194 return ctrl_inw((unsigned long __force)addr);
195}
196
197u32 generic_readl(void __iomem *addr)
198{
199 return ctrl_inl((unsigned long __force)addr);
200}
201
202void generic_writeb(u8 b, void __iomem *addr)
203{
204 ctrl_outb(b, (unsigned long __force)addr);
205}
206
207void generic_writew(u16 b, void __iomem *addr)
208{
209 ctrl_outw(b, (unsigned long __force)addr);
210}
211
212void generic_writel(u32 b, void __iomem *addr)
213{
214 ctrl_outl(b, (unsigned long __force)addr);
215}
216
217void __iomem *generic_ioport_map(unsigned long addr, unsigned int size)
218{
219 return (void __iomem *)(addr + generic_io_base);
220}
221
222void generic_ioport_unmap(void __iomem *addr)
223{
224}
225