Commit ad09d583 authored by Hirokazu Takata's avatar Hirokazu Takata Committed by Linus Torvalds

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

This patch is for supporting IDE interface for M3A-2170(Mappi-III) board.
Signed-off-by: default avatarMamoru Sakugawa <sakugawa@linux-m32r.org>
Signed-off-by: default avatarHirokazu Takata <takata@linux-m32r.org>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0332db5a
...@@ -36,12 +36,13 @@ static inline void *_port2addr(unsigned long port) ...@@ -36,12 +36,13 @@ static inline void *_port2addr(unsigned long port)
return (void *)(port + NONCACHE_OFFSET); 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 inline void *__port2addr_ata(unsigned long port)
{ {
static int dummy_reg; static int dummy_reg;
switch (port) { switch (port) {
/* IDE0 CF */
case 0x1f0: return (void *)0xb4002000; case 0x1f0: return (void *)0xb4002000;
case 0x1f1: return (void *)0xb4012800; case 0x1f1: return (void *)0xb4012800;
case 0x1f2: return (void *)0xb4012002; case 0x1f2: return (void *)0xb4012002;
...@@ -51,6 +52,17 @@ static inline void *__port2addr_ata(unsigned long port) ...@@ -51,6 +52,17 @@ static inline void *__port2addr_ata(unsigned long port)
case 0x1f6: return (void *)0xb4012006; case 0x1f6: return (void *)0xb4012006;
case 0x1f7: return (void *)0xb4012806; case 0x1f7: return (void *)0xb4012806;
case 0x3f6: return (void *)0xb401200e; 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; default: return (void *)&dummy_reg;
} }
} }
...@@ -108,8 +120,9 @@ unsigned char _inb(unsigned long port) ...@@ -108,8 +120,9 @@ unsigned char _inb(unsigned long port)
{ {
if (port >= LAN_IOSTART && port < LAN_IOEND) if (port >= LAN_IOSTART && port < LAN_IOEND)
return _ne_inb(PORT2ADDR_NE(port)); return _ne_inb(PORT2ADDR_NE(port));
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
return *(volatile unsigned char *)__port2addr_ata(port); return *(volatile unsigned char *)__port2addr_ata(port);
} }
#endif #endif
...@@ -127,8 +140,9 @@ unsigned short _inw(unsigned long port) ...@@ -127,8 +140,9 @@ unsigned short _inw(unsigned long port)
{ {
if (port >= LAN_IOSTART && port < LAN_IOEND) if (port >= LAN_IOSTART && port < LAN_IOEND)
return _ne_inw(PORT2ADDR_NE(port)); return _ne_inw(PORT2ADDR_NE(port));
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
return *(volatile unsigned short *)__port2addr_ata(port); return *(volatile unsigned short *)__port2addr_ata(port);
} }
#endif #endif
...@@ -185,8 +199,9 @@ void _outb(unsigned char b, unsigned long port) ...@@ -185,8 +199,9 @@ void _outb(unsigned char b, unsigned long port)
if (port >= LAN_IOSTART && port < LAN_IOEND) if (port >= LAN_IOSTART && port < LAN_IOEND)
_ne_outb(b, PORT2ADDR_NE(port)); _ne_outb(b, PORT2ADDR_NE(port));
else else
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
*(volatile unsigned char *)__port2addr_ata(port) = b; *(volatile unsigned char *)__port2addr_ata(port) = b;
} else } else
#endif #endif
...@@ -203,8 +218,9 @@ void _outw(unsigned short w, unsigned long port) ...@@ -203,8 +218,9 @@ void _outw(unsigned short w, unsigned long port)
if (port >= LAN_IOSTART && port < LAN_IOEND) if (port >= LAN_IOSTART && port < LAN_IOEND)
_ne_outw(w, PORT2ADDR_NE(port)); _ne_outw(w, PORT2ADDR_NE(port));
else else
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
*(volatile unsigned short *)__port2addr_ata(port) = w; *(volatile unsigned short *)__port2addr_ata(port) = w;
} else } else
#endif #endif
...@@ -253,8 +269,9 @@ void _insb(unsigned int port, void * addr, unsigned long count) ...@@ -253,8 +269,9 @@ void _insb(unsigned int port, void * addr, unsigned long count)
{ {
if (port >= LAN_IOSTART && port < LAN_IOEND) if (port >= LAN_IOSTART && port < LAN_IOEND)
_ne_insb(PORT2ADDR_NE(port), addr, count); _ne_insb(PORT2ADDR_NE(port), addr, count);
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
unsigned char *buf = addr; unsigned char *buf = addr;
unsigned char *portp = __port2addr_ata(port); unsigned char *portp = __port2addr_ata(port);
while (count--) while (count--)
...@@ -289,8 +306,9 @@ void _insw(unsigned int port, void * addr, unsigned long 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), pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short),
count, 1); count, 1);
#endif #endif
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
portp = __port2addr_ata(port); portp = __port2addr_ata(port);
while (count--) while (count--)
*buf++ = *(volatile unsigned short *)portp; *buf++ = *(volatile unsigned short *)portp;
...@@ -321,8 +339,9 @@ void _outsb(unsigned int port, const void * addr, unsigned long count) ...@@ -321,8 +339,9 @@ void _outsb(unsigned int port, const void * addr, unsigned long count)
portp = PORT2ADDR_NE(port); portp = PORT2ADDR_NE(port);
while (count--) while (count--)
_ne_outb(*buf++, portp); _ne_outb(*buf++, portp);
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
portp = __port2addr_ata(port); portp = __port2addr_ata(port);
while (count--) while (count--)
*(volatile unsigned char *)portp = *buf++; *(volatile unsigned char *)portp = *buf++;
...@@ -348,8 +367,9 @@ void _outsw(unsigned int port, const void * addr, unsigned long count) ...@@ -348,8 +367,9 @@ void _outsw(unsigned int port, const void * addr, unsigned long count)
portp = PORT2ADDR_NE(port); portp = PORT2ADDR_NE(port);
while (count--) while (count--)
*(volatile unsigned short *)portp = *buf++; *(volatile unsigned short *)portp = *buf++;
#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) #if defined(CONFIG_IDE)
} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { } else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
portp = __port2addr_ata(port); portp = __port2addr_ata(port);
while (count--) while (count--)
*(volatile unsigned short *)portp = *buf++; *(volatile unsigned short *)portp = *buf++;
......
...@@ -151,7 +151,7 @@ void __init init_IRQ(void) ...@@ -151,7 +151,7 @@ void __init init_IRQ(void)
disable_mappi3_irq(M32R_IRQ_INT1); disable_mappi3_irq(M32R_IRQ_INT1);
#endif /* CONFIG_USB */ #endif /* CONFIG_USB */
/* ICUCR40: CFC IREQ */ /* CFC IREQ */
irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type; irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type;
irq_desc[PLD_IRQ_CFIREQ].action = 0; irq_desc[PLD_IRQ_CFIREQ].action = 0;
...@@ -160,7 +160,7 @@ void __init init_IRQ(void) ...@@ -160,7 +160,7 @@ void __init init_IRQ(void)
disable_mappi3_irq(PLD_IRQ_CFIREQ); disable_mappi3_irq(PLD_IRQ_CFIREQ);
#if defined(CONFIG_M32R_CFC) #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].status = IRQ_DISABLED;
irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type; irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type;
irq_desc[PLD_IRQ_CFC_INSERT].action = 0; irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
...@@ -168,14 +168,16 @@ void __init init_IRQ(void) ...@@ -168,14 +168,16 @@ void __init init_IRQ(void)
icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
disable_mappi3_irq(PLD_IRQ_CFC_INSERT); 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 */ #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) #if defined(CONFIG_SMC91X)
......
...@@ -355,9 +355,10 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, kio_addr_t ioaddr ...@@ -355,9 +355,10 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, kio_addr_t ioaddr
#ifndef CONFIG_PLAT_USRV #ifndef CONFIG_PLAT_USRV
/* insert interrupt */ /* insert interrupt */
request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
#ifndef CONFIG_PLAT_MAPPI3
/* eject interrupt */ /* eject interrupt */
request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
#endif
debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n");
pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01);
#endif /* CONFIG_PLAT_USRV */ #endif /* CONFIG_PLAT_USRV */
......
...@@ -25,18 +25,21 @@ ...@@ -25,18 +25,21 @@
# endif # endif
#endif #endif
#if defined(CONFIG_PLAT_M32700UT) #include <asm/m32r.h>
#include <asm/irq.h>
#include <asm/m32700ut/m32700ut_pld.h>
#endif
#define IDE_ARCH_OBSOLETE_DEFAULTS #define IDE_ARCH_OBSOLETE_DEFAULTS
static __inline__ int ide_default_irq(unsigned long base) static __inline__ int ide_default_irq(unsigned long base)
{ {
switch (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 0x1f0: return PLD_IRQ_CFIREQ;
case 0x170: return PLD_IRQ_IDEIREQ;
default: default:
return 0; return 0;
#else #else
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#define M32R_IRQ_I2C (28) /* I2C-BUS */ #define M32R_IRQ_I2C (28) /* I2C-BUS */
#define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */ #define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */
#define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert */ #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_MMCCARD (43) /* MMC Card Insert */
#define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */ #define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment