Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Basic EISA bus support for the SGI Indigo-2.
0003  *
0004  * (C) 2002 Pascal Dameme <netinet@freesurf.fr>
0005  *  and Marc Zyngier <mzyngier@freesurf.fr>
0006  *
0007  * This code is released under both the GPL version 2 and BSD
0008  * licenses.  Either license may be used.
0009  *
0010  * This code offers a very basic support for this EISA bus present in
0011  * the SGI Indigo-2. It currently only supports PIO (forget about DMA
0012  * for the time being). This is enough for a low-end ethernet card,
0013  * but forget about your favorite SCSI card...
0014  *
0015  * TODO :
0016  * - Fix bugs...
0017  * - Add ISA support
0018  * - Add DMA (yeah, right...).
0019  * - Fix more bugs.
0020  */
0021 
0022 #include <linux/eisa.h>
0023 #include <linux/types.h>
0024 #include <linux/init.h>
0025 #include <linux/irq.h>
0026 #include <linux/kernel_stat.h>
0027 #include <linux/signal.h>
0028 #include <linux/sched.h>
0029 #include <linux/interrupt.h>
0030 #include <linux/delay.h>
0031 #include <asm/io.h>
0032 #include <asm/irq.h>
0033 #include <asm/mipsregs.h>
0034 #include <asm/addrspace.h>
0035 #include <asm/processor.h>
0036 #include <asm/sgi/ioc.h>
0037 #include <asm/sgi/mc.h>
0038 #include <asm/sgi/ip22.h>
0039 #include <asm/i8259.h>
0040 
0041 /* I2 has four EISA slots. */
0042 #define IP22_EISA_MAX_SLOTS   4
0043 #define EISA_MAX_IRQ         16
0044 
0045 #define EIU_MODE_REG     0x0001ffc0
0046 #define EIU_STAT_REG     0x0001ffc4
0047 #define EIU_PREMPT_REG   0x0001ffc8
0048 #define EIU_QUIET_REG    0x0001ffcc
0049 #define EIU_INTRPT_ACK   0x00010004
0050 
0051 static char __init *decode_eisa_sig(unsigned long addr)
0052 {
0053     static char sig_str[EISA_SIG_LEN] __initdata;
0054     u8 sig[4];
0055     u16 rev;
0056     int i;
0057 
0058     for (i = 0; i < 4; i++) {
0059         sig[i] = inb(addr + i);
0060 
0061         if (!i && (sig[0] & 0x80))
0062             return NULL;
0063     }
0064 
0065     sig_str[0] = ((sig[0] >> 2) & 0x1f) + ('A' - 1);
0066     sig_str[1] = (((sig[0] & 3) << 3) | (sig[1] >> 5)) + ('A' - 1);
0067     sig_str[2] = (sig[1] & 0x1f) + ('A' - 1);
0068     rev = (sig[2] << 8) | sig[3];
0069     sprintf(sig_str + 3, "%04X", rev);
0070 
0071     return sig_str;
0072 }
0073 
0074 static irqreturn_t ip22_eisa_intr(int irq, void *dev_id)
0075 {
0076     u8 eisa_irq = inb(EIU_INTRPT_ACK);
0077 
0078     inb(EISA_DMA1_STATUS);
0079     inb(EISA_DMA2_STATUS);
0080 
0081     if (eisa_irq < EISA_MAX_IRQ) {
0082         do_IRQ(eisa_irq);
0083         return IRQ_HANDLED;
0084     }
0085 
0086     /* Oops, Bad Stuff Happened... */
0087     printk(KERN_ERR "eisa_irq %d out of bound\n", eisa_irq);
0088 
0089     outb(0x20, EISA_INT2_CTRL);
0090     outb(0x20, EISA_INT1_CTRL);
0091 
0092     return IRQ_NONE;
0093 }
0094 
0095 int __init ip22_eisa_init(void)
0096 {
0097     int i, c;
0098     char *str;
0099 
0100     if (!(sgimc->systemid & SGIMC_SYSID_EPRESENT)) {
0101         printk(KERN_INFO "EISA: bus not present.\n");
0102         return 1;
0103     }
0104 
0105     printk(KERN_INFO "EISA: Probing bus...\n");
0106     for (c = 0, i = 1; i <= IP22_EISA_MAX_SLOTS; i++) {
0107         if ((str = decode_eisa_sig(0x1000 * i + EISA_VENDOR_ID_OFFSET))) {
0108             printk(KERN_INFO "EISA: slot %d : %s detected.\n",
0109                    i, str);
0110             c++;
0111         }
0112     }
0113     printk(KERN_INFO "EISA: Detected %d card%s.\n", c, c < 2 ? "" : "s");
0114 #ifdef CONFIG_ISA
0115     printk(KERN_INFO "ISA support compiled in.\n");
0116 #endif
0117 
0118     /* Warning : BlackMagicAhead(tm).
0119        Please wave your favorite dead chicken over the busses */
0120 
0121     /* First say hello to the EIU */
0122     outl(0x0000FFFF, EIU_PREMPT_REG);
0123     outl(1, EIU_QUIET_REG);
0124     outl(0x40f3c07F, EIU_MODE_REG);
0125 
0126     /* Now be nice to the EISA chipset */
0127     outb(1, EISA_EXT_NMI_RESET_CTRL);
0128     udelay(50); /* Wait long enough for the dust to settle */
0129     outb(0, EISA_EXT_NMI_RESET_CTRL);
0130     outb(0, EISA_DMA2_WRITE_SINGLE);
0131 
0132     init_i8259_irqs();
0133 
0134     if (request_irq(SGI_EISA_IRQ, ip22_eisa_intr, 0, "EISA", NULL))
0135         pr_err("Failed to request irq %d (EISA)\n", SGI_EISA_IRQ);
0136 
0137     EISA_bus = 1;
0138     return 0;
0139 }