Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[GitHub/mt8127/android_kernel_alcatel_ttab.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, 04 Ralf Baechle (ralf@linux-mips.org)
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 /*
18 * PCIMT Shortcuts ...
19 */
20 #define SCSI PCIMT_IRQ_SCSI
21 #define ETH PCIMT_IRQ_ETHERNET
22 #define INTA PCIMT_IRQ_INTA
23 #define INTB PCIMT_IRQ_INTB
24 #define INTC PCIMT_IRQ_INTC
25 #define INTD PCIMT_IRQ_INTD
26
27 /*
28 * Device 0: PCI EISA Bridge (directly routed)
29 * Device 1: NCR53c810 SCSI (directly routed)
30 * Device 2: PCnet32 Ethernet (directly routed)
31 * Device 3: VGA (routed to INTB)
32 * Device 4: Unused
33 * Device 5: Slot 2
34 * Device 6: Slot 3
35 * Device 7: Slot 4
36 *
37 * Documentation says the VGA is device 5 and device 3 is unused but that
38 * seem to be a documentation error. At least on my RM200C the Cirrus
39 * Logic CL-GD5434 VGA is device 3.
40 */
41 static char irq_tab_rm200[8][5] __initdata = {
42 /* INTA INTB INTC INTD */
43 { 0, 0, 0, 0, 0 }, /* EISA bridge */
44 { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
45 { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
46 { INTB, INTB, INTB, INTB, INTB }, /* VGA */
47 { 0, 0, 0, 0, 0 }, /* Unused */
48 { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
49 { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
50 { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
51 };
52
53 /*
54 * In Revision D of the RM300 Device 2 has become a normal purpose Slot 1
55 *
56 * The VGA card is optional for RM300 systems.
57 */
58 static char irq_tab_rm300d[8][5] __initdata = {
59 /* INTA INTB INTC INTD */
60 { 0, 0, 0, 0, 0 }, /* EISA bridge */
61 { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
62 { 0, INTC, INTD, INTA, INTB }, /* Slot 1 */
63 { INTB, INTB, INTB, INTB, INTB }, /* VGA */
64 { 0, 0, 0, 0, 0 }, /* Unused */
65 { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
66 { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
67 { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
68 };
69
70 static char irq_tab_rm300e[5][5] __initdata = {
71 /* INTA INTB INTC INTD */
72 { 0, 0, 0, 0, 0 }, /* HOST bridge */
73 { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
74 { 0, INTC, INTD, INTA, INTB }, /* Bridge/i960 */
75 { 0, INTD, INTA, INTB, INTC }, /* Slot 1 */
76 { 0, INTA, INTB, INTC, INTD }, /* Slot 2 */
77 };
78 #undef SCSI
79 #undef ETH
80 #undef INTA
81 #undef INTB
82 #undef INTC
83 #undef INTD
84
85
86 /*
87 * PCIT Shortcuts ...
88 */
89 #define SCSI0 PCIT_IRQ_SCSI0
90 #define SCSI1 PCIT_IRQ_SCSI1
91 #define ETH PCIT_IRQ_ETHERNET
92 #define INTA PCIT_IRQ_INTA
93 #define INTB PCIT_IRQ_INTB
94 #define INTC PCIT_IRQ_INTC
95 #define INTD PCIT_IRQ_INTD
96
97 static char irq_tab_pcit[13][5] __initdata = {
98 /* INTA INTB INTC INTD */
99 { 0, 0, 0, 0, 0 }, /* HOST bridge */
100 { SCSI0, SCSI0, SCSI0, SCSI0, SCSI0 }, /* SCSI */
101 { SCSI1, SCSI1, SCSI1, SCSI1, SCSI1 }, /* SCSI */
102 { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
103 { 0, INTA, INTB, INTC, INTD }, /* PCI-PCI bridge */
104 { 0, 0, 0, 0, 0 }, /* Unused */
105 { 0, 0, 0, 0, 0 }, /* Unused */
106 { 0, 0, 0, 0, 0 }, /* Unused */
107 { 0, INTA, INTB, INTC, INTD }, /* Slot 1 */
108 { 0, INTB, INTC, INTD, INTA }, /* Slot 2 */
109 { 0, INTC, INTD, INTA, INTB }, /* Slot 3 */
110 { 0, INTD, INTA, INTB, INTC }, /* Slot 4 */
111 { 0, INTA, INTB, INTC, INTD }, /* Slot 5 */
112 };
113
114 static inline int is_rm300_revd(void)
115 {
116 unsigned char csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
117
118 return (csmsr & 0xa0) == 0x20;
119 }
120
121 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
122 {
123 switch (sni_brd_type) {
124 case SNI_BRD_PCI_TOWER:
125 case SNI_BRD_PCI_TOWER_CPLUS:
126 return irq_tab_pcit[slot][pin];
127
128 case SNI_BRD_PCI_MTOWER:
129 if (is_rm300_revd())
130 return irq_tab_rm300d[slot][pin];
131 /* fall through */
132
133 case SNI_BRD_PCI_DESKTOP:
134 return irq_tab_rm200[slot][pin];
135
136 case SNI_BRD_PCI_MTOWER_CPLUS:
137 return irq_tab_rm300e[slot][pin];
138 }
139
140 return 0;
141 }
142
143 /* Do platform specific device initialization at pci_enable_device() time */
144 int pcibios_plat_dev_init(struct pci_dev *dev)
145 {
146 return 0;
147 }