aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/pci/fixup-rbtx4927.c
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-07-10 11:33:08 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-07-15 13:44:35 -0400
commit89d63fe179520b11f54de1f26755b7444c79e73a (patch)
treefede06c5648335652c864fc35c951d991cbab183 /arch/mips/pci/fixup-rbtx4927.c
parent22b1d707ffc99faebd86257ad19d5bb9fc624734 (diff)
[MIPS] TXx9: Reorganize PCI code
Split out PCIC dependent code and SoC dependent code from board dependent code. Now TX4927 PCIC code is independent from TX4927/TX4938 SoC code. Also fix some build problems on CONFIG_PCI=n. As a bonus, "FPCIB0 Backplane Support" is available for all TX39/TX49 boards and PCI66 support is available for all TX49 boards. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/pci/fixup-rbtx4927.c')
-rw-r--r--arch/mips/pci/fixup-rbtx4927.c112
1 files changed, 26 insertions, 86 deletions
diff --git a/arch/mips/pci/fixup-rbtx4927.c b/arch/mips/pci/fixup-rbtx4927.c
index 26013badfe1..abab4852d15 100644
--- a/arch/mips/pci/fixup-rbtx4927.c
+++ b/arch/mips/pci/fixup-rbtx4927.c
@@ -33,102 +33,42 @@
33 * 675 Mass Ave, Cambridge, MA 02139, USA. 33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */ 34 */
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/pci.h> 36#include <asm/txx9/pci.h>
37#include <linux/kernel.h> 37#include <asm/txx9/rbtx4927.h>
38#include <linux/init.h>
39 38
40#include <asm/txx9/tx4927.h> 39int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
41
42#undef DEBUG
43#ifdef DEBUG
44#define DBG(x...) printk(x)
45#else
46#define DBG(x...)
47#endif
48
49/* look up table for backplane pci irq for slots 17-20 by pin # */
50static unsigned char backplane_pci_irq[4][4] = {
51 /* PJ6 SLOT: 17, PIN: 1 */ {TX4927_IRQ_IOC_PCIA,
52 /* PJ6 SLOT: 17, PIN: 2 */
53 TX4927_IRQ_IOC_PCIB,
54 /* PJ6 SLOT: 17, PIN: 3 */
55 TX4927_IRQ_IOC_PCIC,
56 /* PJ6 SLOT: 17, PIN: 4 */
57 TX4927_IRQ_IOC_PCID},
58 /* SB SLOT: 18, PIN: 1 */ {TX4927_IRQ_IOC_PCIB,
59 /* SB SLOT: 18, PIN: 2 */
60 TX4927_IRQ_IOC_PCIC,
61 /* SB SLOT: 18, PIN: 3 */
62 TX4927_IRQ_IOC_PCID,
63 /* SB SLOT: 18, PIN: 4 */
64 TX4927_IRQ_IOC_PCIA},
65 /* PJ5 SLOT: 19, PIN: 1 */ {TX4927_IRQ_IOC_PCIC,
66 /* PJ5 SLOT: 19, PIN: 2 */
67 TX4927_IRQ_IOC_PCID,
68 /* PJ5 SLOT: 19, PIN: 3 */
69 TX4927_IRQ_IOC_PCIA,
70 /* PJ5 SLOT: 19, PIN: 4 */
71 TX4927_IRQ_IOC_PCIB},
72 /* PJ4 SLOT: 20, PIN: 1 */ {TX4927_IRQ_IOC_PCID,
73 /* PJ4 SLOT: 20, PIN: 2 */
74 TX4927_IRQ_IOC_PCIA,
75 /* PJ4 SLOT: 20, PIN: 3 */
76 TX4927_IRQ_IOC_PCIB,
77 /* PJ4 SLOT: 20, PIN: 4 */
78 TX4927_IRQ_IOC_PCIC}
79};
80
81static int pci_get_irq(const struct pci_dev *dev, int pin)
82{ 40{
83 unsigned char irq = pin; 41 unsigned char irq = pin;
84 42
85 DBG("pci_get_irq: pin is %d\n", pin);
86 /* IRQ rotation */ 43 /* IRQ rotation */
87 irq--; /* 0-3 */ 44 irq--; /* 0-3 */
88 if (dev->bus->parent == NULL && 45 if (slot == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) {
89 PCI_SLOT(dev->devfn) == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) { 46 /* PCI CardSlot (IDSEL=A23) */
90 printk("Onboard PCI_SLOT(dev->devfn) is %d\n", 47 /* PCIA => PCIA */
91 PCI_SLOT(dev->devfn)); 48 irq = (irq + 0 + slot) % 4;
92 /* IDSEL=A23 is tx4927 onboard pci slot */
93 irq = (irq + PCI_SLOT(dev->devfn)) % 4;
94 irq++; /* 1-4 */
95 DBG("irq is now %d\n", irq);
96
97 switch (irq) {
98 case 1:
99 irq = TX4927_IRQ_IOC_PCIA;
100 break;
101 case 2:
102 irq = TX4927_IRQ_IOC_PCIB;
103 break;
104 case 3:
105 irq = TX4927_IRQ_IOC_PCIC;
106 break;
107 case 4:
108 irq = TX4927_IRQ_IOC_PCID;
109 break;
110 }
111 } else { 49 } else {
112 /* PCI Backplane */ 50 /* PCI Backplane */
113 DBG("PCI Backplane PCI_SLOT(dev->devfn) is %d\n", 51 if (txx9_pci_option & TXX9_PCI_OPT_PICMG)
114 PCI_SLOT(dev->devfn)); 52 irq = (irq + 33 - slot) % 4;
115 irq = backplane_pci_irq[PCI_SLOT(dev->devfn) - 17][irq]; 53 else
54 irq = (irq + 3 + slot) % 4;
116 } 55 }
117 DBG("assigned irq %d\n", irq); 56 irq++; /* 1-4 */
118 return irq;
119}
120
121int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
122{
123 unsigned char irq;
124
125 printk("PCI Setup for pin %d \n", pin);
126
127 if (dev->device == 0x9130) /* IDE */
128 irq = 14;
129 else
130 irq = pci_get_irq(dev, pin);
131 57
58 switch (irq) {
59 case 1:
60 irq = RBTX4927_IRQ_IOC_PCIA;
61 break;
62 case 2:
63 irq = RBTX4927_IRQ_IOC_PCIB;
64 break;
65 case 3:
66 irq = RBTX4927_IRQ_IOC_PCIC;
67 break;
68 case 4:
69 irq = RBTX4927_IRQ_IOC_PCID;
70 break;
71 }
132 return irq; 72 return irq;
133} 73}
134 74