Pull sbs into release branch
[pandora-kernel.git] / arch / powerpc / platforms / 85xx / pci.c
1 /*
2  * FSL SoC setup code
3  *
4  * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5  *
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.
10  */
11
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>
20
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>
27
28 #undef DEBUG
29
30 #ifdef DEBUG
31 #define DBG(x...) printk(x)
32 #else
33 #define DBG(x...)
34 #endif
35
36 #ifdef CONFIG_PCI
37 int __init mpc85xx_add_bridge(struct device_node *dev)
38 {
39         int len;
40         struct pci_controller *hose;
41         struct resource rsrc;
42         const int *bus_range;
43         int primary = 1, has_address = 0;
44         phys_addr_t immr = get_immrbase();
45
46         DBG("Adding PCI host bridge %s\n", dev->full_name);
47
48         /* Fetch host bridge registers address */
49         has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
50
51         /* Get bus range if any */
52         bus_range = of_get_property(dev, "bus-range", &len);
53         if (bus_range == NULL || len < 2 * sizeof(int)) {
54                 printk(KERN_WARNING "Can't get bus-range for %s, assume"
55                        " bus 0\n", dev->full_name);
56         }
57
58         pci_assign_all_buses = 1;
59         hose = pcibios_alloc_controller(dev);
60         if (!hose)
61                 return -ENOMEM;
62
63         hose->first_busno = bus_range ? bus_range[0] : 0;
64         hose->last_busno = bus_range ? bus_range[1] : 0xff;
65
66         /* PCI 1 */
67         if ((rsrc.start & 0xfffff) == 0x8000) {
68                 setup_indirect_pci(hose, immr + 0x8000, immr + 0x8004);
69         }
70         /* PCI 2 */
71         if ((rsrc.start & 0xfffff) == 0x9000) {
72                 setup_indirect_pci(hose, immr + 0x9000, immr + 0x9004);
73                 primary = 0;
74         }
75
76         printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%016llx. "
77                "Firmware bus number: %d->%d\n",
78                 (unsigned long long)rsrc.start, hose->first_busno,
79                 hose->last_busno);
80
81         DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
82                 hose, hose->cfg_addr, hose->cfg_data);
83
84         /* Interpret the "ranges" property */
85         /* This also maps the I/O region and sets isa_io/mem_base */
86         pci_process_bridge_OF_ranges(hose, dev, primary);
87
88         return 0;
89 }
90
91 #endif