Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney...
[pandora-kernel.git] / arch / powerpc / platforms / 52xx / mpc52xx_pci.c
index 34d34a2..5a382bb 100644 (file)
@@ -63,6 +63,7 @@
 
 #define MPC52xx_PCI_TCR_P              0x01000000
 #define MPC52xx_PCI_TCR_LD             0x00010000
+#define MPC52xx_PCI_TCR_WCT8           0x00000008
 
 #define MPC52xx_PCI_TBATR_DISABLE      0x0
 #define MPC52xx_PCI_TBATR_ENABLE       0x1
@@ -99,6 +100,12 @@ struct mpc52xx_pci {
        u8      reserved6[4];   /* PCI + 0xFC */
 };
 
+/* MPC5200 device tree match tables */
+const struct of_device_id mpc52xx_pci_ids[] __initdata = {
+       { .type = "pci", .compatible = "fsl,mpc5200-pci", },
+       { .type = "pci", .compatible = "mpc5200-pci", },
+       {}
+};
 
 /* ======================================================================== */
 /* PCI configuration acess                                                  */
@@ -112,18 +119,18 @@ mpc52xx_pci_read_config(struct pci_bus *bus, unsigned int devfn,
        u32 value;
 
        if (ppc_md.pci_exclude_device)
-               if (ppc_md.pci_exclude_device(bus->number, devfn))
+               if (ppc_md.pci_exclude_device(hose, bus->number, devfn))
                        return PCIBIOS_DEVICE_NOT_FOUND;
 
        out_be32(hose->cfg_addr,
                (1 << 31) |
-               ((bus->number - hose->bus_offset) << 16) |
+               (bus->number << 16) |
                (devfn << 8) |
                (offset & 0xfc));
        mb();
 
 #if defined(CONFIG_PPC_MPC5200_BUGFIX)
-       if (bus->number != hose->bus_offset) {
+       if (bus->number) {
                /* workaround for the bug 435 of the MPC5200 (L25R);
                 * Don't do 32 bits config access during type-1 cycles */
                switch (len) {
@@ -169,18 +176,18 @@ mpc52xx_pci_write_config(struct pci_bus *bus, unsigned int devfn,
        u32 value, mask;
 
        if (ppc_md.pci_exclude_device)
-               if (ppc_md.pci_exclude_device(bus->number, devfn))
+               if (ppc_md.pci_exclude_device(hose, bus->number, devfn))
                        return PCIBIOS_DEVICE_NOT_FOUND;
 
        out_be32(hose->cfg_addr,
                (1 << 31) |
-               ((bus->number - hose->bus_offset) << 16) |
+               (bus->number << 16) |
                (devfn << 8) |
                (offset & 0xfc));
        mb();
 
 #if defined(CONFIG_PPC_MPC5200_BUGFIX)
-       if (bus->number != hose->bus_offset) {
+       if (bus->number) {
                /* workaround for the bug 435 of the MPC5200 (L25R);
                 * Don't do 32 bits config access during type-1 cycles */
                switch (len) {
@@ -307,7 +314,7 @@ mpc52xx_pci_setup(struct pci_controller *hose,
        out_be32(&pci_regs->tbatr1,
                MPC52xx_PCI_TBATR_ENABLE | MPC52xx_PCI_TARGET_MEM );
 
-       out_be32(&pci_regs->tcr, MPC52xx_PCI_TCR_LD);
+       out_be32(&pci_regs->tcr, MPC52xx_PCI_TCR_LD | MPC52xx_PCI_TCR_WCT8);
 
        tmp = in_be32(&pci_regs->gscr);
 #if 0
@@ -363,7 +370,7 @@ mpc52xx_add_bridge(struct device_node *node)
 
        pr_debug("Adding MPC52xx PCI host bridge %s\n", node->full_name);
 
-       pci_assign_all_buses = 1;
+       ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
 
        if (of_address_to_resource(node, 0, &rsrc) != 0) {
                printk(KERN_ERR "Can't get %s resources\n", node->full_name);
@@ -385,17 +392,13 @@ mpc52xx_add_bridge(struct device_node *node)
         * tree are needed to configure the 52xx PCI controller.  Rather
         * than parse the tree here, let pci_process_bridge_OF_ranges()
         * do it for us and extract the values after the fact */
-       hose = pcibios_alloc_controller();
+       hose = pcibios_alloc_controller(node);
        if (!hose)
                return -ENOMEM;
 
-       hose->arch_data = node;
-       hose->set_cfg_type = 1;
-
        hose->first_busno = bus_range ? bus_range[0] : 0;
        hose->last_busno = bus_range ? bus_range[1] : 0xff;
 
-       hose->bus_offset = 0;
        hose->ops = &mpc52xx_pci_ops;
 
        pci_regs = ioremap(rsrc.start, rsrc.end - rsrc.start + 1);
@@ -410,3 +413,15 @@ mpc52xx_add_bridge(struct device_node *node)
 
        return 0;
 }
+
+void __init mpc52xx_setup_pci(void)
+{
+       struct device_node *pci;
+
+       pci = of_find_matching_node(NULL, mpc52xx_pci_ids);
+       if (!pci)
+               return;
+
+       mpc52xx_add_bridge(pci);
+       of_node_put(pci);
+}