[PATCH] m32r: M3A-2170(Mappi-III) IDE support

This patch is for supporting IDE interface for M3A-2170(Mappi-III) board.

Signed-off-by: Mamoru Sakugawa <sakugawa@linux-m32r.org>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Hirokazu Takata and committed by
Linus Torvalds
ad09d583 0332db5a

+59 -33
+37 -17
arch/m32r/kernel/io_mappi3.c
··· 36 return (void *)(port + NONCACHE_OFFSET); 37 } 38 39 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 40 static inline void *__port2addr_ata(unsigned long port) 41 { 42 static int dummy_reg; 43 44 switch (port) { 45 case 0x1f0: return (void *)0xb4002000; 46 case 0x1f1: return (void *)0xb4012800; 47 case 0x1f2: return (void *)0xb4012002; ··· 52 case 0x1f6: return (void *)0xb4012006; 53 case 0x1f7: return (void *)0xb4012806; 54 case 0x3f6: return (void *)0xb401200e; 55 default: return (void *)&dummy_reg; 56 } 57 } ··· 120 { 121 if (port >= LAN_IOSTART && port < LAN_IOEND) 122 return _ne_inb(PORT2ADDR_NE(port)); 123 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 124 - else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 125 return *(volatile unsigned char *)__port2addr_ata(port); 126 } 127 #endif ··· 140 { 141 if (port >= LAN_IOSTART && port < LAN_IOEND) 142 return _ne_inw(PORT2ADDR_NE(port)); 143 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 144 - else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 145 return *(volatile unsigned short *)__port2addr_ata(port); 146 } 147 #endif ··· 199 if (port >= LAN_IOSTART && port < LAN_IOEND) 200 _ne_outb(b, PORT2ADDR_NE(port)); 201 else 202 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 203 - if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 204 *(volatile unsigned char *)__port2addr_ata(port) = b; 205 } else 206 #endif ··· 218 if (port >= LAN_IOSTART && port < LAN_IOEND) 219 _ne_outw(w, PORT2ADDR_NE(port)); 220 else 221 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 222 - if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 223 *(volatile unsigned short *)__port2addr_ata(port) = w; 224 } else 225 #endif ··· 269 { 270 if (port >= LAN_IOSTART && port < LAN_IOEND) 271 _ne_insb(PORT2ADDR_NE(port), addr, count); 272 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 273 - else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 274 unsigned char *buf = addr; 275 unsigned char *portp = __port2addr_ata(port); 276 while (count--) ··· 306 pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), 307 count, 1); 308 #endif 309 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 310 - } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 311 portp = __port2addr_ata(port); 312 while (count--) 313 *buf++ = *(volatile unsigned short *)portp; ··· 339 portp = PORT2ADDR_NE(port); 340 while (count--) 341 _ne_outb(*buf++, portp); 342 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 343 - } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 344 portp = __port2addr_ata(port); 345 while (count--) 346 *(volatile unsigned char *)portp = *buf++; ··· 367 portp = PORT2ADDR_NE(port); 368 while (count--) 369 *(volatile unsigned short *)portp = *buf++; 370 - #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) 371 - } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { 372 portp = __port2addr_ata(port); 373 while (count--) 374 *(volatile unsigned short *)portp = *buf++;
··· 36 return (void *)(port + NONCACHE_OFFSET); 37 } 38 39 + #if defined(CONFIG_IDE) 40 static inline void *__port2addr_ata(unsigned long port) 41 { 42 static int dummy_reg; 43 44 switch (port) { 45 + /* IDE0 CF */ 46 case 0x1f0: return (void *)0xb4002000; 47 case 0x1f1: return (void *)0xb4012800; 48 case 0x1f2: return (void *)0xb4012002; ··· 51 case 0x1f6: return (void *)0xb4012006; 52 case 0x1f7: return (void *)0xb4012806; 53 case 0x3f6: return (void *)0xb401200e; 54 + /* IDE1 IDE */ 55 + case 0x170: return (void *)0xb4810000; /* Data 16bit */ 56 + case 0x171: return (void *)0xb4810002; /* Features / Error */ 57 + case 0x172: return (void *)0xb4810004; /* Sector count */ 58 + case 0x173: return (void *)0xb4810006; /* Sector number */ 59 + case 0x174: return (void *)0xb4810008; /* Cylinder low */ 60 + case 0x175: return (void *)0xb481000a; /* Cylinder high */ 61 + case 0x176: return (void *)0xb481000c; /* Device head */ 62 + case 0x177: return (void *)0xb481000e; /* Command */ 63 + case 0x376: return (void *)0xb480800c; /* Device control / Alt status */ 64 + 65 default: return (void *)&dummy_reg; 66 } 67 } ··· 108 { 109 if (port >= LAN_IOSTART && port < LAN_IOEND) 110 return _ne_inb(PORT2ADDR_NE(port)); 111 + #if defined(CONFIG_IDE) 112 + else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 113 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 114 return *(volatile unsigned char *)__port2addr_ata(port); 115 } 116 #endif ··· 127 { 128 if (port >= LAN_IOSTART && port < LAN_IOEND) 129 return _ne_inw(PORT2ADDR_NE(port)); 130 + #if defined(CONFIG_IDE) 131 + else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 132 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 133 return *(volatile unsigned short *)__port2addr_ata(port); 134 } 135 #endif ··· 185 if (port >= LAN_IOSTART && port < LAN_IOEND) 186 _ne_outb(b, PORT2ADDR_NE(port)); 187 else 188 + #if defined(CONFIG_IDE) 189 + if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 190 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 191 *(volatile unsigned char *)__port2addr_ata(port) = b; 192 } else 193 #endif ··· 203 if (port >= LAN_IOSTART && port < LAN_IOEND) 204 _ne_outw(w, PORT2ADDR_NE(port)); 205 else 206 + #if defined(CONFIG_IDE) 207 + if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 208 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 209 *(volatile unsigned short *)__port2addr_ata(port) = w; 210 } else 211 #endif ··· 253 { 254 if (port >= LAN_IOSTART && port < LAN_IOEND) 255 _ne_insb(PORT2ADDR_NE(port), addr, count); 256 + #if defined(CONFIG_IDE) 257 + else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 258 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 259 unsigned char *buf = addr; 260 unsigned char *portp = __port2addr_ata(port); 261 while (count--) ··· 289 pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), 290 count, 1); 291 #endif 292 + #if defined(CONFIG_IDE) 293 + } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 294 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 295 portp = __port2addr_ata(port); 296 while (count--) 297 *buf++ = *(volatile unsigned short *)portp; ··· 321 portp = PORT2ADDR_NE(port); 322 while (count--) 323 _ne_outb(*buf++, portp); 324 + #if defined(CONFIG_IDE) 325 + } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 326 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 327 portp = __port2addr_ata(port); 328 while (count--) 329 *(volatile unsigned char *)portp = *buf++; ··· 348 portp = PORT2ADDR_NE(port); 349 while (count--) 350 *(volatile unsigned short *)portp = *buf++; 351 + #if defined(CONFIG_IDE) 352 + } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || 353 + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ 354 portp = __port2addr_ata(port); 355 while (count--) 356 *(volatile unsigned short *)portp = *buf++;
+11 -9
arch/m32r/kernel/setup_mappi3.c
··· 151 disable_mappi3_irq(M32R_IRQ_INT1); 152 #endif /* CONFIG_USB */ 153 154 - /* ICUCR40: CFC IREQ */ 155 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; 156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type; 157 irq_desc[PLD_IRQ_CFIREQ].action = 0; ··· 160 disable_mappi3_irq(PLD_IRQ_CFIREQ); 161 162 #if defined(CONFIG_M32R_CFC) 163 - /* ICUCR41: CFC Insert */ 164 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; 165 irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type; 166 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; ··· 168 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; 169 disable_mappi3_irq(PLD_IRQ_CFC_INSERT); 170 171 - /* ICUCR42: CFC Eject */ 172 - irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; 173 - irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi3_irq_type; 174 - irq_desc[PLD_IRQ_CFC_EJECT].action = 0; 175 - irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ 176 - icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 177 - disable_mappi3_irq(PLD_IRQ_CFC_EJECT); 178 #endif /* CONFIG_M32R_CFC */ 179 } 180 181 #if defined(CONFIG_SMC91X)
··· 151 disable_mappi3_irq(M32R_IRQ_INT1); 152 #endif /* CONFIG_USB */ 153 154 + /* CFC IREQ */ 155 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; 156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type; 157 irq_desc[PLD_IRQ_CFIREQ].action = 0; ··· 160 disable_mappi3_irq(PLD_IRQ_CFIREQ); 161 162 #if defined(CONFIG_M32R_CFC) 163 + /* ICUCR41: CFC Insert & eject */ 164 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; 165 irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type; 166 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; ··· 168 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; 169 disable_mappi3_irq(PLD_IRQ_CFC_INSERT); 170 171 #endif /* CONFIG_M32R_CFC */ 172 + 173 + /* IDE IREQ */ 174 + irq_desc[PLD_IRQ_IDEIREQ].status = IRQ_DISABLED; 175 + irq_desc[PLD_IRQ_IDEIREQ].handler = &mappi3_irq_type; 176 + irq_desc[PLD_IRQ_IDEIREQ].action = 0; 177 + irq_desc[PLD_IRQ_IDEIREQ].depth = 1; /* disable nested irq */ 178 + icu_data[PLD_IRQ_IDEIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 179 + disable_mappi3_irq(PLD_IRQ_IDEIREQ); 180 + 181 } 182 183 #if defined(CONFIG_SMC91X)
+2 -1
drivers/pcmcia/m32r_cfc.c
··· 355 #ifndef CONFIG_PLAT_USRV 356 /* insert interrupt */ 357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 358 /* eject interrupt */ 359 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 360 - 361 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); 362 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); 363 #endif /* CONFIG_PLAT_USRV */
··· 355 #ifndef CONFIG_PLAT_USRV 356 /* insert interrupt */ 357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 358 + #ifndef CONFIG_PLAT_MAPPI3 359 /* eject interrupt */ 360 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 361 + #endif 362 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); 363 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); 364 #endif /* CONFIG_PLAT_USRV */
+8 -5
include/asm-m32r/ide.h
··· 25 # endif 26 #endif 27 28 - #if defined(CONFIG_PLAT_M32700UT) 29 - #include <asm/irq.h> 30 - #include <asm/m32700ut/m32700ut_pld.h> 31 - #endif 32 33 #define IDE_ARCH_OBSOLETE_DEFAULTS 34 35 static __inline__ int ide_default_irq(unsigned long base) 36 { 37 switch (base) { 38 - #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3) 39 case 0x1f0: return PLD_IRQ_CFIREQ; 40 default: 41 return 0; 42 #else
··· 25 # endif 26 #endif 27 28 + #include <asm/m32r.h> 29 + 30 31 #define IDE_ARCH_OBSOLETE_DEFAULTS 32 33 static __inline__ int ide_default_irq(unsigned long base) 34 { 35 switch (base) { 36 + #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) 37 case 0x1f0: return PLD_IRQ_CFIREQ; 38 + default: 39 + return 0; 40 + #elif defined(CONFIG_PLAT_MAPPI3) 41 + case 0x1f0: return PLD_IRQ_CFIREQ; 42 + case 0x170: return PLD_IRQ_IDEIREQ; 43 default: 44 return 0; 45 #else
+1 -1
include/asm-m32r/mappi3/mappi3_pld.h
··· 59 #define M32R_IRQ_I2C (28) /* I2C-BUS */ 60 #define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */ 61 #define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert */ 62 - #define PLD_IRQ_CFC_EJECT (8) /* INT7 CFC Card Eject */ 63 #define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */ 64 #define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */ 65
··· 59 #define M32R_IRQ_I2C (28) /* I2C-BUS */ 60 #define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */ 61 #define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert */ 62 + #define PLD_IRQ_IDEIREQ (8) /* INT7 IDE Interrupt */ 63 #define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */ 64 #define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */ 65