]> git.sur5r.net Git - u-boot/blobdiff - drivers/pci/pci_auto_old.c
powerpc: MPC8541CDS: Remove macro CONFIG_MPC8541CDS
[u-boot] / drivers / pci / pci_auto_old.c
index 0412bf3515f8e905d98ee79096e36f56149e3170..edc9a7b3c1704eb7d222a1c1ee6ce5fd3db55726 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * arch/powerpc/kernel/pci_auto.c
- *
- * PCI autoconfiguration library
+ * PCI autoconfiguration library (legacy version, do not change)
  *
  * Author: Matt Porter <mporter@mvista.com>
  *
 #include <errno.h>
 #include <pci.h>
 
+/*
+ * Do not change this file. Instead, convert your board to use CONFIG_DM_PCI
+ * and change pci_auto.c.
+ */
+
 /* the user can define CONFIG_SYS_PCI_CACHE_LINE_SIZE to avoid problems */
 #ifndef CONFIG_SYS_PCI_CACHE_LINE_SIZE
 #define CONFIG_SYS_PCI_CACHE_LINE_SIZE 8
 #endif
 
-/*
- *
- */
-
-void pciauto_region_init(struct pci_region *res)
-{
-       /*
-        * Avoid allocating PCI resources from address 0 -- this is illegal
-        * according to PCI 2.1 and moreover, this is known to cause Linux IDE
-        * drivers to fail. Use a reasonable starting value of 0x1000 instead.
-        */
-       res->bus_lower = res->bus_start ? res->bus_start : 0x1000;
-}
-
-void pciauto_region_align(struct pci_region *res, pci_size_t size)
-{
-       res->bus_lower = ((res->bus_lower - 1) | (size - 1)) + 1;
-}
-
-int pciauto_region_allocate(struct pci_region *res, pci_size_t size,
-       pci_addr_t *bar)
-{
-       pci_addr_t addr;
-
-       if (!res) {
-               debug("No resource");
-               goto error;
-       }
-
-       addr = ((res->bus_lower - 1) | (size - 1)) + 1;
-
-       if (addr - res->bus_start + size > res->size) {
-               debug("No room in resource");
-               goto error;
-       }
-
-       res->bus_lower = addr + size;
-
-       debug("address=0x%llx bus_lower=0x%llx", (unsigned long long)addr,
-             (unsigned long long)res->bus_lower);
-
-       *bar = addr;
-       return 0;
-
- error:
-       *bar = (pci_addr_t)-1;
-       return -1;
-}
-
 /*
  *
  */
@@ -147,11 +101,11 @@ void pciauto_setup_device(struct pci_controller *hose,
                                bar_res = prefetch;
                        else
                                bar_res = mem;
-#endif
 
                        debug("PCI Autoconfig: BAR %d, %s, size=0x%llx, ",
                              bar_nr, bar_res == prefetch ? "Prf" : "Mem",
                              (unsigned long long)bar_size);
+#endif
                }
 
 #ifndef CONFIG_PCI_ENUM_ONLY
@@ -226,18 +180,9 @@ void pciauto_prescan_setup_bridge(struct pci_controller *hose,
        struct pci_region *pci_io;
        u16 cmdstat, prefechable_64;
 
-#ifdef CONFIG_DM_PCI
-       /* The root controller has the region information */
-       struct pci_controller *ctlr_hose = pci_bus_to_hose(0);
-
-       pci_mem = ctlr_hose->pci_mem;
-       pci_prefetch = ctlr_hose->pci_prefetch;
-       pci_io = ctlr_hose->pci_io;
-#else
        pci_mem = hose->pci_mem;
        pci_prefetch = hose->pci_prefetch;
        pci_io = hose->pci_io;
-#endif
 
        pci_hose_read_config_word(hose, dev, PCI_COMMAND, &cmdstat);
        pci_hose_read_config_word(hose, dev, PCI_PREF_MEMORY_BASE,
@@ -245,15 +190,10 @@ void pciauto_prescan_setup_bridge(struct pci_controller *hose,
        prefechable_64 &= PCI_PREF_RANGE_TYPE_MASK;
 
        /* Configure bus number registers */
-#ifdef CONFIG_DM_PCI
-       pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS, PCI_BUS(dev));
-       pci_hose_write_config_byte(hose, dev, PCI_SECONDARY_BUS, sub_bus);
-#else
        pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS,
                                   PCI_BUS(dev) - hose->first_busno);
        pci_hose_write_config_byte(hose, dev, PCI_SECONDARY_BUS,
                                   sub_bus - hose->first_busno);
-#endif
        pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, 0xff);
 
        if (pci_mem) {
@@ -320,26 +260,13 @@ void pciauto_postscan_setup_bridge(struct pci_controller *hose,
        struct pci_region *pci_prefetch;
        struct pci_region *pci_io;
 
-#ifdef CONFIG_DM_PCI
-       /* The root controller has the region information */
-       struct pci_controller *ctlr_hose = pci_bus_to_hose(0);
-
-       pci_mem = ctlr_hose->pci_mem;
-       pci_prefetch = ctlr_hose->pci_prefetch;
-       pci_io = ctlr_hose->pci_io;
-#else
        pci_mem = hose->pci_mem;
        pci_prefetch = hose->pci_prefetch;
        pci_io = hose->pci_io;
-#endif
 
        /* Configure bus number registers */
-#ifdef CONFIG_DM_PCI
-       pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, sub_bus);
-#else
        pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS,
                                   sub_bus - hose->first_busno);
-#endif
 
        if (pci_mem) {
                /* Round memory allocator to 1MB boundary */
@@ -385,73 +312,6 @@ void pciauto_postscan_setup_bridge(struct pci_controller *hose,
        }
 }
 
-/*
- *
- */
-
-void pciauto_config_init(struct pci_controller *hose)
-{
-       int i;
-
-       hose->pci_io = hose->pci_mem = hose->pci_prefetch = NULL;
-
-       for (i = 0; i < hose->region_count; i++) {
-               switch(hose->regions[i].flags) {
-               case PCI_REGION_IO:
-                       if (!hose->pci_io ||
-                           hose->pci_io->size < hose->regions[i].size)
-                               hose->pci_io = hose->regions + i;
-                       break;
-               case PCI_REGION_MEM:
-                       if (!hose->pci_mem ||
-                           hose->pci_mem->size < hose->regions[i].size)
-                               hose->pci_mem = hose->regions + i;
-                       break;
-               case (PCI_REGION_MEM | PCI_REGION_PREFETCH):
-                       if (!hose->pci_prefetch ||
-                           hose->pci_prefetch->size < hose->regions[i].size)
-                               hose->pci_prefetch = hose->regions + i;
-                       break;
-               }
-       }
-
-
-       if (hose->pci_mem) {
-               pciauto_region_init(hose->pci_mem);
-
-               debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n"
-                      "\t\tPhysical Memory [%llx-%llxx]\n",
-                   (u64)hose->pci_mem->bus_start,
-                   (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1),
-                   (u64)hose->pci_mem->phys_start,
-                   (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1));
-       }
-
-       if (hose->pci_prefetch) {
-               pciauto_region_init(hose->pci_prefetch);
-
-               debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n"
-                      "\t\tPhysical Memory [%llx-%llx]\n",
-                   (u64)hose->pci_prefetch->bus_start,
-                   (u64)(hose->pci_prefetch->bus_start +
-                           hose->pci_prefetch->size - 1),
-                   (u64)hose->pci_prefetch->phys_start,
-                   (u64)(hose->pci_prefetch->phys_start +
-                           hose->pci_prefetch->size - 1));
-       }
-
-       if (hose->pci_io) {
-               pciauto_region_init(hose->pci_io);
-
-               debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n"
-                      "\t\tPhysical Memory: [%llx-%llx]\n",
-                   (u64)hose->pci_io->bus_start,
-                   (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1),
-                   (u64)hose->pci_io->phys_start,
-                   (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1));
-
-       }
-}
 
 /*
  * HJF: Changed this to return int. I think this is required
@@ -466,18 +326,9 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
        unsigned short class;
        int n;
 
-#ifdef CONFIG_DM_PCI
-       /* The root controller has the region information */
-       struct pci_controller *ctlr_hose = pci_bus_to_hose(0);
-
-       pci_mem = ctlr_hose->pci_mem;
-       pci_prefetch = ctlr_hose->pci_prefetch;
-       pci_io = ctlr_hose->pci_io;
-#else
        pci_mem = hose->pci_mem;
        pci_prefetch = hose->pci_prefetch;
        pci_io = hose->pci_io;
-#endif
 
        pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class);
 
@@ -489,12 +340,6 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
                pciauto_setup_device(hose, dev, 2, pci_mem,
                                     pci_prefetch, pci_io);
 
-#ifdef CONFIG_DM_PCI
-               n = dm_pci_hose_probe_bus(hose, dev);
-               if (n < 0)
-                       return n;
-               sub_bus = (unsigned int)n;
-#else
                /* Passing in current_busno allows for sibling P2P bridges */
                hose->current_busno++;
                pciauto_prescan_setup_bridge(hose, dev, hose->current_busno);
@@ -509,7 +354,6 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
                pciauto_postscan_setup_bridge(hose, dev, sub_bus);
 
                sub_bus = hose->current_busno;
-#endif
                break;
 
        case PCI_CLASS_BRIDGE_CARDBUS:
@@ -523,9 +367,7 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
                debug("PCI Autoconfig: Found P2CardBus bridge, device %d\n",
                      PCI_DEV(dev));
 
-#ifndef CONFIG_DM_PCI
                hose->current_busno++;
-#endif
                break;
 
 #if defined(CONFIG_PCIAUTO_SKIP_HOST_BRIDGE)