23 #include <linux/kernel.h>
25 #include <linux/pci.h>
33 #include <asm/pci-bridge.h>
39 #define MAX_PCI_DEVICES 32
40 #define MAX_PCI_FUNCTIONS 8
42 #define iob() __asm__ __volatile__("eieio; sync":::"memory")
44 static inline PCI_IO_ADDR celleb_epci_get_epci_base(
53 return hose->cfg_addr;
56 static inline PCI_IO_ADDR celleb_epci_get_epci_cfg(
65 return hose->cfg_data;
68 static inline void clear_and_disable_master_abort_interrupt(
71 PCI_IO_ADDR epci_base;
73 epci_base = celleb_epci_get_epci_base(hose);
82 PCI_IO_ADDR epci_base;
86 epci_base = celleb_epci_get_epci_base(hose);
112 static PCI_IO_ADDR celleb_epci_make_config_addr(
struct pci_bus *
bus,
117 if (bus != hose->bus)
118 addr = celleb_epci_get_epci_cfg(hose) +
119 (((bus->
number & 0xff) << 16)
120 | ((devfn & 0xff) << 8)
124 addr = celleb_epci_get_epci_cfg(hose) +
125 (((devfn & 0xff) << 8) | (where & 0xff));
127 pr_debug(
"EPCI: config_addr = 0x%p\n", addr);
132 static int celleb_epci_read_config(
struct pci_bus *bus,
133 unsigned int devfn,
int where,
int size,
u32 *val)
135 PCI_IO_ADDR epci_base;
142 if (!celleb_epci_get_epci_cfg(hose))
148 epci_base = celleb_epci_get_epci_base(hose);
149 addr = epci_base + where;
167 clear_and_disable_master_abort_interrupt(hose);
168 addr = celleb_epci_make_config_addr(bus, hose, devfn, where);
186 "addr=0x%p, devfn=0x%x, where=0x%x, size=0x%x, val=0x%x\n",
187 addr, devfn, where, size, *val);
189 return celleb_epci_check_abort(hose,
NULL);
192 static int celleb_epci_write_config(
struct pci_bus *bus,
193 unsigned int devfn,
int where,
int size,
u32 val)
195 PCI_IO_ADDR epci_base;
202 if (!celleb_epci_get_epci_cfg(hose))
208 epci_base = celleb_epci_get_epci_base(hose);
209 addr = epci_base + where;
227 clear_and_disable_master_abort_interrupt(hose);
228 addr = celleb_epci_make_config_addr(bus, hose, devfn, where);
245 return celleb_epci_check_abort(hose, addr);
249 .read = celleb_epci_read_config,
250 .write = celleb_epci_write_config,
258 PCI_IO_ADDR epci_base;
261 epci_base = celleb_epci_get_epci_base(hose);
266 if (val == 0x00030101)
380 pr_debug(
"PCI: celleb_setup_epci()\n");
396 hose->cfg_addr =
ioremap(
r.start, resource_size(&
r));
399 pr_debug(
"EPCI: cfg_addr map 0x%016llx->0x%016lx + 0x%016llx\n",
400 r.start, (
unsigned long)hose->cfg_addr, resource_size(&
r));
404 hose->cfg_data =
ioremap(
r.start, resource_size(&
r));
407 pr_debug(
"EPCI: cfg_data map 0x%016llx->0x%016lx + 0x%016llx\n",
408 r.start, (
unsigned long)hose->cfg_data, resource_size(&
r));
411 celleb_epci_init(hose);
425 .setup = celleb_setup_epci,
428 .iowa_data = (
void *)0,