24 #include <linux/kernel.h>
26 #include <linux/pci.h>
27 #include <linux/string.h>
32 #include <asm/pgtable.h>
35 #include <asm/machdep.h>
36 #include <asm/pci-bridge.h>
37 #include <asm/iommu.h>
44 static int read_pci_config;
45 static int write_pci_config;
46 static int ibm_read_pci_config;
47 static int ibm_write_pci_config;
49 static inline int config_access_valid(
struct pci_dn *
dn,
int where)
53 if (where < 4096 && dn->pci_ext_config_space)
62 unsigned long buid,
addr;
67 if (!config_access_valid(pdn, where))
70 addr = rtas_config_addr(pdn->busno, pdn->devfn, where);
71 buid = pdn->phb->buid;
73 ret =
rtas_call(ibm_read_pci_config, 4, 2, &returnval,
74 addr, BUID_HI(buid), BUID_LO(buid), size);
76 ret =
rtas_call(read_pci_config, 2, 2, &returnval, addr, size);
83 if (returnval == EEH_IO_ERROR_VALUE(size) &&
90 static int rtas_pci_read_config(
struct pci_bus *
bus,
96 busdn = pci_bus_to_OF_node(bus);
100 struct pci_dn *pdn = PCI_DN(dn);
101 if (pdn && pdn->devfn == devfn
111 unsigned long buid,
addr;
116 if (!config_access_valid(pdn, where))
119 addr = rtas_config_addr(pdn->busno, pdn->devfn, where);
120 buid = pdn->phb->buid;
123 BUID_HI(buid), BUID_LO(buid), size, (
ulong) val);
134 static int rtas_pci_write_config(
struct pci_bus *bus,
136 int where,
int size,
u32 val)
140 busdn = pci_bus_to_OF_node(bus);
144 struct pci_dn *pdn = PCI_DN(dn);
145 if (pdn && pdn->devfn == devfn
152 static struct pci_ops rtas_pci_ops = {
153 .read = rtas_pci_read_config,
154 .write = rtas_pci_write_config,
161 if (model &&
strstr(model,
"Python"))
167 static void python_countermeasures(
struct device_node *dev)
186 #define PRG_CL_RESET_VALID 0x00010000
188 val =
in_be32(chip_regs + 0xf6030);
189 if (val & PRG_CL_RESET_VALID) {
191 val &= ~PRG_CL_RESET_VALID;
197 val =
in_be32(chip_regs + 0xf6030);
198 printk(
"reg0: %x\n", val);
206 read_pci_config =
rtas_token(
"read-pci-config");
207 write_pci_config =
rtas_token(
"write-pci-config");
208 ibm_read_pci_config =
rtas_token(
"ibm,read-pci-config");
209 ibm_write_pci_config =
rtas_token(
"ibm,write-pci-config");
216 if (ibm_read_pci_config == -1)
223 static int phb_set_bus_ranges(
struct device_node *dev,
226 const int *bus_range;
230 if (bus_range ==
NULL || len < 2 *
sizeof(
int)) {
245 python_countermeasures(dev);
247 if (phb_set_bus_ranges(dev, phb))
250 phb->
ops = &rtas_pci_ops;
286 "linux,pci-probe-only",
NULL);
289 pci_add_flags(PCI_PROBE_ONLY);
291 pci_clear_flags(PCI_PROBE_ONLY);
296 "linux,pci-assign-all-buses",
NULL);
298 pci_add_flags(PCI_REASSIGN_ALL_BUS);