18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/pci.h>
25 #include <linux/slab.h>
27 #include <linux/device.h>
29 #include <linux/export.h>
30 #include <asm/dma-mapping.h>
32 #include <asm/cputype.h>
34 #include <asm/sizes.h>
36 #include <mach/hardware.h>
83 static inline int check_master_abort(
void)
112 for (i = 0; i < 8; i++) {
118 if(check_master_abort())
140 if(check_master_abort())
162 if(check_master_abort())
169 static u32 ixp4xx_config_addr(
u8 bus_num,
u16 devfn,
int where)
178 addr = (bus_num << 16) | ((
PCI_SLOT(devfn)) << 11) |
179 ((
PCI_FUNC(devfn)) << 8) | (where & ~3) | 1;
188 static u32 bytemask[] = {
196 static u32 local_byte_lane_enable_bits(
u32 n,
int size)
207 static int local_read_config(
int where,
int size,
u32 *
value)
210 pr_debug(
"local_read_config from %d size %d\n", where, size);
212 crp_read(where & ~3, &data);
213 *value = (data >> (8*
n)) & bytemask[
size];
214 pr_debug(
"local_read_config read %#x\n", *value);
218 static int local_write_config(
int where,
int size,
u32 value)
221 pr_debug(
"local_write_config %#x to %d size %d\n", value, where, size);
223 byte_enables = local_byte_lane_enable_bits(n, size);
224 if (byte_enables == 0xffffffff)
226 data = value << (8*
n);
227 crp_write((where & ~3) | byte_enables, data);
231 static u32 byte_lane_enable_bits(
u32 n,
int size)
234 return (0xf & ~
BIT(n)) << 4;
236 return (0xf & ~(
BIT(n) |
BIT(n+1))) << 4;
242 static int ixp4xx_pci_read_config(
struct pci_bus *
bus,
unsigned int devfn,
int where,
int size,
u32 *value)
247 pr_debug(
"read_config from %d size %d dev %d:%d:%d\n", where, size,
252 byte_enables = byte_lane_enable_bits(n, size);
253 if (byte_enables == 0xffffffff)
256 addr = ixp4xx_config_addr(bus_num, devfn, where);
260 *value = (data >> (8*
n)) & bytemask[
size];
261 pr_debug(
"read_config_byte read %#x\n", *value);
265 static int ixp4xx_pci_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
int size,
u32 value)
270 pr_debug(
"write_config_byte %#x to %d size %d dev %d:%d:%d\n", value, where,
274 byte_enables = byte_lane_enable_bits(n, size);
275 if (byte_enables == 0xffffffff)
278 addr = ixp4xx_config_addr(bus_num, devfn, where);
279 data = value << (8*
n);
287 .read = ixp4xx_pci_read_config,
288 .write = ixp4xx_pci_write_config,
294 static int abort_handler(
unsigned long addr,
unsigned int fsr,
struct pt_regs *
regs)
300 pr_debug(
"PCI: abort_handler addr = %#lx, isr = %#x, "
301 "status = %#x\n", addr, isr, status);
321 return (dma_addr + size) >=
SZ_64M;
327 static int ixp4xx_pci_platform_notify(
struct device *dev)
337 static int ixp4xx_pci_platform_notify_remove(
struct device *dev)
347 unsigned long cpuid = read_cpuid_id();
349 #ifdef CONFIG_IXP4XX_INDIRECT_PCI
350 pcibios_min_mem = 0x10000000;
352 pcibios_min_mem = 0x48000000;
359 printk(
"PCI: IXP42x A0 silicon detected - "
360 "PCI Non-Prefetch Workaround Enabled\n");
368 "imprecise external abort");
370 pr_debug(
"setup PCI-AHB(inbound) and AHB-PCI(outbound) address mappings\n");
389 printk(
"PCI: IXP4xx is host\n");
391 pr_debug(
"setup BARs in controller\n");
413 local_write_config(0x40, 4, 0x000080FF);
415 printk(
"PCI: IXP4xx is target - No bus scan performed\n");
418 printk(
"PCI: IXP4xx Using %s access for memory space\n",
419 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
426 pr_debug(
"clear error bits in ISR\n");
457 panic(
"PCI: unable to allocate resources?\n");
462 res[0].
name =
"PCI I/O Space";
463 res[0].
start = 0x00000000;
464 res[0].
end = 0x0000ffff;
467 res[1].
name =
"PCI Memory Space";