26 #include <linux/kernel.h>
27 #include <linux/pci.h>
29 #include <asm/pci-bridge.h>
30 #include <asm/machdep.h>
34 #define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))
42 if (bus == 0 && devfn == 0)
51 return hose->cfg_data +
PA_PXP_CFA(bus, devfn, offset);
54 static inline int is_root_port(
int busno,
int devfn)
56 return ((busno == 0) && (
PCI_FUNC(devfn) < 4) &&
60 static inline int is_5945_reg(
int reg)
62 return (((reg >= 0x18) && (reg < 0x34)) ||
63 ((reg >= 0x158) && (reg < 0x178)));
66 static int workaround_5945(
struct pci_bus *
bus,
unsigned int devfn,
74 if (!is_root_port(bus->
number, devfn) || !is_5945_reg(offset))
77 hose = pci_bus_to_host(bus);
79 addr = pa_pxp_cfg_addr(hose, bus->
number, devfn, offset & ~0x3);
86 dummy = pa_pxp_cfg_addr(hose, bus->
number, devfn, 0x10);
93 *val = (tmp >> (8*
byte)) & 0xff;
99 *val = (tmp >> 16) & 0xffff;
109 static int pa_pxp_read_config(
struct pci_bus *bus,
unsigned int devfn,
110 int offset,
int len,
u32 *val)
115 hose = pci_bus_to_host(bus);
119 if (!pa_pxp_offset_valid(bus->
number, devfn, offset))
122 if (workaround_5945(bus, devfn, offset, len, val))
125 addr = pa_pxp_cfg_addr(hose, bus->
number, devfn, offset);
146 static int pa_pxp_write_config(
struct pci_bus *bus,
unsigned int devfn,
147 int offset,
int len,
u32 val)
152 hose = pci_bus_to_host(bus);
156 if (!pa_pxp_offset_valid(bus->
number, devfn, offset))
159 addr = pa_pxp_cfg_addr(hose, bus->
number, devfn, offset);
179 static struct pci_ops pa_pxp_ops = {
180 .read = pa_pxp_read_config,
181 .write = pa_pxp_write_config,
186 hose->
ops = &pa_pxp_ops;
187 hose->cfg_data =
ioremap(0xe0000000, 0x10000000);
238 hose = pci_bus_to_host(dev->
bus);
240 return (
void __iomem *)pa_pxp_cfg_addr(hose, dev->
bus->number, dev->
devfn, offset);