14 #include <linux/kernel.h>
15 #include <linux/sched.h>
18 #include <asm/machdep.h>
19 #include <asm/pgtable.h>
23 #define IOWA_MAX_BUS 8
26 static unsigned int iowa_bus_count;
34 for (i = 0; i < iowa_bus_count; i++) {
39 vstart = (
unsigned long)phb->io_base_virt;
40 vend = vstart + phb->pci_io_size - 1;
41 if ((vaddr >= vstart) && (vaddr <=
vend))
46 for (j = 0; j < 3; j++) {
48 if (paddr >= res->
start && paddr <= res->
end)
61 token = PCI_GET_ADDR_TOKEN(addr);
63 if (token && token <= iowa_bus_count)
64 bus = &iowa_busses[token - 1];
69 vaddr = (
unsigned long)PCI_FIX_ADDR(addr);
70 if (vaddr < PHB_IO_BASE || vaddr >=
PHB_IO_END)
73 ptep = find_linux_pte(
init_mm.pgd, vaddr);
78 bus = iowa_pci_find(vaddr, paddr);
90 return iowa_pci_find(vaddr, 0);
94 #define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \
95 static ret iowa_##name at \
97 struct iowa_bus *bus; \
98 bus = iowa_##space##_find_bus(aa); \
99 if (bus && bus->ops && bus->ops->name) \
100 return bus->ops->name al; \
101 return __do_##name al; \
104 #define DEF_PCI_AC_NORET(name, at, al, space, aa) \
105 static void iowa_##name at \
107 struct iowa_bus *bus; \
108 bus = iowa_##space##_find_bus(aa); \
109 if (bus && bus->ops && bus->ops->name) { \
118 #undef DEF_PCI_AC_RET
119 #undef DEF_PCI_AC_NORET
123 #define DEF_PCI_AC_RET(name, ret, at, al, space, aa) .name = iowa_##name,
124 #define DEF_PCI_AC_NORET(name, at, al, space, aa) .name = iowa_##name,
128 #undef DEF_PCI_AC_RET
129 #undef DEF_PCI_AC_NORET
140 bus = iowa_pci_find(0, (
unsigned long)addr);
142 busno = bus - iowa_busses;
143 PCI_SET_ADDR_TOKEN(res, busno + 1);
149 static void __devinit io_workaround_init(
void)
151 static int io_workaround_inited;
153 if (io_workaround_inited)
155 ppc_pci_io = iowa_pci_io;
156 ppc_md.ioremap = iowa_ioremap;
157 io_workaround_inited = 1;
162 struct ppc_pci_io *
ops,
168 io_workaround_init();
171 pr_err(
"IOWA:Too many pci bridges, "
172 "workarounds disabled for %s\n", np->
full_name);
176 bus = &iowa_busses[iowa_bus_count];