ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / pci / fixup-sni.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * SNI specific PCI support for RM200/RM300.
7  *
8  * Copyright (C) 1997 - 2000, 2003 Ralf Baechle
9  */
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/pci.h>
13
14 #include <asm/mipsregs.h>
15 #include <asm/pci_channel.h>
16 #include <asm/sni.h>
17
18 /*
19  * Shortcuts ...
20  */
21 #define SCSI    PCIMT_IRQ_SCSI
22 #define ETH     PCIMT_IRQ_ETHERNET
23 #define INTA    PCIMT_IRQ_INTA
24 #define INTB    PCIMT_IRQ_INTB
25 #define INTC    PCIMT_IRQ_INTC
26 #define INTD    PCIMT_IRQ_INTD
27
28 /*
29  * Device 0: PCI EISA Bridge    (directly routed)
30  * Device 1: NCR53c810 SCSI     (directly routed)
31  * Device 2: PCnet32 Ethernet   (directly routed)
32  * Device 3: VGA                (routed to INTB)
33  * Device 4: Unused
34  * Device 5: Slot 2
35  * Device 6: Slot 3
36  * Device 7: Slot 4     
37  *
38  * Documentation says the VGA is device 5 and device 3 is unused but that
39  * seem to be a documentation error.  At least on my RM200C the Cirrus
40  * Logic CL-GD5434 VGA is device 3.
41  */
42 static char irq_tab_rm200[8][5] __initdata = {
43         /*       INTA  INTB  INTC  INTD */
44         {     0,    0,    0,    0,    0 },      /* EISA bridge */
45         {  SCSI, SCSI, SCSI, SCSI, SCSI },      /* SCSI */
46         {   ETH,  ETH,  ETH,  ETH,  ETH },      /* Ethernet */
47         {  INTB, INTB, INTB, INTB, INTB },      /* VGA */
48         {     0,    0,    0,    0,    0 },      /* Unused */
49         {     0, INTB, INTC, INTD, INTA },      /* Slot 2 */
50         {     0, INTC, INTD, INTA, INTB },      /* Slot 3 */
51         {     0, INTD, INTA, INTB, INTC },      /* Slot 4 */
52 };
53
54 /*
55  * In Revision D of the RM300 Device 2 has become a normal purpose Slot 1
56  *
57  * The VGA card is optional for RM300 systems.
58  */
59 static char irq_tab_rm300d[8][5] __initdata = {
60         /*       INTA  INTB  INTC  INTD */
61         {     0,    0,    0,    0,    0 },      /* EISA bridge */
62         {  SCSI, SCSI, SCSI, SCSI, SCSI },      /* SCSI */
63         {     0, INTC, INTD, INTA, INTB },      /* Slot 1 */
64         {  INTB, INTB, INTB, INTB, INTB },      /* VGA */
65         {     0,    0,    0,    0,    0 },      /* Unused */
66         {     0, INTB, INTC, INTD, INTA },      /* Slot 2 */
67         {     0, INTC, INTD, INTA, INTB },      /* Slot 3 */
68         {     0, INTD, INTA, INTB, INTC },      /* Slot 4 */
69 };
70
71 static inline int is_rm300_revd(void)
72 {
73         unsigned char csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
74
75         return (csmsr & 0xa0) == 0x20;
76 }
77
78 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
79 {
80         if (is_rm300_revd())
81                 return irq_tab_rm300d[slot][pin];
82
83         return irq_tab_rm200[slot][pin];
84 }
85
86 struct pci_fixup pcibios_fixups[] = {
87         {0}
88 };