.. | .. |
---|
65 | 65 | #endif |
---|
66 | 66 | |
---|
67 | 67 | #ifndef mmio_read16be |
---|
68 | | -#define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr)) |
---|
69 | | -#define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr)) |
---|
| 68 | +#define mmio_read16be(addr) swab16(readw(addr)) |
---|
| 69 | +#define mmio_read32be(addr) swab32(readl(addr)) |
---|
| 70 | +#define mmio_read64be(addr) swab64(readq(addr)) |
---|
70 | 71 | #endif |
---|
71 | 72 | |
---|
72 | | -unsigned int ioread8(void __iomem *addr) |
---|
| 73 | +unsigned int ioread8(const void __iomem *addr) |
---|
73 | 74 | { |
---|
74 | 75 | IO_COND(addr, return inb(port), return readb(addr)); |
---|
75 | 76 | return 0xff; |
---|
76 | 77 | } |
---|
77 | | -unsigned int ioread16(void __iomem *addr) |
---|
| 78 | +unsigned int ioread16(const void __iomem *addr) |
---|
78 | 79 | { |
---|
79 | 80 | IO_COND(addr, return inw(port), return readw(addr)); |
---|
80 | 81 | return 0xffff; |
---|
81 | 82 | } |
---|
82 | | -unsigned int ioread16be(void __iomem *addr) |
---|
| 83 | +unsigned int ioread16be(const void __iomem *addr) |
---|
83 | 84 | { |
---|
84 | 85 | IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); |
---|
85 | 86 | return 0xffff; |
---|
86 | 87 | } |
---|
87 | | -unsigned int ioread32(void __iomem *addr) |
---|
| 88 | +unsigned int ioread32(const void __iomem *addr) |
---|
88 | 89 | { |
---|
89 | 90 | IO_COND(addr, return inl(port), return readl(addr)); |
---|
90 | 91 | return 0xffffffff; |
---|
91 | 92 | } |
---|
92 | | -unsigned int ioread32be(void __iomem *addr) |
---|
| 93 | +unsigned int ioread32be(const void __iomem *addr) |
---|
93 | 94 | { |
---|
94 | 95 | IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); |
---|
95 | 96 | return 0xffffffff; |
---|
.. | .. |
---|
100 | 101 | EXPORT_SYMBOL(ioread32); |
---|
101 | 102 | EXPORT_SYMBOL(ioread32be); |
---|
102 | 103 | |
---|
| 104 | +#ifdef readq |
---|
| 105 | +static u64 pio_read64_lo_hi(unsigned long port) |
---|
| 106 | +{ |
---|
| 107 | + u64 lo, hi; |
---|
| 108 | + |
---|
| 109 | + lo = inl(port); |
---|
| 110 | + hi = inl(port + sizeof(u32)); |
---|
| 111 | + |
---|
| 112 | + return lo | (hi << 32); |
---|
| 113 | +} |
---|
| 114 | + |
---|
| 115 | +static u64 pio_read64_hi_lo(unsigned long port) |
---|
| 116 | +{ |
---|
| 117 | + u64 lo, hi; |
---|
| 118 | + |
---|
| 119 | + hi = inl(port + sizeof(u32)); |
---|
| 120 | + lo = inl(port); |
---|
| 121 | + |
---|
| 122 | + return lo | (hi << 32); |
---|
| 123 | +} |
---|
| 124 | + |
---|
| 125 | +static u64 pio_read64be_lo_hi(unsigned long port) |
---|
| 126 | +{ |
---|
| 127 | + u64 lo, hi; |
---|
| 128 | + |
---|
| 129 | + lo = pio_read32be(port + sizeof(u32)); |
---|
| 130 | + hi = pio_read32be(port); |
---|
| 131 | + |
---|
| 132 | + return lo | (hi << 32); |
---|
| 133 | +} |
---|
| 134 | + |
---|
| 135 | +static u64 pio_read64be_hi_lo(unsigned long port) |
---|
| 136 | +{ |
---|
| 137 | + u64 lo, hi; |
---|
| 138 | + |
---|
| 139 | + hi = pio_read32be(port); |
---|
| 140 | + lo = pio_read32be(port + sizeof(u32)); |
---|
| 141 | + |
---|
| 142 | + return lo | (hi << 32); |
---|
| 143 | +} |
---|
| 144 | + |
---|
| 145 | +u64 ioread64_lo_hi(const void __iomem *addr) |
---|
| 146 | +{ |
---|
| 147 | + IO_COND(addr, return pio_read64_lo_hi(port), return readq(addr)); |
---|
| 148 | + return 0xffffffffffffffffULL; |
---|
| 149 | +} |
---|
| 150 | + |
---|
| 151 | +u64 ioread64_hi_lo(const void __iomem *addr) |
---|
| 152 | +{ |
---|
| 153 | + IO_COND(addr, return pio_read64_hi_lo(port), return readq(addr)); |
---|
| 154 | + return 0xffffffffffffffffULL; |
---|
| 155 | +} |
---|
| 156 | + |
---|
| 157 | +u64 ioread64be_lo_hi(const void __iomem *addr) |
---|
| 158 | +{ |
---|
| 159 | + IO_COND(addr, return pio_read64be_lo_hi(port), |
---|
| 160 | + return mmio_read64be(addr)); |
---|
| 161 | + return 0xffffffffffffffffULL; |
---|
| 162 | +} |
---|
| 163 | + |
---|
| 164 | +u64 ioread64be_hi_lo(const void __iomem *addr) |
---|
| 165 | +{ |
---|
| 166 | + IO_COND(addr, return pio_read64be_hi_lo(port), |
---|
| 167 | + return mmio_read64be(addr)); |
---|
| 168 | + return 0xffffffffffffffffULL; |
---|
| 169 | +} |
---|
| 170 | + |
---|
| 171 | +EXPORT_SYMBOL(ioread64_lo_hi); |
---|
| 172 | +EXPORT_SYMBOL(ioread64_hi_lo); |
---|
| 173 | +EXPORT_SYMBOL(ioread64be_lo_hi); |
---|
| 174 | +EXPORT_SYMBOL(ioread64be_hi_lo); |
---|
| 175 | + |
---|
| 176 | +#endif /* readq */ |
---|
| 177 | + |
---|
103 | 178 | #ifndef pio_write16be |
---|
104 | 179 | #define pio_write16be(val,port) outw(swab16(val),port) |
---|
105 | 180 | #define pio_write32be(val,port) outl(swab32(val),port) |
---|
106 | 181 | #endif |
---|
107 | 182 | |
---|
108 | 183 | #ifndef mmio_write16be |
---|
109 | | -#define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port) |
---|
110 | | -#define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port) |
---|
| 184 | +#define mmio_write16be(val,port) writew(swab16(val),port) |
---|
| 185 | +#define mmio_write32be(val,port) writel(swab32(val),port) |
---|
| 186 | +#define mmio_write64be(val,port) writeq(swab64(val),port) |
---|
111 | 187 | #endif |
---|
112 | 188 | |
---|
113 | 189 | void iowrite8(u8 val, void __iomem *addr) |
---|
.. | .. |
---|
136 | 212 | EXPORT_SYMBOL(iowrite32); |
---|
137 | 213 | EXPORT_SYMBOL(iowrite32be); |
---|
138 | 214 | |
---|
| 215 | +#ifdef writeq |
---|
| 216 | +static void pio_write64_lo_hi(u64 val, unsigned long port) |
---|
| 217 | +{ |
---|
| 218 | + outl(val, port); |
---|
| 219 | + outl(val >> 32, port + sizeof(u32)); |
---|
| 220 | +} |
---|
| 221 | + |
---|
| 222 | +static void pio_write64_hi_lo(u64 val, unsigned long port) |
---|
| 223 | +{ |
---|
| 224 | + outl(val >> 32, port + sizeof(u32)); |
---|
| 225 | + outl(val, port); |
---|
| 226 | +} |
---|
| 227 | + |
---|
| 228 | +static void pio_write64be_lo_hi(u64 val, unsigned long port) |
---|
| 229 | +{ |
---|
| 230 | + pio_write32be(val, port + sizeof(u32)); |
---|
| 231 | + pio_write32be(val >> 32, port); |
---|
| 232 | +} |
---|
| 233 | + |
---|
| 234 | +static void pio_write64be_hi_lo(u64 val, unsigned long port) |
---|
| 235 | +{ |
---|
| 236 | + pio_write32be(val >> 32, port); |
---|
| 237 | + pio_write32be(val, port + sizeof(u32)); |
---|
| 238 | +} |
---|
| 239 | + |
---|
| 240 | +void iowrite64_lo_hi(u64 val, void __iomem *addr) |
---|
| 241 | +{ |
---|
| 242 | + IO_COND(addr, pio_write64_lo_hi(val, port), |
---|
| 243 | + writeq(val, addr)); |
---|
| 244 | +} |
---|
| 245 | + |
---|
| 246 | +void iowrite64_hi_lo(u64 val, void __iomem *addr) |
---|
| 247 | +{ |
---|
| 248 | + IO_COND(addr, pio_write64_hi_lo(val, port), |
---|
| 249 | + writeq(val, addr)); |
---|
| 250 | +} |
---|
| 251 | + |
---|
| 252 | +void iowrite64be_lo_hi(u64 val, void __iomem *addr) |
---|
| 253 | +{ |
---|
| 254 | + IO_COND(addr, pio_write64be_lo_hi(val, port), |
---|
| 255 | + mmio_write64be(val, addr)); |
---|
| 256 | +} |
---|
| 257 | + |
---|
| 258 | +void iowrite64be_hi_lo(u64 val, void __iomem *addr) |
---|
| 259 | +{ |
---|
| 260 | + IO_COND(addr, pio_write64be_hi_lo(val, port), |
---|
| 261 | + mmio_write64be(val, addr)); |
---|
| 262 | +} |
---|
| 263 | + |
---|
| 264 | +EXPORT_SYMBOL(iowrite64_lo_hi); |
---|
| 265 | +EXPORT_SYMBOL(iowrite64_hi_lo); |
---|
| 266 | +EXPORT_SYMBOL(iowrite64be_lo_hi); |
---|
| 267 | +EXPORT_SYMBOL(iowrite64be_hi_lo); |
---|
| 268 | + |
---|
| 269 | +#endif /* readq */ |
---|
| 270 | + |
---|
139 | 271 | /* |
---|
140 | 272 | * These are the "repeat MMIO read/write" functions. |
---|
141 | 273 | * Note the "__raw" accesses, since we don't want to |
---|
.. | .. |
---|
143 | 275 | * order" (we also don't have IO barriers). |
---|
144 | 276 | */ |
---|
145 | 277 | #ifndef mmio_insb |
---|
146 | | -static inline void mmio_insb(void __iomem *addr, u8 *dst, int count) |
---|
| 278 | +static inline void mmio_insb(const void __iomem *addr, u8 *dst, int count) |
---|
147 | 279 | { |
---|
148 | 280 | while (--count >= 0) { |
---|
149 | 281 | u8 data = __raw_readb(addr); |
---|
.. | .. |
---|
151 | 283 | dst++; |
---|
152 | 284 | } |
---|
153 | 285 | } |
---|
154 | | -static inline void mmio_insw(void __iomem *addr, u16 *dst, int count) |
---|
| 286 | +static inline void mmio_insw(const void __iomem *addr, u16 *dst, int count) |
---|
155 | 287 | { |
---|
156 | 288 | while (--count >= 0) { |
---|
157 | 289 | u16 data = __raw_readw(addr); |
---|
.. | .. |
---|
159 | 291 | dst++; |
---|
160 | 292 | } |
---|
161 | 293 | } |
---|
162 | | -static inline void mmio_insl(void __iomem *addr, u32 *dst, int count) |
---|
| 294 | +static inline void mmio_insl(const void __iomem *addr, u32 *dst, int count) |
---|
163 | 295 | { |
---|
164 | 296 | while (--count >= 0) { |
---|
165 | 297 | u32 data = __raw_readl(addr); |
---|
.. | .. |
---|
193 | 325 | } |
---|
194 | 326 | #endif |
---|
195 | 327 | |
---|
196 | | -void ioread8_rep(void __iomem *addr, void *dst, unsigned long count) |
---|
| 328 | +void ioread8_rep(const void __iomem *addr, void *dst, unsigned long count) |
---|
197 | 329 | { |
---|
198 | 330 | IO_COND(addr, insb(port,dst,count), mmio_insb(addr, dst, count)); |
---|
199 | 331 | } |
---|
200 | | -void ioread16_rep(void __iomem *addr, void *dst, unsigned long count) |
---|
| 332 | +void ioread16_rep(const void __iomem *addr, void *dst, unsigned long count) |
---|
201 | 333 | { |
---|
202 | 334 | IO_COND(addr, insw(port,dst,count), mmio_insw(addr, dst, count)); |
---|
203 | 335 | } |
---|
204 | | -void ioread32_rep(void __iomem *addr, void *dst, unsigned long count) |
---|
| 336 | +void ioread32_rep(const void __iomem *addr, void *dst, unsigned long count) |
---|
205 | 337 | { |
---|
206 | 338 | IO_COND(addr, insl(port,dst,count), mmio_insl(addr, dst, count)); |
---|
207 | 339 | } |
---|