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

sh: mach-microdev: SuperIO-relative ioport mapping.

The microdev only has to contend with silly PIO mangling on anything
within the SuperIO range. As each of the SuperIO modules is already
speciail cased, we just shift that logic over to the ioport map.

With microdev PCI never being merged (and being fudamentally broken in
hardware), and the ethernet chip only doing 16-bit accesses already,
there's no need to maintain any of the extra special casing. Kill it all
off.

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

+3 -275
+2 -244
arch/sh/boards/mach-microdev/io.c
··· 54 54 /* 55 55 * map I/O ports to memory-mapped addresses 56 56 */ 57 - static unsigned long microdev_isa_port2addr(unsigned long offset) 57 + void __iomem *microdev_ioport_map(unsigned long offset, unsigned int len) 58 58 { 59 59 unsigned long result; 60 60 ··· 72 72 * Configuration Registers 73 73 */ 74 74 result = IO_SUPERIO_PHYS + (offset << 1); 75 - #if 0 76 - } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG || 77 - offset == KBD_STATUS_REG) { 78 - /* 79 - * SMSC FDC37C93xAPM SuperIO chip 80 - * 81 - * PS/2 Keyboard + Mouse (ports 0x60 and 0x64). 82 - */ 83 - result = IO_SUPERIO_PHYS + (offset << 1); 84 - #endif 85 75 } else if (((offset >= IO_IDE1_BASE) && 86 76 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) || 87 77 (offset == IO_IDE1_MISC)) { ··· 121 131 result = PVR; 122 132 } 123 133 124 - return result; 125 - } 126 - 127 - #define PORT2ADDR(x) (microdev_isa_port2addr(x)) 128 - 129 - static inline void delay(void) 130 - { 131 - #if defined(CONFIG_PCI) 132 - /* System board present, just make a dummy SRAM access. (CS0 will be 133 - mapped to PCI memory, probably good to avoid it.) */ 134 - __raw_readw(0xa6800000); 135 - #else 136 - /* CS0 will be mapped to flash, ROM etc so safe to access it. */ 137 - __raw_readw(0xa0000000); 138 - #endif 139 - } 140 - 141 - unsigned char microdev_inb(unsigned long port) 142 - { 143 - #ifdef CONFIG_PCI 144 - if (port >= PCIBIOS_MIN_IO) 145 - return microdev_pci_inb(port); 146 - #endif 147 - return *(volatile unsigned char*)PORT2ADDR(port); 148 - } 149 - 150 - unsigned short microdev_inw(unsigned long port) 151 - { 152 - #ifdef CONFIG_PCI 153 - if (port >= PCIBIOS_MIN_IO) 154 - return microdev_pci_inw(port); 155 - #endif 156 - return *(volatile unsigned short*)PORT2ADDR(port); 157 - } 158 - 159 - unsigned int microdev_inl(unsigned long port) 160 - { 161 - #ifdef CONFIG_PCI 162 - if (port >= PCIBIOS_MIN_IO) 163 - return microdev_pci_inl(port); 164 - #endif 165 - return *(volatile unsigned int*)PORT2ADDR(port); 166 - } 167 - 168 - void microdev_outw(unsigned short b, unsigned long port) 169 - { 170 - #ifdef CONFIG_PCI 171 - if (port >= PCIBIOS_MIN_IO) { 172 - microdev_pci_outw(b, port); 173 - return; 174 - } 175 - #endif 176 - *(volatile unsigned short*)PORT2ADDR(port) = b; 177 - } 178 - 179 - void microdev_outb(unsigned char b, unsigned long port) 180 - { 181 - #ifdef CONFIG_PCI 182 - if (port >= PCIBIOS_MIN_IO) { 183 - microdev_pci_outb(b, port); 184 - return; 185 - } 186 - #endif 187 - 188 - /* 189 - * There is a board feature with the current SH4-202 MicroDev in 190 - * that the 2 byte enables (nBE0 and nBE1) are tied together (and 191 - * to the Chip Select Line (Ethernet_CS)). Due to this connectivity, 192 - * it is not possible to safely perform 8-bit writes to the 193 - * Ethernet registers, as 16-bits will be consumed from the Data 194 - * lines (corrupting the other byte). Hence, this function is 195 - * written to implement 16-bit read/modify/write for all byte-wide 196 - * accesses. 197 - * 198 - * Note: there is no problem with byte READS (even or odd). 199 - * 200 - * Sean McGoogan - 16th June 2003. 201 - */ 202 - if ((port >= IO_LAN91C111_BASE) && 203 - (port < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) { 204 - /* 205 - * Then are trying to perform a byte-write to the 206 - * LAN91C111. This needs special care. 207 - */ 208 - if (port % 2 == 1) { /* is the port odd ? */ 209 - /* unset bit-0, i.e. make even */ 210 - const unsigned long evenPort = port-1; 211 - unsigned short word; 212 - 213 - /* 214 - * do a 16-bit read/write to write to 'port', 215 - * preserving even byte. 216 - * 217 - * Even addresses are bits 0-7 218 - * Odd addresses are bits 8-15 219 - */ 220 - word = microdev_inw(evenPort); 221 - word = (word & 0xffu) | (b << 8); 222 - microdev_outw(word, evenPort); 223 - } else { 224 - /* else, we are trying to do an even byte write */ 225 - unsigned short word; 226 - 227 - /* 228 - * do a 16-bit read/write to write to 'port', 229 - * preserving odd byte. 230 - * 231 - * Even addresses are bits 0-7 232 - * Odd addresses are bits 8-15 233 - */ 234 - word = microdev_inw(port); 235 - word = (word & 0xff00u) | (b); 236 - microdev_outw(word, port); 237 - } 238 - } else { 239 - *(volatile unsigned char*)PORT2ADDR(port) = b; 240 - } 241 - } 242 - 243 - void microdev_outl(unsigned int b, unsigned long port) 244 - { 245 - #ifdef CONFIG_PCI 246 - if (port >= PCIBIOS_MIN_IO) { 247 - microdev_pci_outl(b, port); 248 - return; 249 - } 250 - #endif 251 - *(volatile unsigned int*)PORT2ADDR(port) = b; 252 - } 253 - 254 - unsigned char microdev_inb_p(unsigned long port) 255 - { 256 - unsigned char v = microdev_inb(port); 257 - delay(); 258 - return v; 259 - } 260 - 261 - unsigned short microdev_inw_p(unsigned long port) 262 - { 263 - unsigned short v = microdev_inw(port); 264 - delay(); 265 - return v; 266 - } 267 - 268 - unsigned int microdev_inl_p(unsigned long port) 269 - { 270 - unsigned int v = microdev_inl(port); 271 - delay(); 272 - return v; 273 - } 274 - 275 - void microdev_outb_p(unsigned char b, unsigned long port) 276 - { 277 - microdev_outb(b, port); 278 - delay(); 279 - } 280 - 281 - void microdev_outw_p(unsigned short b, unsigned long port) 282 - { 283 - microdev_outw(b, port); 284 - delay(); 285 - } 286 - 287 - void microdev_outl_p(unsigned int b, unsigned long port) 288 - { 289 - microdev_outl(b, port); 290 - delay(); 291 - } 292 - 293 - void microdev_insb(unsigned long port, void *buffer, unsigned long count) 294 - { 295 - volatile unsigned char *port_addr; 296 - unsigned char *buf = buffer; 297 - 298 - port_addr = (volatile unsigned char *)PORT2ADDR(port); 299 - 300 - while (count--) 301 - *buf++ = *port_addr; 302 - } 303 - 304 - void microdev_insw(unsigned long port, void *buffer, unsigned long count) 305 - { 306 - volatile unsigned short *port_addr; 307 - unsigned short *buf = buffer; 308 - 309 - port_addr = (volatile unsigned short *)PORT2ADDR(port); 310 - 311 - while (count--) 312 - *buf++ = *port_addr; 313 - } 314 - 315 - void microdev_insl(unsigned long port, void *buffer, unsigned long count) 316 - { 317 - volatile unsigned long *port_addr; 318 - unsigned int *buf = buffer; 319 - 320 - port_addr = (volatile unsigned long *)PORT2ADDR(port); 321 - 322 - while (count--) 323 - *buf++ = *port_addr; 324 - } 325 - 326 - void microdev_outsb(unsigned long port, const void *buffer, unsigned long count) 327 - { 328 - volatile unsigned char *port_addr; 329 - const unsigned char *buf = buffer; 330 - 331 - port_addr = (volatile unsigned char *)PORT2ADDR(port); 332 - 333 - while (count--) 334 - *port_addr = *buf++; 335 - } 336 - 337 - void microdev_outsw(unsigned long port, const void *buffer, unsigned long count) 338 - { 339 - volatile unsigned short *port_addr; 340 - const unsigned short *buf = buffer; 341 - 342 - port_addr = (volatile unsigned short *)PORT2ADDR(port); 343 - 344 - while (count--) 345 - *port_addr = *buf++; 346 - } 347 - 348 - void microdev_outsl(unsigned long port, const void *buffer, unsigned long count) 349 - { 350 - volatile unsigned long *port_addr; 351 - const unsigned int *buf = buffer; 352 - 353 - port_addr = (volatile unsigned long *)PORT2ADDR(port); 354 - 355 - while (count--) 356 - *port_addr = *buf++; 134 + return (void __iomem *)result; 357 135 }
+1 -22
arch/sh/boards/mach-microdev/setup.c
··· 195 195 static struct sh_machine_vector mv_sh4202_microdev __initmv = { 196 196 .mv_name = "SH4-202 MicroDev", 197 197 .mv_nr_irqs = 72, 198 - 199 - .mv_inb = microdev_inb, 200 - .mv_inw = microdev_inw, 201 - .mv_inl = microdev_inl, 202 - .mv_outb = microdev_outb, 203 - .mv_outw = microdev_outw, 204 - .mv_outl = microdev_outl, 205 - 206 - .mv_inb_p = microdev_inb_p, 207 - .mv_inw_p = microdev_inw_p, 208 - .mv_inl_p = microdev_inl_p, 209 - .mv_outb_p = microdev_outb_p, 210 - .mv_outw_p = microdev_outw_p, 211 - .mv_outl_p = microdev_outl_p, 212 - 213 - .mv_insb = microdev_insb, 214 - .mv_insw = microdev_insw, 215 - .mv_insl = microdev_insl, 216 - .mv_outsb = microdev_outsb, 217 - .mv_outsw = microdev_outsw, 218 - .mv_outsl = microdev_outsl, 219 - 198 + .mv_ioport_map = microdev_ioport_map, 220 199 .mv_init_irq = init_microdev_irq, 221 200 };
-9
arch/sh/include/mach-common/mach/microdev.h
··· 68 68 #define __IO_PREFIX microdev 69 69 #include <asm/io_generic.h> 70 70 71 - #if defined(CONFIG_PCI) 72 - unsigned char microdev_pci_inb(unsigned long port); 73 - unsigned short microdev_pci_inw(unsigned long port); 74 - unsigned long microdev_pci_inl(unsigned long port); 75 - void microdev_pci_outb(unsigned char data, unsigned long port); 76 - void microdev_pci_outw(unsigned short data, unsigned long port); 77 - void microdev_pci_outl(unsigned long data, unsigned long port); 78 - #endif 79 - 80 71 #endif /* __ASM_SH_MICRODEV_H */