Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fixup-sni.c
Go to the documentation of this file.
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, 04 Ralf Baechle ([email protected])
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/sni.h>
16 
17 #include <irq.h>
18 
19 /*
20  * PCIMT Shortcuts ...
21  */
22 #define SCSI PCIMT_IRQ_SCSI
23 #define ETH PCIMT_IRQ_ETHERNET
24 #define INTA PCIMT_IRQ_INTA
25 #define INTB PCIMT_IRQ_INTB
26 #define INTC PCIMT_IRQ_INTC
27 #define INTD PCIMT_IRQ_INTD
28 
29 /*
30  * Device 0: PCI EISA Bridge (directly routed)
31  * Device 1: NCR53c810 SCSI (directly routed)
32  * Device 2: PCnet32 Ethernet (directly routed)
33  * Device 3: VGA (routed to INTB)
34  * Device 4: Unused
35  * Device 5: Slot 2
36  * Device 6: Slot 3
37  * Device 7: Slot 4
38  *
39  * Documentation says the VGA is device 5 and device 3 is unused but that
40  * seem to be a documentation error. At least on my RM200C the Cirrus
41  * Logic CL-GD5434 VGA is device 3.
42  */
43 static char irq_tab_rm200[8][5] __initdata = {
44  /* INTA INTB INTC INTD */
45  { 0, 0, 0, 0, 0 }, /* EISA bridge */
46  { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
47  { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
48  { INTB, INTB, INTB, INTB, INTB }, /* VGA */
49  { 0, 0, 0, 0, 0 }, /* Unused */
50  { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
51  { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
52  { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
53 };
54 
55 /*
56  * In Revision D of the RM300 Device 2 has become a normal purpose Slot 1
57  *
58  * The VGA card is optional for RM300 systems.
59  */
60 static char irq_tab_rm300d[8][5] __initdata = {
61  /* INTA INTB INTC INTD */
62  { 0, 0, 0, 0, 0 }, /* EISA bridge */
63  { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
64  { 0, INTC, INTD, INTA, INTB }, /* Slot 1 */
65  { INTB, INTB, INTB, INTB, INTB }, /* VGA */
66  { 0, 0, 0, 0, 0 }, /* Unused */
67  { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
68  { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
69  { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
70 };
71 
72 static char irq_tab_rm300e[5][5] __initdata = {
73  /* INTA INTB INTC INTD */
74  { 0, 0, 0, 0, 0 }, /* HOST bridge */
75  { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
76  { 0, INTC, INTD, INTA, INTB }, /* Bridge/i960 */
77  { 0, INTD, INTA, INTB, INTC }, /* Slot 1 */
78  { 0, INTA, INTB, INTC, INTD }, /* Slot 2 */
79 };
80 #undef SCSI
81 #undef ETH
82 #undef INTA
83 #undef INTB
84 #undef INTC
85 #undef INTD
86 
87 
88 /*
89  * PCIT Shortcuts ...
90  */
91 #define SCSI0 PCIT_IRQ_SCSI0
92 #define SCSI1 PCIT_IRQ_SCSI1
93 #define ETH PCIT_IRQ_ETHERNET
94 #define INTA PCIT_IRQ_INTA
95 #define INTB PCIT_IRQ_INTB
96 #define INTC PCIT_IRQ_INTC
97 #define INTD PCIT_IRQ_INTD
98 
99 static char irq_tab_pcit[13][5] __initdata = {
100  /* INTA INTB INTC INTD */
101  { 0, 0, 0, 0, 0 }, /* HOST bridge */
102  { SCSI0, SCSI0, SCSI0, SCSI0, SCSI0 }, /* SCSI */
103  { SCSI1, SCSI1, SCSI1, SCSI1, SCSI1 }, /* SCSI */
104  { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
105  { 0, INTA, INTB, INTC, INTD }, /* PCI-PCI bridge */
106  { 0, 0, 0, 0, 0 }, /* Unused */
107  { 0, 0, 0, 0, 0 }, /* Unused */
108  { 0, 0, 0, 0, 0 }, /* Unused */
109  { 0, INTA, INTB, INTC, INTD }, /* Slot 1 */
110  { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
111  { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
112  { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
113  { 0, INTA, INTB, INTC, INTD }, /* Slot 5 */
114 };
115 
116 static char irq_tab_pcit_cplus[13][5] __initdata = {
117  /* INTA INTB INTC INTD */
118  { 0, 0, 0, 0, 0 }, /* HOST bridge */
119  { 0, INTB, INTC, INTD, INTA }, /* PCI Slot 9 */
120  { 0, 0, 0, 0, 0 }, /* PCI-EISA */
121  { 0, 0, 0, 0, 0 }, /* Unused */
122  { 0, INTA, INTB, INTC, INTD }, /* PCI-PCI bridge */
123  { 0, INTB, INTC, INTD, INTA }, /* fixup */
124 };
125 
126 static inline int is_rm300_revd(void)
127 {
128  unsigned char csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
129 
130  return (csmsr & 0xa0) == 0x20;
131 }
132 
134 {
135  switch (sni_brd_type) {
137  if (slot == 4) {
138  /*
139  * SNI messed up interrupt wiring for onboard
140  * PCI bus 1; we need to fix this up here
141  */
142  while (dev && dev->bus->number != 1)
143  dev = dev->bus->self;
144  if (dev && dev->devfn >= PCI_DEVFN(4, 0))
145  slot = 5;
146  }
147  return irq_tab_pcit_cplus[slot][pin];
148  case SNI_BRD_PCI_TOWER:
149  return irq_tab_pcit[slot][pin];
150 
151  case SNI_BRD_PCI_MTOWER:
152  if (is_rm300_revd())
153  return irq_tab_rm300d[slot][pin];
154  /* fall through */
155 
156  case SNI_BRD_PCI_DESKTOP:
157  return irq_tab_rm200[slot][pin];
158 
160  return irq_tab_rm300e[slot][pin];
161  }
162 
163  return 0;
164 }
165 
166 /* Do platform specific device initialization at pci_enable_device() time */
168 {
169  return 0;
170 }