Skip to content

Commit

Permalink
[PATCH] m32r: M3A-2170(Mappi-III) IDE support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
htakata authored and Linus Torvalds committed Nov 28, 2005
1 parent 0332db5 commit ad09d58
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 33 deletions.
54 changes: 37 additions & 17 deletions arch/m32r/kernel/io_mappi3.c
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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--)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand All @@ -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++;
Expand Down
20 changes: 11 additions & 9 deletions arch/m32r/kernel/setup_mappi3.c
Expand Up @@ -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;
Expand All @@ -160,22 +160,24 @@ 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;
irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
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)
Expand Down
3 changes: 2 additions & 1 deletion drivers/pcmcia/m32r_cfc.c
Expand Up @@ -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 */
Expand Down
13 changes: 8 additions & 5 deletions include/asm-m32r/ide.h
Expand Up @@ -25,18 +25,21 @@
# endif
#endif

#if defined(CONFIG_PLAT_M32700UT)
#include <asm/irq.h>
#include <asm/m32700ut/m32700ut_pld.h>
#endif
#include <asm/m32r.h>


#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
Expand Down
2 changes: 1 addition & 1 deletion include/asm-m32r/mappi3/mappi3_pld.h
Expand Up @@ -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 */

Expand Down

0 comments on commit ad09d58

Please sign in to comment.