allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / powerpc / platforms / 85xx / pci.c
blob48f17e23d771ff0492f8dc9cc46efc753f420555
1 /*
2 * FSL SoC setup code
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
12 #include <linux/stddef.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/errno.h>
16 #include <linux/pci.h>
17 #include <linux/delay.h>
18 #include <linux/irq.h>
19 #include <linux/module.h>
21 #include <asm/system.h>
22 #include <asm/atomic.h>
23 #include <asm/io.h>
24 #include <asm/pci-bridge.h>
25 #include <asm/prom.h>
26 #include <sysdev/fsl_soc.h>
28 #undef DEBUG
30 #ifdef DEBUG
31 #define DBG(x...) printk(x)
32 #else
33 #define DBG(x...)
34 #endif
36 int mpc85xx_pci2_busno = 0;
38 #ifdef CONFIG_PCI
39 int __init add_bridge(struct device_node *dev)
41 int len;
42 struct pci_controller *hose;
43 struct resource rsrc;
44 const int *bus_range;
45 int primary = 1, has_address = 0;
46 phys_addr_t immr = get_immrbase();
48 DBG("Adding PCI host bridge %s\n", dev->full_name);
50 /* Fetch host bridge registers address */
51 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
53 /* Get bus range if any */
54 bus_range = of_get_property(dev, "bus-range", &len);
55 if (bus_range == NULL || len < 2 * sizeof(int)) {
56 printk(KERN_WARNING "Can't get bus-range for %s, assume"
57 " bus 0\n", dev->full_name);
60 hose = pcibios_alloc_controller();
61 if (!hose)
62 return -ENOMEM;
63 hose->arch_data = dev;
64 hose->set_cfg_type = 1;
66 hose->first_busno = bus_range ? bus_range[0] : 0;
67 hose->last_busno = bus_range ? bus_range[1] : 0xff;
69 /* PCI 1 */
70 if ((rsrc.start & 0xfffff) == 0x8000) {
71 setup_indirect_pci(hose, immr + 0x8000, immr + 0x8004);
73 /* PCI 2 */
74 if ((rsrc.start & 0xfffff) == 0x9000) {
75 setup_indirect_pci(hose, immr + 0x9000, immr + 0x9004);
76 primary = 0;
77 hose->bus_offset = hose->first_busno;
78 mpc85xx_pci2_busno = hose->first_busno;
81 printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%016llx. "
82 "Firmware bus number: %d->%d\n",
83 (unsigned long long)rsrc.start, hose->first_busno,
84 hose->last_busno);
86 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
87 hose, hose->cfg_addr, hose->cfg_data);
89 /* Interpret the "ranges" property */
90 /* This also maps the I/O region and sets isa_io/mem_base */
91 pci_process_bridge_OF_ranges(hose, dev, primary);
93 return 0;
96 #endif