Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: machvec IO death.

This takes a bit of a sledgehammer to the machvec I/O routines. The
iomem case requires no special casing and so can just be dropped
outright. This only leaves the ioport casing for PCI and SuperIO
mangling. With the SuperIO case going through the standard ioport
mapping, it's possible to replace everything with generic routines.

With this done the standard I/O routines are tidied up and NO_IOPORT
now gets default-enabled for the vast majority of boards.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

+408 -431
+2 -1
arch/sh/Kconfig
··· 161 161 def_bool y 162 162 163 163 config NO_IOPORT 164 - bool 164 + def_bool !PCI 165 + depends on !SH_CAYMAN && !SH_SH4202_MICRODEV 165 166 166 167 config IO_TRAPPED 167 168 bool
-2
arch/sh/boards/board-secureedge5410.c
··· 29 29 */ 30 30 static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id) 31 31 { 32 - ctrl_delay(); /* dummy read */ 33 - 34 32 printk("SnapGear: erase switch interrupt!\n"); 35 33 36 34 return IRQ_HANDLED;
+1 -2
arch/sh/drivers/pci/pci.c
··· 382 382 struct pci_channel *chan = dev->sysdata; 383 383 384 384 if (unlikely(!chan->io_map_base)) { 385 - chan->io_map_base = generic_io_base; 385 + chan->io_map_base = sh_io_port_base; 386 386 387 387 if (pci_domains_supported) 388 388 panic("To avoid data corruption io_map_base MUST be " 389 389 "set with multiple PCI domains."); 390 390 } 391 - 392 391 393 392 return (void __iomem *)(chan->io_map_base + port); 394 393 }
+192 -177
arch/sh/include/asm/io.h
··· 1 1 #ifndef __ASM_SH_IO_H 2 2 #define __ASM_SH_IO_H 3 + 3 4 /* 4 5 * Convention: 5 6 * read{b,w,l,q}/write{b,w,l,q} are for PCI, ··· 16 15 * SuperH specific I/O (raw I/O to on-chip CPU peripherals). In practice 17 16 * these have the same semantics as the __raw variants, and as such, all 18 17 * new code should be using the __raw versions. 19 - * 20 - * All ISA I/O routines are wrapped through the machine vector. If a 21 - * board does not provide overrides, a generic set that are copied in 22 - * from the default machine vector are used instead. These are largely 23 - * for old compat code for I/O offseting to SuperIOs, all of which are 24 - * better handled through the machvec ioport mapping routines these days. 25 18 */ 26 19 #include <linux/errno.h> 27 20 #include <asm/cache.h> ··· 26 31 #include <asm-generic/iomap.h> 27 32 28 33 #ifdef __KERNEL__ 29 - /* 30 - * Depending on which platform we are running on, we need different 31 - * I/O functions. 32 - */ 33 - #define __IO_PREFIX generic 34 + #define __IO_PREFIX generic 34 35 #include <asm/io_generic.h> 35 36 #include <asm/io_trapped.h> 36 - 37 - #ifdef CONFIG_HAS_IOPORT 38 - 39 - #define inb(p) sh_mv.mv_inb((p)) 40 - #define inw(p) sh_mv.mv_inw((p)) 41 - #define inl(p) sh_mv.mv_inl((p)) 42 - #define outb(x,p) sh_mv.mv_outb((x),(p)) 43 - #define outw(x,p) sh_mv.mv_outw((x),(p)) 44 - #define outl(x,p) sh_mv.mv_outl((x),(p)) 45 - 46 - #define inb_p(p) sh_mv.mv_inb_p((p)) 47 - #define inw_p(p) sh_mv.mv_inw_p((p)) 48 - #define inl_p(p) sh_mv.mv_inl_p((p)) 49 - #define outb_p(x,p) sh_mv.mv_outb_p((x),(p)) 50 - #define outw_p(x,p) sh_mv.mv_outw_p((x),(p)) 51 - #define outl_p(x,p) sh_mv.mv_outl_p((x),(p)) 52 - 53 - #define insb(p,b,c) sh_mv.mv_insb((p), (b), (c)) 54 - #define insw(p,b,c) sh_mv.mv_insw((p), (b), (c)) 55 - #define insl(p,b,c) sh_mv.mv_insl((p), (b), (c)) 56 - #define outsb(p,b,c) sh_mv.mv_outsb((p), (b), (c)) 57 - #define outsw(p,b,c) sh_mv.mv_outsw((p), (b), (c)) 58 - #define outsl(p,b,c) sh_mv.mv_outsl((p), (b), (c)) 59 - 60 - #endif 61 37 62 38 #define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile u8 __force *)(a) = (v)) 63 39 #define __raw_writew(v,a) (__chk_io_ptr(a), *(volatile u16 __force *)(a) = (v)) ··· 40 74 #define __raw_readl(a) (__chk_io_ptr(a), *(volatile u32 __force *)(a)) 41 75 #define __raw_readq(a) (__chk_io_ptr(a), *(volatile u64 __force *)(a)) 42 76 43 - #define readb(a) ({ u8 r_ = __raw_readb(a); mb(); r_; }) 44 - #define readw(a) ({ u16 r_ = __raw_readw(a); mb(); r_; }) 45 - #define readl(a) ({ u32 r_ = __raw_readl(a); mb(); r_; }) 46 - #define readq(a) ({ u64 r_ = __raw_readq(a); mb(); r_; }) 77 + #define readb_relaxed(c) ({ u8 __v = __raw_readb(c); __v; }) 78 + #define readw_relaxed(c) ({ u16 __v = le16_to_cpu((__force __le16) \ 79 + __raw_readw(c)); __v; }) 80 + #define readl_relaxed(c) ({ u32 __v = le32_to_cpu((__force __le32) \ 81 + __raw_readl(c)); __v; }) 82 + #define readq_relaxed(c) ({ u64 __v = le64_to_cpu((__force __le64) \ 83 + __raw_readq(c)); __v; }) 47 84 48 - #define writeb(v,a) ({ __raw_writeb((v),(a)); mb(); }) 49 - #define writew(v,a) ({ __raw_writew((v),(a)); mb(); }) 50 - #define writel(v,a) ({ __raw_writel((v),(a)); mb(); }) 51 - #define writeq(v,a) ({ __raw_writeq((v),(a)); mb(); }) 85 + #define writeb_relaxed(v,c) ((void)__raw_writeb(v,c)) 86 + #define writew_relaxed(v,c) ((void)__raw_writew((__force u16) \ 87 + cpu_to_le16(v),c)) 88 + #define writel_relaxed(v,c) ((void)__raw_writel((__force u32) \ 89 + cpu_to_le32(v),c)) 90 + #define writeq_relaxed(v,c) ((void)__raw_writeq((__force u64) \ 91 + cpu_to_le64(v),c)) 92 + 93 + #define readb(a) ({ u8 r_ = readb_relaxed(a); rmb(); r_; }) 94 + #define readw(a) ({ u16 r_ = readw_relaxed(a); rmb(); r_; }) 95 + #define readl(a) ({ u32 r_ = readl_relaxed(a); rmb(); r_; }) 96 + #define readq(a) ({ u64 r_ = readq_relaxed(a); rmb(); r_; }) 97 + 98 + #define writeb(v,a) ({ wmb(); writeb_relaxed((v),(a)); }) 99 + #define writew(v,a) ({ wmb(); writew_relaxed((v),(a)); }) 100 + #define writel(v,a) ({ wmb(); writel_relaxed((v),(a)); }) 101 + #define writeq(v,a) ({ wmb(); writeq_relaxed((v),(a)); }) 102 + 103 + #define readsb(p,d,l) __raw_readsb(p,d,l) 104 + #define readsw(p,d,l) __raw_readsw(p,d,l) 105 + #define readsl(p,d,l) __raw_readsl(p,d,l) 106 + 107 + #define writesb(p,d,l) __raw_writesb(p,d,l) 108 + #define writesw(p,d,l) __raw_writesw(p,d,l) 109 + #define writesl(p,d,l) __raw_writesl(p,d,l) 110 + 111 + #define __BUILD_UNCACHED_IO(bwlq, type) \ 112 + static inline type read##bwlq##_uncached(unsigned long addr) \ 113 + { \ 114 + type ret; \ 115 + jump_to_uncached(); \ 116 + ret = __raw_read##bwlq(addr); \ 117 + back_to_cached(); \ 118 + return ret; \ 119 + } \ 120 + \ 121 + static inline void write##bwlq##_uncached(type v, unsigned long addr) \ 122 + { \ 123 + jump_to_uncached(); \ 124 + __raw_write##bwlq(v, addr); \ 125 + back_to_cached(); \ 126 + } 127 + 128 + __BUILD_UNCACHED_IO(b, u8) 129 + __BUILD_UNCACHED_IO(w, u16) 130 + __BUILD_UNCACHED_IO(l, u32) 131 + __BUILD_UNCACHED_IO(q, u64) 132 + 133 + #define __BUILD_MEMORY_STRING(pfx, bwlq, type) \ 134 + \ 135 + static inline void \ 136 + pfx##writes##bwlq(volatile void __iomem *mem, const void *addr, \ 137 + unsigned int count) \ 138 + { \ 139 + const volatile type *__addr = addr; \ 140 + \ 141 + while (count--) { \ 142 + __raw_write##bwlq(*__addr, mem); \ 143 + __addr++; \ 144 + } \ 145 + } \ 146 + \ 147 + static inline void pfx##reads##bwlq(volatile void __iomem *mem, \ 148 + void *addr, unsigned int count) \ 149 + { \ 150 + volatile type *__addr = addr; \ 151 + \ 152 + while (count--) { \ 153 + *__addr = __raw_read##bwlq(mem); \ 154 + __addr++; \ 155 + } \ 156 + } 157 + 158 + __BUILD_MEMORY_STRING(__raw_, b, u8) 159 + __BUILD_MEMORY_STRING(__raw_, w, u16) 160 + 161 + #ifdef CONFIG_SUPERH32 162 + void __raw_writesl(void __iomem *addr, const void *data, int longlen); 163 + void __raw_readsl(const void __iomem *addr, void *data, int longlen); 164 + #else 165 + __BUILD_MEMORY_STRING(__raw_, l, u32) 166 + #endif 167 + 168 + __BUILD_MEMORY_STRING(__raw_, q, u64) 169 + 170 + #ifdef CONFIG_HAS_IOPORT 171 + 172 + /* 173 + * Slowdown I/O port space accesses for antique hardware. 174 + */ 175 + #undef CONF_SLOWDOWN_IO 176 + 177 + /* 178 + * On SuperH I/O ports are memory mapped, so we access them using normal 179 + * load/store instructions. sh_io_port_base is the virtual address to 180 + * which all ports are being mapped. 181 + */ 182 + extern const unsigned long sh_io_port_base; 183 + 184 + static inline void __set_io_port_base(unsigned long pbase) 185 + { 186 + *(unsigned long *)&sh_io_port_base = pbase; 187 + barrier(); 188 + } 189 + 190 + #ifdef CONFIG_GENERIC_IOMAP 191 + #define __ioport_map ioport_map 192 + #else 193 + extern void __iomem *__ioport_map(unsigned long addr, unsigned int size); 194 + #endif 195 + 196 + #ifdef CONF_SLOWDOWN_IO 197 + #define SLOW_DOWN_IO __raw_readw(sh_io_port_base) 198 + #else 199 + #define SLOW_DOWN_IO 200 + #endif 201 + 202 + #define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, p, slow) \ 203 + \ 204 + static inline void pfx##out##bwlq##p(type val, unsigned long port) \ 205 + { \ 206 + volatile type *__addr; \ 207 + \ 208 + __addr = __ioport_map(port, sizeof(type)); \ 209 + *__addr = val; \ 210 + slow; \ 211 + } \ 212 + \ 213 + static inline type pfx##in##bwlq##p(unsigned long port) \ 214 + { \ 215 + volatile type *__addr; \ 216 + type __val; \ 217 + \ 218 + __addr = __ioport_map(port, sizeof(type)); \ 219 + __val = *__addr; \ 220 + slow; \ 221 + \ 222 + return __val; \ 223 + } 224 + 225 + #define __BUILD_IOPORT_PFX(bus, bwlq, type) \ 226 + __BUILD_IOPORT_SINGLE(bus, bwlq, type, ,) \ 227 + __BUILD_IOPORT_SINGLE(bus, bwlq, type, _p, SLOW_DOWN_IO) 228 + 229 + #define BUILDIO_IOPORT(bwlq, type) \ 230 + __BUILD_IOPORT_PFX(, bwlq, type) 231 + 232 + BUILDIO_IOPORT(b, u8) 233 + BUILDIO_IOPORT(w, u16) 234 + BUILDIO_IOPORT(l, u32) 235 + BUILDIO_IOPORT(q, u64) 236 + 237 + #define __BUILD_IOPORT_STRING(bwlq, type) \ 238 + \ 239 + static inline void outs##bwlq(unsigned long port, const void *addr, \ 240 + unsigned int count) \ 241 + { \ 242 + const volatile type *__addr = addr; \ 243 + \ 244 + while (count--) { \ 245 + out##bwlq(*__addr, port); \ 246 + __addr++; \ 247 + } \ 248 + } \ 249 + \ 250 + static inline void ins##bwlq(unsigned long port, void *addr, \ 251 + unsigned int count) \ 252 + { \ 253 + volatile type *__addr = addr; \ 254 + \ 255 + while (count--) { \ 256 + *__addr = in##bwlq(port); \ 257 + __addr++; \ 258 + } \ 259 + } 260 + 261 + __BUILD_IOPORT_STRING(b, u8) 262 + __BUILD_IOPORT_STRING(w, u16) 263 + __BUILD_IOPORT_STRING(l, u32) 264 + __BUILD_IOPORT_STRING(q, u64) 265 + 266 + #endif 52 267 53 268 /* 54 269 * Legacy SuperH on-chip I/O functions ··· 277 130 __raw_writeq(v, addr); 278 131 } 279 132 280 - extern unsigned long generic_io_base; 281 - 282 - static inline void ctrl_delay(void) 283 - { 284 - __raw_readw(generic_io_base); 285 - } 286 - 287 - #define __BUILD_UNCACHED_IO(bwlq, type) \ 288 - static inline type read##bwlq##_uncached(unsigned long addr) \ 289 - { \ 290 - type ret; \ 291 - jump_to_uncached(); \ 292 - ret = __raw_read##bwlq(addr); \ 293 - back_to_cached(); \ 294 - return ret; \ 295 - } \ 296 - \ 297 - static inline void write##bwlq##_uncached(type v, unsigned long addr) \ 298 - { \ 299 - jump_to_uncached(); \ 300 - __raw_write##bwlq(v, addr); \ 301 - back_to_cached(); \ 302 - } 303 - 304 - __BUILD_UNCACHED_IO(b, u8) 305 - __BUILD_UNCACHED_IO(w, u16) 306 - __BUILD_UNCACHED_IO(l, u32) 307 - __BUILD_UNCACHED_IO(q, u64) 308 - 309 - #define __BUILD_MEMORY_STRING(bwlq, type) \ 310 - \ 311 - static inline void __raw_writes##bwlq(volatile void __iomem *mem, \ 312 - const void *addr, unsigned int count) \ 313 - { \ 314 - const volatile type *__addr = addr; \ 315 - \ 316 - while (count--) { \ 317 - __raw_write##bwlq(*__addr, mem); \ 318 - __addr++; \ 319 - } \ 320 - } \ 321 - \ 322 - static inline void __raw_reads##bwlq(volatile void __iomem *mem, \ 323 - void *addr, unsigned int count) \ 324 - { \ 325 - volatile type *__addr = addr; \ 326 - \ 327 - while (count--) { \ 328 - *__addr = __raw_read##bwlq(mem); \ 329 - __addr++; \ 330 - } \ 331 - } 332 - 333 - __BUILD_MEMORY_STRING(b, u8) 334 - __BUILD_MEMORY_STRING(w, u16) 335 - 336 - #ifdef CONFIG_SUPERH32 337 - void __raw_writesl(void __iomem *addr, const void *data, int longlen); 338 - void __raw_readsl(const void __iomem *addr, void *data, int longlen); 339 - #else 340 - __BUILD_MEMORY_STRING(l, u32) 341 - #endif 342 - 343 - __BUILD_MEMORY_STRING(q, u64) 344 - 345 - #define writesb __raw_writesb 346 - #define writesw __raw_writesw 347 - #define writesl __raw_writesl 348 - 349 - #define readsb __raw_readsb 350 - #define readsw __raw_readsw 351 - #define readsl __raw_readsl 352 - 353 - #define readb_relaxed(a) readb(a) 354 - #define readw_relaxed(a) readw(a) 355 - #define readl_relaxed(a) readl(a) 356 - #define readq_relaxed(a) readq(a) 357 - 358 - #ifndef CONFIG_GENERIC_IOMAP 359 - /* Simple MMIO */ 360 - #define ioread8(a) __raw_readb(a) 361 - #define ioread16(a) __raw_readw(a) 362 - #define ioread16be(a) be16_to_cpu(__raw_readw((a))) 363 - #define ioread32(a) __raw_readl(a) 364 - #define ioread32be(a) be32_to_cpu(__raw_readl((a))) 365 - 366 - #define iowrite8(v,a) __raw_writeb((v),(a)) 367 - #define iowrite16(v,a) __raw_writew((v),(a)) 368 - #define iowrite16be(v,a) __raw_writew(cpu_to_be16((v)),(a)) 369 - #define iowrite32(v,a) __raw_writel((v),(a)) 370 - #define iowrite32be(v,a) __raw_writel(cpu_to_be32((v)),(a)) 371 - 372 - #define ioread8_rep(a, d, c) __raw_readsb((a), (d), (c)) 373 - #define ioread16_rep(a, d, c) __raw_readsw((a), (d), (c)) 374 - #define ioread32_rep(a, d, c) __raw_readsl((a), (d), (c)) 375 - 376 - #define iowrite8_rep(a, s, c) __raw_writesb((a), (s), (c)) 377 - #define iowrite16_rep(a, s, c) __raw_writesw((a), (s), (c)) 378 - #define iowrite32_rep(a, s, c) __raw_writesl((a), (s), (c)) 379 - #endif 380 - 381 - #define mmio_insb(p,d,c) __raw_readsb(p,d,c) 382 - #define mmio_insw(p,d,c) __raw_readsw(p,d,c) 383 - #define mmio_insl(p,d,c) __raw_readsl(p,d,c) 384 - 385 - #define mmio_outsb(p,s,c) __raw_writesb(p,s,c) 386 - #define mmio_outsw(p,s,c) __raw_writesw(p,s,c) 387 - #define mmio_outsl(p,s,c) __raw_writesl(p,s,c) 133 + #define IO_SPACE_LIMIT 0xffffffff 388 134 389 135 /* synco on SH-4A, otherwise a nop */ 390 136 #define mmiowb() wmb() 391 - 392 - #define IO_SPACE_LIMIT 0xffffffff 393 - 394 - #ifdef CONFIG_HAS_IOPORT 395 - 396 - /* 397 - * This function provides a method for the generic case where a 398 - * board-specific ioport_map simply needs to return the port + some 399 - * arbitrary port base. 400 - * 401 - * We use this at board setup time to implicitly set the port base, and 402 - * as a result, we can use the generic ioport_map. 403 - */ 404 - static inline void __set_io_port_base(unsigned long pbase) 405 - { 406 - generic_io_base = pbase; 407 - } 408 - 409 - #define __ioport_map(p, n) sh_mv.mv_ioport_map((p), (n)) 410 - 411 - #endif 412 137 413 138 /* We really want to try and get these to memcpy etc */ 414 139 void memcpy_fromio(void *, const volatile void __iomem *, unsigned long); ··· 413 394 414 395 #define ioremap_nocache ioremap 415 396 #define iounmap __iounmap 416 - 417 - #define maybebadio(port) \ 418 - printk(KERN_ERR "bad PC-like io %s:%u for port 0x%lx at 0x%08x\n", \ 419 - __func__, __LINE__, (port), (u32)__builtin_return_address(0)) 420 397 421 398 /* 422 399 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
-25
arch/sh/include/asm/io_generic.h
··· 11 11 #error "Don't include this header without a valid system prefix" 12 12 #endif 13 13 14 - u8 IO_CONCAT(__IO_PREFIX,inb)(unsigned long); 15 - u16 IO_CONCAT(__IO_PREFIX,inw)(unsigned long); 16 - u32 IO_CONCAT(__IO_PREFIX,inl)(unsigned long); 17 - 18 - void IO_CONCAT(__IO_PREFIX,outb)(u8, unsigned long); 19 - void IO_CONCAT(__IO_PREFIX,outw)(u16, unsigned long); 20 - void IO_CONCAT(__IO_PREFIX,outl)(u32, unsigned long); 21 - 22 - u8 IO_CONCAT(__IO_PREFIX,inb_p)(unsigned long); 23 - u16 IO_CONCAT(__IO_PREFIX,inw_p)(unsigned long); 24 - u32 IO_CONCAT(__IO_PREFIX,inl_p)(unsigned long); 25 - void IO_CONCAT(__IO_PREFIX,outb_p)(u8, unsigned long); 26 - void IO_CONCAT(__IO_PREFIX,outw_p)(u16, unsigned long); 27 - void IO_CONCAT(__IO_PREFIX,outl_p)(u32, unsigned long); 28 - 29 - void IO_CONCAT(__IO_PREFIX,insb)(unsigned long, void *dst, unsigned long count); 30 - void IO_CONCAT(__IO_PREFIX,insw)(unsigned long, void *dst, unsigned long count); 31 - void IO_CONCAT(__IO_PREFIX,insl)(unsigned long, void *dst, unsigned long count); 32 - void IO_CONCAT(__IO_PREFIX,outsb)(unsigned long, const void *src, unsigned long count); 33 - void IO_CONCAT(__IO_PREFIX,outsw)(unsigned long, const void *src, unsigned long count); 34 - void IO_CONCAT(__IO_PREFIX,outsl)(unsigned long, const void *src, unsigned long count); 35 - 36 - void *IO_CONCAT(__IO_PREFIX,ioremap)(unsigned long offset, unsigned long size); 37 - void IO_CONCAT(__IO_PREFIX,iounmap)(void *addr); 38 - 39 14 void __iomem *IO_CONCAT(__IO_PREFIX,ioport_map)(unsigned long addr, unsigned int size); 40 15 void IO_CONCAT(__IO_PREFIX,ioport_unmap)(void __iomem *addr); 41 16 void IO_CONCAT(__IO_PREFIX,mem_init)(void);
-21
arch/sh/include/asm/machvec.h
··· 23 23 void (*mv_init_irq)(void); 24 24 25 25 #ifdef CONFIG_HAS_IOPORT 26 - u8 (*mv_inb)(unsigned long); 27 - u16 (*mv_inw)(unsigned long); 28 - u32 (*mv_inl)(unsigned long); 29 - void (*mv_outb)(u8, unsigned long); 30 - void (*mv_outw)(u16, unsigned long); 31 - void (*mv_outl)(u32, unsigned long); 32 - 33 - u8 (*mv_inb_p)(unsigned long); 34 - u16 (*mv_inw_p)(unsigned long); 35 - u32 (*mv_inl_p)(unsigned long); 36 - void (*mv_outb_p)(u8, unsigned long); 37 - void (*mv_outw_p)(u16, unsigned long); 38 - void (*mv_outl_p)(u32, unsigned long); 39 - 40 - void (*mv_insb)(unsigned long, void *dst, unsigned long count); 41 - void (*mv_insw)(unsigned long, void *dst, unsigned long count); 42 - void (*mv_insl)(unsigned long, void *dst, unsigned long count); 43 - void (*mv_outsb)(unsigned long, const void *src, unsigned long count); 44 - void (*mv_outsw)(unsigned long, const void *src, unsigned long count); 45 - void (*mv_outsl)(unsigned long, const void *src, unsigned long count); 46 - 47 26 void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size); 48 27 void (*mv_ioport_unmap)(void __iomem *); 49 28 #endif
+5 -1
arch/sh/kernel/Makefile
··· 20 20 syscalls_$(BITS).o time.o topology.o traps.o \ 21 21 traps_$(BITS).o unwinder.o 22 22 23 + ifndef CONFIG_GENERIC_IOMAP 24 + obj-y += iomap.o 25 + obj-$(CONFIG_HAS_IOPORT) += ioport.o 26 + endif 27 + 23 28 obj-y += cpu/ 24 29 obj-$(CONFIG_VSYSCALL) += vsyscall/ 25 30 obj-$(CONFIG_SMP) += smp.o ··· 44 39 obj-$(CONFIG_HIBERNATION) += swsusp.o 45 40 obj-$(CONFIG_DWARF_UNWINDER) += dwarf.o 46 41 obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_callchain.o 47 - obj-$(CONFIG_HAS_IOPORT) += io_generic.o 48 42 49 43 obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o 50 44 obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += localtimer.o
-180
arch/sh/kernel/io_generic.c
··· 1 - /* 2 - * arch/sh/kernel/io_generic.c 3 - * 4 - * Copyright (C) 2000 Niibe Yutaka 5 - * Copyright (C) 2005 - 2007 Paul Mundt 6 - * 7 - * Generic I/O routine. These can be used where a machine specific version 8 - * is not required. 9 - * 10 - * This file is subject to the terms and conditions of the GNU General Public 11 - * License. See the file "COPYING" in the main directory of this archive 12 - * for more details. 13 - */ 14 - #include <linux/module.h> 15 - #include <linux/io.h> 16 - #include <asm/machvec.h> 17 - 18 - #ifdef CONFIG_CPU_SH3 19 - /* SH3 has a PCMCIA bug that needs a dummy read from area 6 for a 20 - * workaround. */ 21 - /* I'm not sure SH7709 has this kind of bug */ 22 - #define dummy_read() __raw_readb(0xba000000) 23 - #else 24 - #define dummy_read() 25 - #endif 26 - 27 - unsigned long generic_io_base = 0; 28 - 29 - u8 generic_inb(unsigned long port) 30 - { 31 - return __raw_readb(__ioport_map(port, 1)); 32 - } 33 - 34 - u16 generic_inw(unsigned long port) 35 - { 36 - return __raw_readw(__ioport_map(port, 2)); 37 - } 38 - 39 - u32 generic_inl(unsigned long port) 40 - { 41 - return __raw_readl(__ioport_map(port, 4)); 42 - } 43 - 44 - u8 generic_inb_p(unsigned long port) 45 - { 46 - unsigned long v = generic_inb(port); 47 - 48 - ctrl_delay(); 49 - return v; 50 - } 51 - 52 - u16 generic_inw_p(unsigned long port) 53 - { 54 - unsigned long v = generic_inw(port); 55 - 56 - ctrl_delay(); 57 - return v; 58 - } 59 - 60 - u32 generic_inl_p(unsigned long port) 61 - { 62 - unsigned long v = generic_inl(port); 63 - 64 - ctrl_delay(); 65 - return v; 66 - } 67 - 68 - /* 69 - * insb/w/l all read a series of bytes/words/longs from a fixed port 70 - * address. However as the port address doesn't change we only need to 71 - * convert the port address to real address once. 72 - */ 73 - 74 - void generic_insb(unsigned long port, void *dst, unsigned long count) 75 - { 76 - __raw_readsb(__ioport_map(port, 1), dst, count); 77 - dummy_read(); 78 - } 79 - 80 - void generic_insw(unsigned long port, void *dst, unsigned long count) 81 - { 82 - __raw_readsw(__ioport_map(port, 2), dst, count); 83 - dummy_read(); 84 - } 85 - 86 - void generic_insl(unsigned long port, void *dst, unsigned long count) 87 - { 88 - __raw_readsl(__ioport_map(port, 4), dst, count); 89 - dummy_read(); 90 - } 91 - 92 - void generic_outb(u8 b, unsigned long port) 93 - { 94 - __raw_writeb(b, __ioport_map(port, 1)); 95 - } 96 - 97 - void generic_outw(u16 b, unsigned long port) 98 - { 99 - __raw_writew(b, __ioport_map(port, 2)); 100 - } 101 - 102 - void generic_outl(u32 b, unsigned long port) 103 - { 104 - __raw_writel(b, __ioport_map(port, 4)); 105 - } 106 - 107 - void generic_outb_p(u8 b, unsigned long port) 108 - { 109 - generic_outb(b, port); 110 - ctrl_delay(); 111 - } 112 - 113 - void generic_outw_p(u16 b, unsigned long port) 114 - { 115 - generic_outw(b, port); 116 - ctrl_delay(); 117 - } 118 - 119 - void generic_outl_p(u32 b, unsigned long port) 120 - { 121 - generic_outl(b, port); 122 - ctrl_delay(); 123 - } 124 - 125 - /* 126 - * outsb/w/l all write a series of bytes/words/longs to a fixed port 127 - * address. However as the port address doesn't change we only need to 128 - * convert the port address to real address once. 129 - */ 130 - void generic_outsb(unsigned long port, const void *src, unsigned long count) 131 - { 132 - __raw_writesb(__ioport_map(port, 1), src, count); 133 - dummy_read(); 134 - } 135 - 136 - void generic_outsw(unsigned long port, const void *src, unsigned long count) 137 - { 138 - __raw_writesw(__ioport_map(port, 2), src, count); 139 - dummy_read(); 140 - } 141 - 142 - void generic_outsl(unsigned long port, const void *src, unsigned long count) 143 - { 144 - __raw_writesl(__ioport_map(port, 4), src, count); 145 - dummy_read(); 146 - } 147 - 148 - void __iomem *generic_ioport_map(unsigned long addr, unsigned int size) 149 - { 150 - #ifdef P1SEG 151 - if (PXSEG(addr) >= P1SEG) 152 - return (void __iomem *)addr; 153 - #endif 154 - 155 - return (void __iomem *)(addr + generic_io_base); 156 - } 157 - 158 - void generic_ioport_unmap(void __iomem *addr) 159 - { 160 - } 161 - 162 - #ifndef CONFIG_GENERIC_IOMAP 163 - void __iomem *ioport_map(unsigned long port, unsigned int nr) 164 - { 165 - void __iomem *ret; 166 - 167 - ret = __ioport_map_trapped(port, nr); 168 - if (ret) 169 - return ret; 170 - 171 - return __ioport_map(port, nr); 172 - } 173 - EXPORT_SYMBOL(ioport_map); 174 - 175 - void ioport_unmap(void __iomem *addr) 176 - { 177 - sh_mv.mv_ioport_unmap(addr); 178 - } 179 - EXPORT_SYMBOL(ioport_unmap); 180 - #endif /* CONFIG_GENERIC_IOMAP */
+165
arch/sh/kernel/iomap.c
··· 1 + /* 2 + * arch/sh/kernel/iomap.c 3 + * 4 + * Copyright (C) 2000 Niibe Yutaka 5 + * Copyright (C) 2005 - 2007 Paul Mundt 6 + * 7 + * This file is subject to the terms and conditions of the GNU General Public 8 + * License. See the file "COPYING" in the main directory of this archive 9 + * for more details. 10 + */ 11 + #include <linux/module.h> 12 + #include <linux/io.h> 13 + 14 + unsigned int ioread8(void __iomem *addr) 15 + { 16 + return readb(addr); 17 + } 18 + EXPORT_SYMBOL(ioread8); 19 + 20 + unsigned int ioread16(void __iomem *addr) 21 + { 22 + return readw(addr); 23 + } 24 + EXPORT_SYMBOL(ioread16); 25 + 26 + unsigned int ioread16be(void __iomem *addr) 27 + { 28 + return be16_to_cpu(__raw_readw(addr)); 29 + } 30 + EXPORT_SYMBOL(ioread16be); 31 + 32 + unsigned int ioread32(void __iomem *addr) 33 + { 34 + return readl(addr); 35 + } 36 + EXPORT_SYMBOL(ioread32); 37 + 38 + unsigned int ioread32be(void __iomem *addr) 39 + { 40 + return be32_to_cpu(__raw_readl(addr)); 41 + } 42 + EXPORT_SYMBOL(ioread32be); 43 + 44 + void iowrite8(u8 val, void __iomem *addr) 45 + { 46 + writeb(val, addr); 47 + } 48 + EXPORT_SYMBOL(iowrite8); 49 + 50 + void iowrite16(u16 val, void __iomem *addr) 51 + { 52 + writew(val, addr); 53 + } 54 + EXPORT_SYMBOL(iowrite16); 55 + 56 + void iowrite16be(u16 val, void __iomem *addr) 57 + { 58 + __raw_writew(cpu_to_be16(val), addr); 59 + } 60 + EXPORT_SYMBOL(iowrite16be); 61 + 62 + void iowrite32(u32 val, void __iomem *addr) 63 + { 64 + writel(val, addr); 65 + } 66 + EXPORT_SYMBOL(iowrite32); 67 + 68 + void iowrite32be(u32 val, void __iomem *addr) 69 + { 70 + __raw_writel(cpu_to_be32(val), addr); 71 + } 72 + EXPORT_SYMBOL(iowrite32be); 73 + 74 + /* 75 + * These are the "repeat MMIO read/write" functions. 76 + * Note the "__raw" accesses, since we don't want to 77 + * convert to CPU byte order. We write in "IO byte 78 + * order" (we also don't have IO barriers). 79 + */ 80 + static inline void mmio_insb(void __iomem *addr, u8 *dst, int count) 81 + { 82 + while (--count >= 0) { 83 + u8 data = __raw_readb(addr); 84 + *dst = data; 85 + dst++; 86 + } 87 + } 88 + 89 + static inline void mmio_insw(void __iomem *addr, u16 *dst, int count) 90 + { 91 + while (--count >= 0) { 92 + u16 data = __raw_readw(addr); 93 + *dst = data; 94 + dst++; 95 + } 96 + } 97 + 98 + static inline void mmio_insl(void __iomem *addr, u32 *dst, int count) 99 + { 100 + while (--count >= 0) { 101 + u32 data = __raw_readl(addr); 102 + *dst = data; 103 + dst++; 104 + } 105 + } 106 + 107 + static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count) 108 + { 109 + while (--count >= 0) { 110 + __raw_writeb(*src, addr); 111 + src++; 112 + } 113 + } 114 + 115 + static inline void mmio_outsw(void __iomem *addr, const u16 *src, int count) 116 + { 117 + while (--count >= 0) { 118 + __raw_writew(*src, addr); 119 + src++; 120 + } 121 + } 122 + 123 + static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count) 124 + { 125 + while (--count >= 0) { 126 + __raw_writel(*src, addr); 127 + src++; 128 + } 129 + } 130 + 131 + void ioread8_rep(void __iomem *addr, void *dst, unsigned long count) 132 + { 133 + mmio_insb(addr, dst, count); 134 + } 135 + EXPORT_SYMBOL(ioread8_rep); 136 + 137 + void ioread16_rep(void __iomem *addr, void *dst, unsigned long count) 138 + { 139 + mmio_insw(addr, dst, count); 140 + } 141 + EXPORT_SYMBOL(ioread16_rep); 142 + 143 + void ioread32_rep(void __iomem *addr, void *dst, unsigned long count) 144 + { 145 + mmio_insl(addr, dst, count); 146 + } 147 + EXPORT_SYMBOL(ioread32_rep); 148 + 149 + void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count) 150 + { 151 + mmio_outsb(addr, src, count); 152 + } 153 + EXPORT_SYMBOL(iowrite8_rep); 154 + 155 + void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count) 156 + { 157 + mmio_outsw(addr, src, count); 158 + } 159 + EXPORT_SYMBOL(iowrite16_rep); 160 + 161 + void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count) 162 + { 163 + mmio_outsl(addr, src, count); 164 + } 165 + EXPORT_SYMBOL(iowrite32_rep);
+43
arch/sh/kernel/ioport.c
··· 1 + /* 2 + * arch/sh/kernel/ioport.c 3 + * 4 + * Copyright (C) 2000 Niibe Yutaka 5 + * Copyright (C) 2005 - 2007 Paul Mundt 6 + * 7 + * This file is subject to the terms and conditions of the GNU General Public 8 + * License. See the file "COPYING" in the main directory of this archive 9 + * for more details. 10 + */ 11 + #include <linux/module.h> 12 + #include <linux/io.h> 13 + 14 + const unsigned long sh_io_port_base __read_mostly = -1; 15 + EXPORT_SYMBOL(sh_io_port_base); 16 + 17 + void __iomem *__ioport_map(unsigned long addr, unsigned int size) 18 + { 19 + if (sh_mv.mv_ioport_map) 20 + return sh_mv.mv_ioport_map(addr, size); 21 + 22 + return (void __iomem *)(addr + sh_io_port_base); 23 + } 24 + EXPORT_SYMBOL(__ioport_map); 25 + 26 + void __iomem *ioport_map(unsigned long port, unsigned int nr) 27 + { 28 + void __iomem *ret; 29 + 30 + ret = __ioport_map_trapped(port, nr); 31 + if (ret) 32 + return ret; 33 + 34 + return __ioport_map(port, nr); 35 + } 36 + EXPORT_SYMBOL(ioport_map); 37 + 38 + void ioport_unmap(void __iomem *addr) 39 + { 40 + if (sh_mv.mv_ioport_unmap) 41 + sh_mv.mv_ioport_unmap(addr); 42 + } 43 + EXPORT_SYMBOL(ioport_unmap);
-22
arch/sh/kernel/machvec.c
··· 118 118 sh_mv.mv_##elem = generic_##elem; \ 119 119 } while (0) 120 120 121 - #ifdef CONFIG_HAS_IOPORT 122 - 123 - #ifdef P2SEG 124 - __set_io_port_base(P2SEG); 125 - #else 126 - __set_io_port_base(0); 127 - #endif 128 - 129 - mv_set(inb); mv_set(inw); mv_set(inl); 130 - mv_set(outb); mv_set(outw); mv_set(outl); 131 - 132 - mv_set(inb_p); mv_set(inw_p); mv_set(inl_p); 133 - mv_set(outb_p); mv_set(outw_p); mv_set(outl_p); 134 - 135 - mv_set(insb); mv_set(insw); mv_set(insl); 136 - mv_set(outsb); mv_set(outsw); mv_set(outsl); 137 - 138 - mv_set(ioport_map); 139 - mv_set(ioport_unmap); 140 - 141 - #endif 142 - 143 121 mv_set(irq_demux); 144 122 mv_set(mode_pins); 145 123 mv_set(mem_init);