20 #include <linux/pci.h>
21 #include <linux/slab.h>
24 #include <linux/export.h>
26 #include <mach/hardware.h>
27 #include <asm/sizes.h>
28 #include <asm/signal.h>
32 #define IOP13XX_PCI_DEBUG 0
33 #define PRINTK(x...) ((void)(IOP13XX_PCI_DEBUG && printk(x)))
37 static struct pci_bus *pci_bus_atux = 0;
38 static struct pci_bus *pci_bus_atue = 0;
50 static unsigned long atux_trhfa_timeout = 0;
62 for (atu = 0; atu < 2; atu++) {
63 bus = atu ? pci_bus_atue : pci_bus_atux;
72 for (i = 0; i <
max; i++) {
95 printk(
"%s: atux allocation "
96 "failed\n", __func__);
101 PRINTK(
"%s: atu: %d bus_size: %d mem_base: %p\n",
120 printk(
"%s: atue allocation "
121 "failed\n", __func__);
126 PRINTK(
"%s: atu: %d bus_size: %d mem_base: %p\n",
132 printk(
"%s: Initialized (%uM @ resource/virtual: %08lx/%p)\n",
133 atu ?
"ATUE" :
"ATUX",
146 static int iop13xx_atu_function(
int atu)
191 addr |=
PCI_FUNC(devfn) << 8 | ((where & 0xff) & ~3);
192 addr |= ((where & 0xf00) >> 8) << 24;
204 static u32 iop13xx_atue_cfg_address(
struct pci_bus *bus,
int devfn,
int where)
209 PRINTK(
"iop13xx_atue_cfg_address: bus: %d dev: %d func: %d",
228 static int iop13xx_atux_pci_status(
int clear)
239 PRINTK(
"\t\t\tPCI error: ATUSR %#08x", status);
248 PRINTK(
"\t\t\tPCI error interrupt: ATUISR %#08x", status);
261 static u32 iop13xx_atux_read(
unsigned long addr)
279 iop13xx_atux_read_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
282 unsigned long addr = iop13xx_atux_cfg_address(bus, devfn, where);
283 u32 val = iop13xx_atux_read(addr) >> ((where & 3) * 8);
297 iop13xx_atux_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
300 unsigned long addr = iop13xx_atux_cfg_address(bus, devfn, where);
304 val = iop13xx_atux_read(addr);
305 if (!iop13xx_atux_pci_status(1) == 0)
308 where = (where & 3) * 8;
311 val &= ~(0xff << where);
313 val &= ~(0xffff << where);
324 static struct pci_ops iop13xx_atux_ops = {
325 .read = iop13xx_atux_read_config,
326 .write = iop13xx_atux_write_config,
335 static int iop13xx_atue_pci_status(
int clear)
346 if (status & IOP_PCI_STATUS_ERROR) {
347 PRINTK(
"\t\t\tPCI error: ATUSR %#08x", status);
357 PRINTK(
"\t\t\tPCI error: ATUISR %#08x", status);
370 PRINTK(
"\t\t\tPCI-E error: ATUE_PIE_STS %#08x",
374 PRINTK(
"\t\t\tPCI-E error: ATUE_PIE_STS %#08x",
376 PRINTK(
"\t\t\tPCI-E error: ATUE_PIE_MSK %#08x",
403 static u32 iop13xx_atue_read(
unsigned long addr)
419 iop13xx_atue_read_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
420 int size,
u32 *value)
423 unsigned long addr = iop13xx_atue_cfg_address(bus, devfn, where);
426 if (!
PCI_SLOT(devfn) || (addr & 1)) {
427 val = iop13xx_atue_read(addr) >> ((where & 3) * 8);
434 PRINTK(
"addr=%#0lx, val=%#010x", addr, val);
444 iop13xx_atue_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
447 unsigned long addr = iop13xx_atue_cfg_address(bus, devfn, where);
451 val = iop13xx_atue_read(addr);
452 if (!iop13xx_atue_pci_status(1) == 0)
455 where = (where & 3) * 8;
458 val &= ~(0xff << where);
460 val &= ~(0xffff << where);
471 static struct pci_ops iop13xx_atue_ops = {
472 .read = iop13xx_atue_read_config,
473 .write = iop13xx_atue_write_config,
485 PRINTK(
"Data abort: address = 0x%08lx "
486 "fsr = 0x%03x PC = 0x%08lx LR = 0x%08lx",
487 addr, fsr, regs->ARM_pc, regs->ARM_lr);
561 #ifdef CONFIG_PCI_MSI
601 iop13xx_atue_pci_status(1);
722 msec = 1000 / (8-
msec);
730 #ifdef CONFIG_PCI_MSI
770 iop13xx_atux_pci_status(1);
897 case IOP13XX_INTERFACE_SEL_PCIX:
959 for (i = 0; i < 2; i++) {
960 if((
init_atu & (1 << i)) == (1 << i))
988 "imprecise external abort");
1005 panic(
"PCI: unable to alloc resources");
1046 res->
name =
"IQ81340 ATUX PCI Memory Space";
1053 pcsr &= ~(0xfff8 << 16);
1063 res->
name =
"IQ81340 ATUE PCI Memory Space";
1066 sys->
map_irq = iop13xx_pcie_map_irq;
1088 static int __init iop13xx_init_atu_setup(
char *
str)
1092 while (*str !=
'\0') {
1108 PRINTK(
"\"iop13xx_init_atu\" malformed at "
1109 "character: \'%c\'", *str);
1119 __setup(
"iop13xx_init_atu", iop13xx_init_atu_setup);