From: Hirokazu Takata Date: Mon, 28 Nov 2005 21:44:00 +0000 (-0800) Subject: [PATCH] m32r: M3A-2170(Mappi-III) IDE support X-Git-Tag: v3.12-rc1~40104^2~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad09d583106fadfdf751926107cfe35fba6bdbd4;p=kernel%2Fkernel-generic.git [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 Signed-off-by: Hirokazu Takata Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/m32r/kernel/io_mappi3.c b/arch/m32r/kernel/io_mappi3.c index 6716ffe..f80321a 100644 --- a/arch/m32r/kernel/io_mappi3.c +++ b/arch/m32r/kernel/io_mappi3.c @@ -36,12 +36,13 @@ static inline void *_port2addr(unsigned long port) return (void *)(port + NONCACHE_OFFSET); } -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) +#if defined(CONFIG_IDE) static inline void *__port2addr_ata(unsigned long port) { static int dummy_reg; switch (port) { + /* IDE0 CF */ case 0x1f0: return (void *)0xb4002000; case 0x1f1: return (void *)0xb4012800; case 0x1f2: return (void *)0xb4012002; @@ -51,6 +52,17 @@ static inline void *__port2addr_ata(unsigned long port) case 0x1f6: return (void *)0xb4012006; case 0x1f7: return (void *)0xb4012806; case 0x3f6: return (void *)0xb401200e; + /* IDE1 IDE */ + case 0x170: return (void *)0xb4810000; /* Data 16bit */ + case 0x171: return (void *)0xb4810002; /* Features / Error */ + case 0x172: return (void *)0xb4810004; /* Sector count */ + case 0x173: return (void *)0xb4810006; /* Sector number */ + case 0x174: return (void *)0xb4810008; /* Cylinder low */ + case 0x175: return (void *)0xb481000a; /* Cylinder high */ + case 0x176: return (void *)0xb481000c; /* Device head */ + case 0x177: return (void *)0xb481000e; /* Command */ + case 0x376: return (void *)0xb480800c; /* Device control / Alt status */ + default: return (void *)&dummy_reg; } } @@ -108,8 +120,9 @@ unsigned char _inb(unsigned long port) { if (port >= LAN_IOSTART && port < LAN_IOEND) return _ne_inb(PORT2ADDR_NE(port)); -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ return *(volatile unsigned char *)__port2addr_ata(port); } #endif @@ -127,8 +140,9 @@ unsigned short _inw(unsigned long port) { if (port >= LAN_IOSTART && port < LAN_IOEND) return _ne_inw(PORT2ADDR_NE(port)); -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ return *(volatile unsigned short *)__port2addr_ata(port); } #endif @@ -185,8 +199,9 @@ void _outb(unsigned char b, unsigned long port) if (port >= LAN_IOSTART && port < LAN_IOEND) _ne_outb(b, PORT2ADDR_NE(port)); else -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ *(volatile unsigned char *)__port2addr_ata(port) = b; } else #endif @@ -203,8 +218,9 @@ void _outw(unsigned short w, unsigned long port) if (port >= LAN_IOSTART && port < LAN_IOEND) _ne_outw(w, PORT2ADDR_NE(port)); else -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ *(volatile unsigned short *)__port2addr_ata(port) = w; } else #endif @@ -253,8 +269,9 @@ void _insb(unsigned int port, void * addr, unsigned long count) { if (port >= LAN_IOSTART && port < LAN_IOEND) _ne_insb(PORT2ADDR_NE(port), addr, count); -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ unsigned char *buf = addr; unsigned char *portp = __port2addr_ata(port); while (count--) @@ -289,8 +306,9 @@ void _insw(unsigned int port, void * addr, unsigned long count) pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), count, 1); #endif -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ portp = __port2addr_ata(port); while (count--) *buf++ = *(volatile unsigned short *)portp; @@ -321,8 +339,9 @@ void _outsb(unsigned int port, const void * addr, unsigned long count) portp = PORT2ADDR_NE(port); while (count--) _ne_outb(*buf++, portp); -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ portp = __port2addr_ata(port); while (count--) *(volatile unsigned char *)portp = *buf++; @@ -348,8 +367,9 @@ void _outsw(unsigned int port, const void * addr, unsigned long count) portp = PORT2ADDR_NE(port); while (count--) *(volatile unsigned short *)portp = *buf++; -#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) - } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { +#if defined(CONFIG_IDE) + } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) || + ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){ portp = __port2addr_ata(port); while (count--) *(volatile unsigned short *)portp = *buf++; diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c index 9c79341..f6ecdf7 100644 --- a/arch/m32r/kernel/setup_mappi3.c +++ b/arch/m32r/kernel/setup_mappi3.c @@ -151,7 +151,7 @@ void __init init_IRQ(void) disable_mappi3_irq(M32R_IRQ_INT1); #endif /* CONFIG_USB */ - /* ICUCR40: CFC IREQ */ + /* CFC IREQ */ irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type; irq_desc[PLD_IRQ_CFIREQ].action = 0; @@ -160,7 +160,7 @@ void __init init_IRQ(void) disable_mappi3_irq(PLD_IRQ_CFIREQ); #if defined(CONFIG_M32R_CFC) - /* ICUCR41: CFC Insert */ + /* ICUCR41: CFC Insert & eject */ irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type; irq_desc[PLD_IRQ_CFC_INSERT].action = 0; @@ -168,14 +168,16 @@ void __init init_IRQ(void) icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; disable_mappi3_irq(PLD_IRQ_CFC_INSERT); - /* ICUCR42: CFC Eject */ - irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi3_irq_type; - irq_desc[PLD_IRQ_CFC_EJECT].action = 0; - irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ - icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; - disable_mappi3_irq(PLD_IRQ_CFC_EJECT); #endif /* CONFIG_M32R_CFC */ + + /* IDE IREQ */ + irq_desc[PLD_IRQ_IDEIREQ].status = IRQ_DISABLED; + irq_desc[PLD_IRQ_IDEIREQ].handler = &mappi3_irq_type; + irq_desc[PLD_IRQ_IDEIREQ].action = 0; + irq_desc[PLD_IRQ_IDEIREQ].depth = 1; /* disable nested irq */ + icu_data[PLD_IRQ_IDEIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; + disable_mappi3_irq(PLD_IRQ_IDEIREQ); + } #if defined(CONFIG_SMC91X) diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index 2c22b4b..078579a 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c @@ -355,9 +355,10 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, kio_addr_t ioaddr #ifndef CONFIG_PLAT_USRV /* insert interrupt */ request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); +#ifndef CONFIG_PLAT_MAPPI3 /* eject interrupt */ request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); - +#endif debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); #endif /* CONFIG_PLAT_USRV */ diff --git a/include/asm-m32r/ide.h b/include/asm-m32r/ide.h index 194393b..f7aa969 100644 --- a/include/asm-m32r/ide.h +++ b/include/asm-m32r/ide.h @@ -25,18 +25,21 @@ # endif #endif -#if defined(CONFIG_PLAT_M32700UT) -#include -#include -#endif +#include + #define IDE_ARCH_OBSOLETE_DEFAULTS static __inline__ int ide_default_irq(unsigned long base) { switch (base) { -#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3) +#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) + case 0x1f0: return PLD_IRQ_CFIREQ; + default: + return 0; +#elif defined(CONFIG_PLAT_MAPPI3) case 0x1f0: return PLD_IRQ_CFIREQ; + case 0x170: return PLD_IRQ_IDEIREQ; default: return 0; #else diff --git a/include/asm-m32r/mappi3/mappi3_pld.h b/include/asm-m32r/mappi3/mappi3_pld.h index 3f1551f..1d3c25d 100644 --- a/include/asm-m32r/mappi3/mappi3_pld.h +++ b/include/asm-m32r/mappi3/mappi3_pld.h @@ -59,7 +59,7 @@ #define M32R_IRQ_I2C (28) /* I2C-BUS */ #define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */ #define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert */ -#define PLD_IRQ_CFC_EJECT (8) /* INT7 CFC Card Eject */ +#define PLD_IRQ_IDEIREQ (8) /* INT7 IDE Interrupt */ #define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */ #define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */