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
6 * SNI specific PCI support for RM200/RM300.
8 * Copyright (C) 1997 - 2000 Ralf Baechle
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/pci.h>
13 #include <linux/types.h>
14 #include <asm/byteorder.h>
17 #define mkaddr(bus, devfn, where) \
19 if (bus->number == 0) \
21 *(volatile u32 *)PCIMT_CONFIG_ADDRESS = \
22 ((bus->number & 0xff) << 0x10) | \
23 ((devfn & 0xff) << 0x08) | \
28 /* To do: Bring this uptodate ... */
29 static void pcimt_pcibios_fixup(void)
33 pci_for_each_dev(dev
) {
35 * TODO: Take care of RM300 revision D boards for where the
36 * network slot became an ordinary PCI slot.
38 if (dev
->devfn
== PCI_DEVFN(1, 0)) {
40 set_cp0_config(CONF_CM_CMASK
,
41 CONF_CM_CACHABLE_NO_WA
);
42 dev
->irq
= PCIMT_IRQ_SCSI
;
45 if (dev
->devfn
== PCI_DEVFN(2, 0)) {
46 dev
->irq
= PCIMT_IRQ_ETHERNET
;
52 dev
->irq
+= PCIMT_IRQ_INTA
- 1;
57 printk("PCI device on bus %d, dev %d, function %d "
58 "impossible interrupt configured.\n",
59 dev
->bus
->number
, PCI_SLOT(dev
->devfn
),
60 PCI_SLOT(dev
->devfn
));
67 * We can't address 8 and 16 bit words directly. Instead we have to
68 * read/write a 32bit word and mask/modify the data we actually want.
70 static int pcimt_read(struct pci_bus
*bus
, unsigned int devfn
, int where
,
77 mkaddr(bus
, devfn
, where
);
78 res
= *(volatile u32
*) PCIMT_CONFIG_DATA
;
79 res
= (le32_to_cpu(res
) >> ((where
& 3) << 3)) & 0xff;
84 return PCIBIOS_BAD_REGISTER_NUMBER
;
85 mkaddr(bus
, devfn
, where
);
86 res
= *(volatile u32
*) PCIMT_CONFIG_DATA
;
87 res
= (le32_to_cpu(res
) >> ((where
& 3) << 3)) & 0xffff;
92 return PCIBIOS_BAD_REGISTER_NUMBER
;
93 mkaddr(bus
, devfn
, where
);
94 res
= *(volatile u32
*) PCIMT_CONFIG_DATA
;
95 res
= le32_to_cpu(res
);
100 return PCIBIOS_SUCCESSFUL
;
103 static int pcimt_write(struct pci_bus
*bus
, unsigned int devfn
, int where
,
108 mkaddr(bus
, devfn
, where
);
109 *(volatile u8
*) (PCIMT_CONFIG_DATA
+ (where
& 3)) =
110 (u8
) le32_to_cpu(val
);
114 return PCIBIOS_BAD_REGISTER_NUMBER
;
115 mkaddr(bus
, devfn
, where
);
116 *(volatile u16
*) (PCIMT_CONFIG_DATA
+ (where
& 3)) =
117 (u16
) le32_to_cpu(val
);
121 return PCIBIOS_BAD_REGISTER_NUMBER
;
122 mkaddr(bus
, devfn
, where
);
123 *(volatile u32
*) PCIMT_CONFIG_DATA
= le32_to_cpu(val
);
127 return PCIBIOS_SUCCESSFUL
;
130 struct pci_ops sni_pci_ops
= {
132 .write
= pcimt_write
,
135 void __devinit
pcibios_fixup_bus(struct pci_bus
*b
)
139 static int __init
pcibios_init(void)
141 struct pci_ops
*ops
= &sni_pci_ops
;
143 pci_scan_bus(0, ops
, NULL
);
148 subsys_initcall(pcibios_init
);
150 int __init
pcibios_enable_device(struct pci_dev
*dev
, int mask
)
152 /* Not needed, since we enable all devices at startup. */
156 void pcibios_align_resource(void *data
, struct resource
*res
,
157 unsigned long size
, unsigned long align
)
161 unsigned __init
int pcibios_assign_all_busses(void)
166 char *__init
pcibios_setup(char *str
)
168 /* Nothing to do for now. */
173 struct pci_fixup pcibios_fixups
[] = {