blob: f67ebeeb42000bb5d4d73961d6bcc4d632375298 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Ralf Baechle3a1d8212007-03-01 15:35:54 +000017#include <irq.h>
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019/*
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010020 * PCIMT Shortcuts ...
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 */
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
Ralf Baechle42a3b4f2005-09-03 15:56:17 -070037 * Device 7: Slot 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 *
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 */
43static char irq_tab_rm200[8][5] __initdata = {
Ralf Baechle70342282013-01-22 12:59:30 +010044 /* INTA INTB INTC INTD */
45 { 0, 0, 0, 0, 0 }, /* EISA bridge */
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
Ralf Baechle70342282013-01-22 12:59:30 +010047 { ETH, ETH, ETH, ETH, ETH }, /* Ethernet */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 { INTB, INTB, INTB, INTB, INTB }, /* VGA */
Ralf Baechle70342282013-01-22 12:59:30 +010049 { 0, 0, 0, 0, 0 }, /* Unused */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 { 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 */
60static char irq_tab_rm300d[8][5] __initdata = {
Ralf Baechle70342282013-01-22 12:59:30 +010061 /* INTA INTB INTC INTD */
62 { 0, 0, 0, 0, 0 }, /* EISA bridge */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 { SCSI, SCSI, SCSI, SCSI, SCSI }, /* SCSI */
64 { 0, INTC, INTD, INTA, INTB }, /* Slot 1 */
65 { INTB, INTB, INTB, INTB, INTB }, /* VGA */
Ralf Baechle70342282013-01-22 12:59:30 +010066 { 0, 0, 0, 0, 0 }, /* Unused */
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 { 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
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010072static char irq_tab_rm300e[5][5] __initdata = {
Ralf Baechle70342282013-01-22 12:59:30 +010073 /* INTA INTB INTC INTD */
74 { 0, 0, 0, 0, 0 }, /* HOST bridge */
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010075 { 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
99static char irq_tab_pcit[13][5] __initdata = {
Ralf Baechle70342282013-01-22 12:59:30 +0100100 /* INTA INTB INTC INTD */
101 { 0, 0, 0, 0, 0 }, /* HOST bridge */
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100102 { SCSI0, SCSI0, SCSI0, SCSI0, SCSI0 }, /* SCSI */
103 { SCSI1, SCSI1, SCSI1, SCSI1, SCSI1 }, /* SCSI */
Ralf Baechle70342282013-01-22 12:59:30 +0100104 { 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 */
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100114};
115
Thomas Bogendoerferfcee3fa2007-11-08 22:09:11 +0100116static char irq_tab_pcit_cplus[13][5] __initdata = {
Ralf Baechle70342282013-01-22 12:59:30 +0100117 /* 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 */
Thomas Bogendoerferfcee3fa2007-11-08 22:09:11 +0100124};
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126static inline int is_rm300_revd(void)
127{
128 unsigned char csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
129
130 return (csmsr & 0xa0) == 0x20;
131}
132
Ralf Baechle19df0d12007-07-10 17:33:00 +0100133int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100135 switch (sni_brd_type) {
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100136 case SNI_BRD_PCI_TOWER_CPLUS:
Thomas Bogendoerferfcee3fa2007-11-08 22:09:11 +0100137 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:
Ralf Baechle70342282013-01-22 12:59:30 +0100149 return irq_tab_pcit[slot][pin];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100151 case SNI_BRD_PCI_MTOWER:
Ralf Baechle70342282013-01-22 12:59:30 +0100152 if (is_rm300_revd())
153 return irq_tab_rm300d[slot][pin];
154 /* fall through */
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100155
156 case SNI_BRD_PCI_DESKTOP:
Ralf Baechle70342282013-01-22 12:59:30 +0100157 return irq_tab_rm200[slot][pin];
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100158
159 case SNI_BRD_PCI_MTOWER_CPLUS:
Ralf Baechle70342282013-01-22 12:59:30 +0100160 return irq_tab_rm300e[slot][pin];
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100161 }
162
163 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164}
165
166/* Do platform specific device initialization at pci_enable_device() time */
167int pcibios_plat_dev_init(struct pci_dev *dev)
168{
169 return 0;
170}