]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/pci/fsl_pci_init.c
Merge branch 'master' of git://git.denx.de/u-boot-samsung
[karo-tx-uboot.git] / drivers / pci / fsl_pci_init.c
index fe57926d7ea66bb8250c4e5942c2379f19e26c0b..5b34dcbb0fe9dac70feee9594e393832e2634d65 100644 (file)
@@ -1,9 +1,10 @@
 /*
- * Copyright 2007-2009 Freescale Semiconductor, Inc.
+ * Copyright 2007-2010 Freescale Semiconductor, Inc.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * Version 2 as published by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -90,6 +91,9 @@ int fsl_setup_hose(struct pci_controller *hose, unsigned long addr)
 {
        volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) addr;
 
+       /* Reset hose to make sure its in a clean state */
+       memset(hose, 0, sizeof(struct pci_controller));
+
        pci_setup_indirect(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
 
        return fsl_is_pci_agent(hose);
@@ -387,11 +391,11 @@ void fsl_pci_init(struct pci_controller *hose, u32 cfg_addr, u32 cfg_data)
         * 1 == pci agent or pcie end-point
         */
        if (!temp8) {
-               printf("               Scanning PCI bus %02x\n",
+               debug("           Scanning PCI bus %02x\n",
                        hose->current_busno);
                hose->last_busno = pci_hose_scan_bus(hose, hose->current_busno);
        } else {
-               debug("               Not scanning PCI bus %02x. PI=%x\n",
+               debug("           Not scanning PCI bus %02x. PI=%x\n",
                        hose->current_busno, temp8);
                hose->last_busno = hose->current_busno;
        }
@@ -437,6 +441,8 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
 {
        volatile ccsr_fsl_pci_t *pci;
        struct pci_region *r;
+       pci_dev_t dev = PCI_BDF(busno,0,0);
+       u8 pcie_cap;
 
        pci = (ccsr_fsl_pci_t *) pci_info->regs;
 
@@ -475,8 +481,10 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
                hose->last_busno = hose->first_busno;
        }
 
-       printf("    PCIE%x on bus %02x - %02x\n", pci_info->pci_num,
-                       hose->first_busno, hose->last_busno);
+       pci_hose_read_config_byte(hose, dev, FSL_PCIE_CAP_ID, &pcie_cap);
+       printf("PCI%s%x: Bus %02x - %02x\n", pcie_cap == PCI_CAP_ID_EXP ?
+               "E" : "", pci_info->pci_num,
+               hose->first_busno, hose->last_busno);
 
        return(hose->last_busno + 1);
 }
@@ -509,14 +517,26 @@ void fsl_pci_config_unlock(struct pci_controller *hose)
 #include <libfdt.h>
 #include <fdt_support.h>
 
-void ft_fsl_pci_setup(void *blob, const char *pci_alias,
-                       struct pci_controller *hose)
+void ft_fsl_pci_setup(void *blob, const char *pci_compat,
+                       struct pci_controller *hose, unsigned long ctrl_addr)
 {
-       int off = fdt_path_offset(blob, pci_alias);
+       int off;
+       u32 bus_range[2];
+       phys_addr_t p_ctrl_addr = (phys_addr_t)ctrl_addr;
+
+       /* convert ctrl_addr to true physical address */
+       p_ctrl_addr = (phys_addr_t)ctrl_addr - CONFIG_SYS_CCSRBAR;
+       p_ctrl_addr += CONFIG_SYS_CCSRBAR_PHYS;
 
-       if (off >= 0) {
-               u32 bus_range[2];
+       off = fdt_node_offset_by_compat_reg(blob, pci_compat, p_ctrl_addr);
 
+       if (off < 0)
+               return;
+
+       /* We assume a cfg_addr not being set means we didn't setup the controller */
+       if ((hose == NULL) || (hose->cfg_addr == NULL)) {
+               fdt_del_node(blob, off);
+       } else {
                bus_range[0] = 0;
                bus_range[1] = hose->last_busno - hose->first_busno;
                fdt_setprop(blob, off, "bus-range", &bus_range[0], 2*4);