Commit 37c8c642 authored by Thiemo Seufer's avatar Thiemo Seufer Committed by Ralf Baechle

IP22 EISA support update.

Signed-off-by: default avatarThiemo Seufer <ths@networkno.de>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 7623debf
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/mipsregs.h> #include <asm/mipsregs.h>
#include <asm/addrspace.h> #include <asm/addrspace.h>
...@@ -37,42 +38,29 @@ ...@@ -37,42 +38,29 @@
#include <asm/sgi/mc.h> #include <asm/sgi/mc.h>
#include <asm/sgi/ip22.h> #include <asm/sgi/ip22.h>
#define EISA_MAX_SLOTS 4 /* I2 has four EISA slots. */
#define IP22_EISA_MAX_SLOTS 4
#define EISA_MAX_IRQ 16 #define EISA_MAX_IRQ 16
#define EISA_TO_PHYS(x) (0x00080000 | (x)) #define EIU_MODE_REG 0x0001ffc0
#define EISA_TO_KSEG1(x) ((void *) KSEG1ADDR(EISA_TO_PHYS((x)))) #define EIU_STAT_REG 0x0001ffc4
#define EIU_PREMPT_REG 0x0001ffc8
#define EIU_MODE_REG 0x0009ffc0 #define EIU_QUIET_REG 0x0001ffcc
#define EIU_STAT_REG 0x0009ffc4 #define EIU_INTRPT_ACK 0x00010004
#define EIU_PREMPT_REG 0x0009ffc8
#define EIU_QUIET_REG 0x0009ffcc static char __init *decode_eisa_sig(unsigned long addr)
#define EIU_INTRPT_ACK 0x00090004
#define EISA_DMA1_STATUS 8
#define EISA_INT1_CTRL 0x20
#define EISA_INT1_MASK 0x21
#define EISA_INT2_CTRL 0xA0
#define EISA_INT2_MASK 0xA1
#define EISA_DMA2_STATUS 0xD0
#define EISA_DMA2_WRITE_SINGLE 0xD4
#define EISA_EXT_NMI_RESET_CTRL 0x461
#define EISA_INT1_EDGE_LEVEL 0x4D0
#define EISA_INT2_EDGE_LEVEL 0x4D1
#define EISA_VENDOR_ID_OFFSET 0xC80
#define EIU_WRITE_32(x,y) { *((u32 *) KSEG1ADDR(x)) = (u32) (y); mb(); }
#define EIU_READ_8(x) *((u8 *) KSEG1ADDR(x))
#define EISA_WRITE_8(x,y) { *((u8 *) EISA_TO_KSEG1(x)) = (u8) (y); mb(); }
#define EISA_READ_8(x) *((u8 *) EISA_TO_KSEG1(x))
static char *decode_eisa_sig(u8 * sig)
{ {
static char sig_str[8]; static char sig_str[EISA_SIG_LEN];
u16 rev; u8 sig[4];
u16 rev;
int i;
for (i = 0; i < 4; i++) {
sig[i] = inb (addr + i);
if (sig[0] & 0x80) if (!i && (sig[0] & 0x80))
return NULL; return NULL;
}
sig_str[0] = ((sig[0] >> 2) & 0x1f) + ('A' - 1); sig_str[0] = ((sig[0] >> 2) & 0x1f) + ('A' - 1);
sig_str[1] = (((sig[0] & 3) << 3) | (sig[1] >> 5)) + ('A' - 1); sig_str[1] = (((sig[0] & 3) << 3) | (sig[1] >> 5)) + ('A' - 1);
...@@ -83,23 +71,26 @@ static char *decode_eisa_sig(u8 * sig) ...@@ -83,23 +71,26 @@ static char *decode_eisa_sig(u8 * sig)
return sig_str; return sig_str;
} }
static void ip22_eisa_intr(int irq, void *dev_id, struct pt_regs *regs) static irqreturn_t ip22_eisa_intr(int irq, void *dev_id, struct pt_regs *regs)
{ {
u8 eisa_irq; u8 eisa_irq;
u8 dma1, dma2; u8 dma1, dma2;
eisa_irq = EIU_READ_8(EIU_INTRPT_ACK); eisa_irq = inb(EIU_INTRPT_ACK);
dma1 = EISA_READ_8(EISA_DMA1_STATUS); dma1 = inb(EISA_DMA1_STATUS);
dma2 = EISA_READ_8(EISA_DMA2_STATUS); dma2 = inb(EISA_DMA2_STATUS);
if (eisa_irq >= EISA_MAX_IRQ) {
/* Oops, Bad Stuff Happened... */
printk(KERN_ERR "eisa_irq %d out of bound\n", eisa_irq);
EISA_WRITE_8(EISA_INT2_CTRL, 0x20); if (eisa_irq < EISA_MAX_IRQ) {
EISA_WRITE_8(EISA_INT1_CTRL, 0x20);
} else
do_IRQ(eisa_irq, regs); do_IRQ(eisa_irq, regs);
return IRQ_HANDLED;
}
/* Oops, Bad Stuff Happened... */
printk(KERN_ERR "eisa_irq %d out of bound\n", eisa_irq);
outb(0x20, EISA_INT2_CTRL);
outb(0x20, EISA_INT1_CTRL);
return IRQ_NONE;
} }
static void enable_eisa1_irq(unsigned int irq) static void enable_eisa1_irq(unsigned int irq)
...@@ -109,9 +100,9 @@ static void enable_eisa1_irq(unsigned int irq) ...@@ -109,9 +100,9 @@ static void enable_eisa1_irq(unsigned int irq)
local_irq_save(flags); local_irq_save(flags);
mask = EISA_READ_8(EISA_INT1_MASK); mask = inb(EISA_INT1_MASK);
mask &= ~((u8) (1 << irq)); mask &= ~((u8) (1 << irq));
EISA_WRITE_8(EISA_INT1_MASK, mask); outb(mask, EISA_INT1_MASK);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -122,9 +113,9 @@ static unsigned int startup_eisa1_irq(unsigned int irq) ...@@ -122,9 +113,9 @@ static unsigned int startup_eisa1_irq(unsigned int irq)
/* Only use edge interrupts for EISA */ /* Only use edge interrupts for EISA */
edge = EISA_READ_8(EISA_INT1_EDGE_LEVEL); edge = inb(EISA_INT1_EDGE_LEVEL);
edge &= ~((u8) (1 << irq)); edge &= ~((u8) (1 << irq));
EISA_WRITE_8(EISA_INT1_EDGE_LEVEL, edge); outb(edge, EISA_INT1_EDGE_LEVEL);
enable_eisa1_irq(irq); enable_eisa1_irq(irq);
return 0; return 0;
...@@ -134,9 +125,9 @@ static void disable_eisa1_irq(unsigned int irq) ...@@ -134,9 +125,9 @@ static void disable_eisa1_irq(unsigned int irq)
{ {
u8 mask; u8 mask;
mask = EISA_READ_8(EISA_INT1_MASK); mask = inb(EISA_INT1_MASK);
mask |= ((u8) (1 << irq)); mask |= ((u8) (1 << irq));
EISA_WRITE_8(EISA_INT1_MASK, mask); outb(mask, EISA_INT1_MASK);
} }
#define shutdown_eisa1_irq disable_eisa1_irq #define shutdown_eisa1_irq disable_eisa1_irq
...@@ -145,7 +136,7 @@ static void mask_and_ack_eisa1_irq(unsigned int irq) ...@@ -145,7 +136,7 @@ static void mask_and_ack_eisa1_irq(unsigned int irq)
{ {
disable_eisa1_irq(irq); disable_eisa1_irq(irq);
EISA_WRITE_8(EISA_INT1_CTRL, 0x20); outb(0x20, EISA_INT1_CTRL);
} }
static void end_eisa1_irq(unsigned int irq) static void end_eisa1_irq(unsigned int irq)
...@@ -171,9 +162,9 @@ static void enable_eisa2_irq(unsigned int irq) ...@@ -171,9 +162,9 @@ static void enable_eisa2_irq(unsigned int irq)
local_irq_save(flags); local_irq_save(flags);
mask = EISA_READ_8(EISA_INT2_MASK); mask = inb(EISA_INT2_MASK);
mask &= ~((u8) (1 << (irq - 8))); mask &= ~((u8) (1 << (irq - 8)));
EISA_WRITE_8(EISA_INT2_MASK, mask); outb(mask, EISA_INT2_MASK);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -184,9 +175,9 @@ static unsigned int startup_eisa2_irq(unsigned int irq) ...@@ -184,9 +175,9 @@ static unsigned int startup_eisa2_irq(unsigned int irq)
/* Only use edge interrupts for EISA */ /* Only use edge interrupts for EISA */
edge = EISA_READ_8(EISA_INT2_EDGE_LEVEL); edge = inb(EISA_INT2_EDGE_LEVEL);
edge &= ~((u8) (1 << (irq - 8))); edge &= ~((u8) (1 << (irq - 8)));
EISA_WRITE_8(EISA_INT2_EDGE_LEVEL, edge); outb(edge, EISA_INT2_EDGE_LEVEL);
enable_eisa2_irq(irq); enable_eisa2_irq(irq);
return 0; return 0;
...@@ -196,9 +187,9 @@ static void disable_eisa2_irq(unsigned int irq) ...@@ -196,9 +187,9 @@ static void disable_eisa2_irq(unsigned int irq)
{ {
u8 mask; u8 mask;
mask = EISA_READ_8(EISA_INT2_MASK); mask = inb(EISA_INT2_MASK);
mask |= ((u8) (1 << (irq - 8))); mask |= ((u8) (1 << (irq - 8)));
EISA_WRITE_8(EISA_INT2_MASK, mask); outb(mask, EISA_INT2_MASK);
} }
#define shutdown_eisa2_irq disable_eisa2_irq #define shutdown_eisa2_irq disable_eisa2_irq
...@@ -207,8 +198,7 @@ static void mask_and_ack_eisa2_irq(unsigned int irq) ...@@ -207,8 +198,7 @@ static void mask_and_ack_eisa2_irq(unsigned int irq)
{ {
disable_eisa2_irq(irq); disable_eisa2_irq(irq);
EISA_WRITE_8(EISA_INT2_CTRL, 0x20); outb(0x20, EISA_INT2_CTRL);
EISA_WRITE_8(EISA_INT1_CTRL, 0x20);
} }
static void end_eisa2_irq(unsigned int irq) static void end_eisa2_irq(unsigned int irq)
...@@ -241,7 +231,6 @@ int __init ip22_eisa_init(void) ...@@ -241,7 +231,6 @@ int __init ip22_eisa_init(void)
{ {
int i, c; int i, c;
char *str; char *str;
u8 *slot_addr;
if (!(sgimc->systemid & SGIMC_SYSID_EPRESENT)) { if (!(sgimc->systemid & SGIMC_SYSID_EPRESENT)) {
printk(KERN_INFO "EISA: bus not present.\n"); printk(KERN_INFO "EISA: bus not present.\n");
...@@ -249,11 +238,8 @@ int __init ip22_eisa_init(void) ...@@ -249,11 +238,8 @@ int __init ip22_eisa_init(void)
} }
printk(KERN_INFO "EISA: Probing bus...\n"); printk(KERN_INFO "EISA: Probing bus...\n");
for (c = 0, i = 1; i <= EISA_MAX_SLOTS; i++) { for (c = 0, i = 1; i <= IP22_EISA_MAX_SLOTS; i++) {
slot_addr = if ((str = decode_eisa_sig(0x1000 * i + EISA_VENDOR_ID_OFFSET))) {
(u8 *) EISA_TO_KSEG1((0x1000 * i) +
EISA_VENDOR_ID_OFFSET);
if ((str = decode_eisa_sig(slot_addr))) {
printk(KERN_INFO "EISA: slot %d : %s detected.\n", printk(KERN_INFO "EISA: slot %d : %s detected.\n",
i, str); i, str);
c++; c++;
...@@ -268,25 +254,25 @@ int __init ip22_eisa_init(void) ...@@ -268,25 +254,25 @@ int __init ip22_eisa_init(void)
Please wave your favorite dead chicken over the busses */ Please wave your favorite dead chicken over the busses */
/* First say hello to the EIU */ /* First say hello to the EIU */
EIU_WRITE_32(EIU_PREMPT_REG, 0x0000FFFF); outl(0x0000FFFF, EIU_PREMPT_REG);
EIU_WRITE_32(EIU_QUIET_REG, 1); outl(1, EIU_QUIET_REG);
EIU_WRITE_32(EIU_MODE_REG, 0x40f3c07F); outl(0x40f3c07F, EIU_MODE_REG);
/* Now be nice to the EISA chipset */ /* Now be nice to the EISA chipset */
EISA_WRITE_8(EISA_EXT_NMI_RESET_CTRL, 1); outb(1, EISA_EXT_NMI_RESET_CTRL);
for (i = 0; i < 10000; i++); /* Wait long enough for the dust to settle */ udelay(50); /* Wait long enough for the dust to settle */
EISA_WRITE_8(EISA_EXT_NMI_RESET_CTRL, 0); outb(0, EISA_EXT_NMI_RESET_CTRL);
EISA_WRITE_8(EISA_INT1_CTRL, 0x11); outb(0x11, EISA_INT1_CTRL);
EISA_WRITE_8(EISA_INT2_CTRL, 0x11); outb(0x11, EISA_INT2_CTRL);
EISA_WRITE_8(EISA_INT1_MASK, 0); outb(0, EISA_INT1_MASK);
EISA_WRITE_8(EISA_INT2_MASK, 8); outb(8, EISA_INT2_MASK);
EISA_WRITE_8(EISA_INT1_MASK, 4); outb(4, EISA_INT1_MASK);
EISA_WRITE_8(EISA_INT2_MASK, 2); outb(2, EISA_INT2_MASK);
EISA_WRITE_8(EISA_INT1_MASK, 1); outb(1, EISA_INT1_MASK);
EISA_WRITE_8(EISA_INT2_MASK, 1); outb(1, EISA_INT2_MASK);
EISA_WRITE_8(EISA_INT1_MASK, 0xfb); outb(0xfb, EISA_INT1_MASK);
EISA_WRITE_8(EISA_INT2_MASK, 0xff); outb(0xff, EISA_INT2_MASK);
EISA_WRITE_8(EISA_DMA2_WRITE_SINGLE, 0); outb(0, EISA_DMA2_WRITE_SINGLE);
for (i = SGINT_EISA; i < (SGINT_EISA + EISA_MAX_IRQ); i++) { for (i = SGINT_EISA; i < (SGINT_EISA + EISA_MAX_IRQ); i++) {
irq_desc[i].status = IRQ_DISABLED; irq_desc[i].status = IRQ_DISABLED;
......
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