Factor out a few commonly duplicated functions from northbridge.c.
[coreboot.git] / src / northbridge / intel / e7520 / northbridge.c
index efb7f0263bf8555f67868d2cc948421d68ab4826..fceceb2a470d93fc35bf67674644a32c2911bc85 100644 (file)
 
 static unsigned int max_bus;
 
-static void ram_resource(device_t dev, unsigned long index, 
-       unsigned long basek, unsigned long sizek)
-{
-       struct resource *resource;
-
-       resource = new_resource(dev, index);
-       resource->base  = ((resource_t)basek) << 10;
-       resource->size  = ((resource_t)sizek) << 10;
-       resource->flags =  IORESOURCE_MEM | IORESOURCE_CACHEABLE | \
-               IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
-}
-
-static void tolm_test(void *gp, struct device *dev, struct resource *new)
-{
-       struct resource **best_p = gp;
-       struct resource *best;
-       best = *best_p;
-       if (!best || (best->base > new->base)) {
-               best = new;
-       }
-       *best_p = best;
-}
-
-static uint32_t find_pci_tolm(struct bus *bus)
-{
-       struct resource *min;
-       uint32_t tolm;
-       min = 0;
-       search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test, &min);
-       tolm = 0xffffffffUL;
-       if (min && tolm > min->base) {
-               tolm = min->base;
-       }
-       return tolm;
-}
-
 #if CONFIG_WRITE_HIGH_TABLES==1
 #define HIGH_TABLES_SIZE 64    // maximum size of high tables in KB
 extern uint64_t high_tables_base, high_tables_size;
@@ -62,7 +26,7 @@ static void pci_domain_set_resources(device_t dev)
        device_t mc_dev;
        uint32_t pci_tolm;
 
-        pci_tolm = find_pci_tolm(&dev->link[0]);
+        pci_tolm = find_pci_tolm(dev->link_list);
 
 #if 1
        printk(BIOS_DEBUG, "PCI mem marker = %x\n", pci_tolm);
@@ -72,7 +36,7 @@ static void pci_domain_set_resources(device_t dev)
                pci_tolm = 0xe0000000;
        /* Ensure pci_tolm is 128M aligned */
        pci_tolm &= 0xf8000000;
-       mc_dev = dev->link[0].children;
+       mc_dev = dev->link_list->children;
        if (mc_dev) {
                /* Figure out which areas are/should be occupied by RAM.
                 * This is all computed in kilobytes and converted to/from
@@ -151,7 +115,7 @@ static void pci_domain_set_resources(device_t dev)
                high_tables_size = HIGH_TABLES_SIZE * 1024;
 #endif
        }
-       assign_resources(&dev->link[0]);
+       assign_resources(dev->link_list);
 }
 
 static u32 e7520_domain_scan_bus(device_t dev, u32 max)
@@ -163,8 +127,8 @@ static u32 e7520_domain_scan_bus(device_t dev, u32 max)
 static struct device_operations pci_domain_ops = {
        .read_resources   = pci_domain_read_resources,
        .set_resources    = pci_domain_set_resources,
-       .enable_resources = enable_childrens_resources,
-       .init             = 0,
+       .enable_resources = NULL,
+       .init             = NULL,
        .scan_bus         = e7520_domain_scan_bus,
        .ops_pci_bus      = &pci_cf8_conf1, /* Do we want to use the memory mapped space here? */
 };
@@ -183,9 +147,8 @@ static void mc_read_resources(device_t dev)
 
 static void mc_set_resources(device_t dev)
 {
-       struct resource *resource, *last;
+       struct resource *resource;
 
-       last = &dev->resource[dev->resources];
        resource = find_resource(dev, 0xcf);
        if (resource) {
                report_resource_stored(dev, resource, "<mmconfig>");
@@ -195,7 +158,7 @@ static void mc_set_resources(device_t dev)
 
 static void intel_set_subsystem(device_t dev, unsigned vendor, unsigned device)
 {
-       pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, 
+       pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
                ((device & 0xffff) << 16) | (vendor & 0xffff));
 }
 
@@ -220,7 +183,7 @@ static const struct pci_driver mc_driver __pci_driver = {
 
 static void cpu_bus_init(device_t dev)
 {
-        initialize_cpus(&dev->link[0]);
+        initialize_cpus(dev->link_list);
 }
 
 static void cpu_bus_noop(device_t dev)