2 * arch/arm/mach-iop3xx/iq80331-pci.c
4 * PCI support for the Intel IQ80331 reference board
6 * Author: Dave Jiang <dave.jiang@intel.com>
7 * Copyright (C) 2003 Intel Corp.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/pci.h>
15 #include <linux/init.h>
17 #include <asm/hardware.h>
19 #include <asm/mach/pci.h>
20 #include <asm/mach-types.h>
23 * The following macro is used to lookup irqs in a standard table
24 * format for those systems that do not already have PCI
25 * interrupts properly routed. We assume 1 <= pin <= 4
27 #define PCI_IRQ_TABLE_LOOKUP(minid,maxid) \
29 unsigned int _idsel = idsel - minid; \
30 if (_idsel <= maxid) \
31 _ctl_ = pci_irq_table[_idsel][pin-1]; \
34 #define INTA IRQ_IQ80331_INTA
35 #define INTB IRQ_IQ80331_INTB
36 #define INTC IRQ_IQ80331_INTC
37 #define INTD IRQ_IQ80331_INTD
39 //#define INTE IRQ_IQ80331_I82544
41 static inline int __init
42 iq80331_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
44 static int pci_irq_table[][4] = {
46 * PCI IDSEL/INTPIN->INTLINE
49 {INTB, INTC, INTD, INTA}, /* PCI-X Slot */
50 {INTC, INTC, INTC, INTC}, /* GigE */
53 BUG_ON(pin < 1 || pin > 4);
55 return PCI_IRQ_TABLE_LOOKUP(1, 7);
58 static int iq80331_setup(int nr, struct pci_sys_data *sys)
65 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
67 panic("PCI: unable to alloc resources");
69 memset(res, 0, sizeof(struct resource) * 2);
71 res[0].start = IQ80331_PCI_IO_BASE + 0x6e000000;
72 res[0].end = IQ80331_PCI_IO_BASE + IQ80331_PCI_IO_SIZE - 1 + IQ80331_PCI_IO_OFFSET;
73 res[0].name = "IQ80331 PCI I/O Space";
74 res[0].flags = IORESOURCE_IO;
76 res[1].start = IQ80331_PCI_MEM_BASE;
77 res[1].end = IQ80331_PCI_MEM_BASE + IQ80331_PCI_MEM_SIZE;
78 res[1].name = "IQ80331 PCI Memory Space";
79 res[1].flags = IORESOURCE_MEM;
81 request_resource(&ioport_resource, &res[0]);
82 request_resource(&iomem_resource, &res[1]);
85 * Since the IQ80331 is a slave card on a PCI backplane,
86 * it uses BAR1 to reserve a portion of PCI memory space for
87 * use with the private devices on the secondary bus
88 * (GigE and PCI-X slot). We read BAR1 and configure
89 * our outbound translation windows to target that
90 * address range and assign all devices in that
91 * address range. W/O this, certain BIOSes will fail
92 * to boot as the IQ80331 claims addresses that are
93 * in use by other devices.
95 * Note that the same cannot be done with I/O space,
96 * so hopefully the host will stick to the lower 64K for
97 * PCI I/O and leave us alone.
99 sys->mem_offset = IQ80331_PCI_MEM_BASE -
100 (*IOP331_IABAR1 & PCI_BASE_ADDRESS_MEM_MASK);
102 sys->resource[0] = &res[0];
103 sys->resource[1] = &res[1];
104 sys->resource[2] = NULL;
105 sys->io_offset = IQ80331_PCI_IO_OFFSET;
107 iop3xx_pcibios_min_io = IQ80331_PCI_IO_BASE;
108 iop3xx_pcibios_min_mem = IQ80331_PCI_MEM_BASE;
113 static void iq80331_preinit(void)
118 static struct hw_pci iq80331_pci __initdata = {
119 .swizzle = pci_std_swizzle,
121 .setup = iq80331_setup,
122 .scan = iop331_scan_bus,
123 .preinit = iq80331_preinit,
124 .map_irq = iq80331_map_irq
127 static int __init iq80331_pci_init(void)
129 if (machine_is_iq80331())
130 pci_common_init(&iq80331_pci);
134 subsys_initcall(iq80331_pci_init);