Factor out a few commonly duplicated functions from northbridge.c.
[coreboot.git] / src / devices / device_util.c
index 979b0253247958f7aa67abd434ae330685a481ae..2c46884d9e7e0c3e0fd5d5f68f03d72a29a82dd7 100644 (file)
@@ -1,3 +1,27 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2003-2004 Linux Networx
+ * (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx)
+ * Copyright (C) 2003 Greg Watson <jarrah@users.sourceforge.net>
+ * Copyright (C) 2004 Li-Ta Lo <ollie@lanl.gov>
+ * Copyright (C) 2005-2006 Tyan
+ * (Written by Yinghai Lu <yhlu@tyan.com> for Tyan)
+ *
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
 #include <console/console.h>
 #include <device/device.h>
 #include <device/path.h>
@@ -16,7 +40,7 @@
 device_t find_dev_path(struct bus *parent, struct device_path *path)
 {
        device_t child;
-       for(child = parent->children; child; child = child->sibling) {
+       for (child = parent->children; child; child = child->sibling) {
                if (path_eq(path, &child->path)) {
                        break;
                }
@@ -55,8 +79,8 @@ struct device *dev_find_slot(unsigned int bus, unsigned int devfn)
        result = 0;
        for (dev = all_devices; dev; dev = dev->next) {
                if ((dev->path.type == DEVICE_PATH_PCI) &&
-                       (dev->bus->secondary == bus) && 
-                       (dev->path.u.pci.devfn == devfn)) {
+                       (dev->bus->secondary == bus) &&
+                       (dev->path.pci.devfn == devfn)) {
                        result = dev;
                        break;
                }
@@ -68,32 +92,32 @@ struct device *dev_find_slot(unsigned int bus, unsigned int devfn)
  * @brief Given a smbus bus and a device number, find the device structure
  *
  * @param bus The bus number
- * @param addr a device number 
+ * @param addr a device number
  * @return pointer to the device structure
  */
 struct device *dev_find_slot_on_smbus(unsigned int bus, unsigned int addr)
 {
         struct device *dev, *result;
-        
+
         result = 0;
         for (dev = all_devices; dev; dev = dev->next) {
                 if ((dev->path.type == DEVICE_PATH_I2C) &&
-                        (dev->bus->secondary == bus) && 
-                        (dev->path.u.i2c.device == addr)) {
+                        (dev->bus->secondary == bus) &&
+                        (dev->path.i2c.device == addr)) {
                         result = dev;
-                        break; 
-                }       
-        }       
+                        break;
+                }
+        }
         return result;
-}    
+}
 
 /** Find a device of a given vendor and type
  * @param vendor Vendor ID (e.g. 0x8086 for Intel)
  * @param device Device ID
  * @param from Pointer to the device structure, used as a starting point
- *        in the linked list of all_devices, which can be 0 to start at the 
+ *        in the linked list of all_devices, which can be 0 to start at the
  *        head of the list (i.e. all_devices)
- * @return Pointer to the device struct 
+ * @return Pointer to the device struct
  */
 struct device *dev_find_device(unsigned int vendor, unsigned int device, struct device *from)
 {
@@ -110,9 +134,9 @@ struct device *dev_find_device(unsigned int vendor, unsigned int device, struct
 /** Find a device of a given class
  * @param class Class of the device
  * @param from Pointer to the device structure, used as a starting point
- *        in the linked list of all_devices, which can be 0 to start at the 
+ *        in the linked list of all_devices, which can be 0 to start at the
  *        head of the list (i.e. all_devices)
- * @return Pointer to the device struct 
+ * @return Pointer to the device struct
  */
 struct device *dev_find_class(unsigned int class, struct device *from)
 {
@@ -125,6 +149,8 @@ struct device *dev_find_class(unsigned int class, struct device *from)
        return from;
 }
 
+/* Warning: This function uses a static buffer.  Don't call it more than once
+ * from the same print statement! */
 
 const char *dev_path(device_t dev)
 {
@@ -139,45 +165,45 @@ const char *dev_path(device_t dev)
                        memcpy(buffer, "Root Device", 12);
                        break;
                case DEVICE_PATH_PCI:
-#if PCI_BUS_SEGN_BITS
+#if CONFIG_PCI_BUS_SEGN_BITS
                        sprintf(buffer, "PCI: %04x:%02x:%02x.%01x",
-                               dev->bus->secondary>>8, dev->bus->secondary & 0xff, 
-                               PCI_SLOT(dev->path.u.pci.devfn), PCI_FUNC(dev->path.u.pci.devfn));
+                               dev->bus->secondary>>8, dev->bus->secondary & 0xff,
+                               PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
 #else
                        sprintf(buffer, "PCI: %02x:%02x.%01x",
-                               dev->bus->secondary, 
-                               PCI_SLOT(dev->path.u.pci.devfn), PCI_FUNC(dev->path.u.pci.devfn));
+                               dev->bus->secondary,
+                               PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
 #endif
                        break;
                case DEVICE_PATH_PNP:
                        sprintf(buffer, "PNP: %04x.%01x",
-                               dev->path.u.pnp.port, dev->path.u.pnp.device);
+                               dev->path.pnp.port, dev->path.pnp.device);
                        break;
                case DEVICE_PATH_I2C:
                        sprintf(buffer, "I2C: %02x:%02x",
                                dev->bus->secondary,
-                               dev->path.u.i2c.device);
+                               dev->path.i2c.device);
                        break;
                case DEVICE_PATH_APIC:
                        sprintf(buffer, "APIC: %02x",
-                               dev->path.u.apic.apic_id);
+                               dev->path.apic.apic_id);
                        break;
                case DEVICE_PATH_PCI_DOMAIN:
                        sprintf(buffer, "PCI_DOMAIN: %04x",
-                               dev->path.u.pci_domain.domain);
+                               dev->path.pci_domain.domain);
                        break;
                case DEVICE_PATH_APIC_CLUSTER:
                        sprintf(buffer, "APIC_CLUSTER: %01x",
-                               dev->path.u.apic_cluster.cluster);
+                               dev->path.apic_cluster.cluster);
                        break;
                case DEVICE_PATH_CPU:
-                       sprintf(buffer, "CPU: %02x", dev->path.u.cpu.id);
+                       sprintf(buffer, "CPU: %02x", dev->path.cpu.id);
                        break;
                case DEVICE_PATH_CPU_BUS:
-                       sprintf(buffer, "CPU_BUS: %02x", dev->path.u.cpu_bus.id);
+                       sprintf(buffer, "CPU_BUS: %02x", dev->path.cpu_bus.id);
                        break;
                default:
-                       printk_err("Unknown device path type: %d\n", dev->path.type);
+                       printk(BIOS_ERR, "Unknown device path type: %d\n", dev->path.type);
                        break;
                }
        }
@@ -187,8 +213,7 @@ const char *dev_path(device_t dev)
 const char *bus_path(struct bus *bus)
 {
        static char buffer[BUS_PATH_MAX];
-       sprintf(buffer, "%s,%d",
-               dev_path(bus->dev), bus->link);
+       sprintf(buffer, "%s,%d", dev_path(bus->dev), bus->link_num);
        return buffer;
 }
 
@@ -203,38 +228,72 @@ int path_eq(struct device_path *path1, struct device_path *path2)
                        equal = 1;
                        break;
                case DEVICE_PATH_PCI:
-                       equal = (path1->u.pci.devfn == path2->u.pci.devfn);
+                       equal = (path1->pci.devfn == path2->pci.devfn);
                        break;
                case DEVICE_PATH_PNP:
-                       equal = (path1->u.pnp.port == path2->u.pnp.port) &&
-                               (path1->u.pnp.device == path2->u.pnp.device);
+                       equal = (path1->pnp.port == path2->pnp.port) &&
+                               (path1->pnp.device == path2->pnp.device);
                        break;
                case DEVICE_PATH_I2C:
-                       equal = (path1->u.i2c.device == path2->u.i2c.device);
+                       equal = (path1->i2c.device == path2->i2c.device);
                        break;
                case DEVICE_PATH_APIC:
-                       equal = (path1->u.apic.apic_id == path2->u.apic.apic_id);
+                       equal = (path1->apic.apic_id == path2->apic.apic_id);
                        break;
                case DEVICE_PATH_PCI_DOMAIN:
-                       equal = (path1->u.pci_domain.domain == path2->u.pci_domain.domain);
+                       equal = (path1->pci_domain.domain == path2->pci_domain.domain);
                        break;
                case DEVICE_PATH_APIC_CLUSTER:
-                       equal = (path1->u.apic_cluster.cluster == path2->u.apic_cluster.cluster);
+                       equal = (path1->apic_cluster.cluster == path2->apic_cluster.cluster);
                        break;
                case DEVICE_PATH_CPU:
-                       equal = (path1->u.cpu.id == path2->u.cpu.id);
+                       equal = (path1->cpu.id == path2->cpu.id);
                        break;
                case DEVICE_PATH_CPU_BUS:
-                       equal = (path1->u.cpu_bus.id == path2->u.cpu_bus.id);
+                       equal = (path1->cpu_bus.id == path2->cpu_bus.id);
                        break;
                default:
-                       printk_err("Uknown device type: %d\n", path1->type);
+                       printk(BIOS_ERR, "Uknown device type: %d\n", path1->type);
                        break;
                }
        }
        return equal;
 }
 
+/**
+ * Allocate 64 more resources to the free list.
+ */
+static int allocate_more_resources(void)
+{
+       int i;
+       struct resource *new_res_list;
+       new_res_list = malloc(64 * sizeof(*new_res_list));
+
+       if (new_res_list == NULL)
+               return 0;
+
+       memset(new_res_list, 0, 64 * sizeof(*new_res_list));
+
+       for (i = 0; i < 64-1; i++)
+               new_res_list[i].next = &new_res_list[i+1];
+
+       free_resources = new_res_list;
+       return 1;
+}
+
+/**
+ * Remove resource res from the device's list and add it to the free list.
+ */
+static void free_resource(device_t dev, struct resource *res, struct resource *prev)
+{
+       if (prev)
+               prev->next = res->next;
+       else
+               dev->resource_list = res->next;
+       res->next = free_resources;
+       free_resources = res;
+}
+
 /**
  * See if we have unused but allocated resource structures.
  * If so remove the allocation.
@@ -242,18 +301,14 @@ int path_eq(struct device_path *path1, struct device_path *path2)
  */
 void compact_resources(device_t dev)
 {
-       struct resource *resource;
-       int i;
+       struct resource *res, *next, *prev = NULL;
        /* Move all of the free resources to the end */
-       for(i = 0; i < dev->resources;) {
-               resource = &dev->resource[i];
-               if (!resource->flags) {
-                       memmove(resource, resource + 1, dev->resources - i);
-                       dev->resources -= 1;
-                       memset(&dev->resource[dev->resources], 0, sizeof(*resource));
-               } else {
-                       i++;
-               }
+       for (res = dev->resource_list; res; res = next) {
+               next = res->next;
+               if (!res->flags)
+                       free_resource(dev, res, prev);
+               else
+                       prev = res;
        }
 }
 
@@ -266,17 +321,13 @@ void compact_resources(device_t dev)
  */
 struct resource *probe_resource(device_t dev, unsigned index)
 {
-       struct resource *resource;
-       int i;
+       struct resource *res;
        /* See if there is a resource with the appropriate index */
-       resource = 0;
-       for(i = 0; i < dev->resources; i++) {
-               if (dev->resource[i].index == index) {
-                       resource = &dev->resource[i];
+       for (res = dev->resource_list; res; res = res->next) {
+               if (res->index == index)
                        break;
-               }
        }
-       return resource;
+       return res;
 }
 
 /**
@@ -288,7 +339,7 @@ struct resource *probe_resource(device_t dev, unsigned index)
  */
 struct resource *new_resource(device_t dev, unsigned index)
 {
-       struct resource *resource;
+       struct resource *resource, *tail;
 
        /* First move all of the free resources to the end */
        compact_resources(dev);
@@ -296,12 +347,20 @@ struct resource *new_resource(device_t dev, unsigned index)
        /* See if there is a resource with the appropriate index */
        resource = probe_resource(dev, index);
        if (!resource) {
-               if (dev->resources == MAX_RESOURCES) {
-                       die("MAX_RESOURCES exceeded.");
-               }
-               resource = &dev->resource[dev->resources];
+               if (free_resources == NULL && !allocate_more_resources())
+                       die("Couldn't allocate more resources.");
+
+               resource = free_resources;
+               free_resources = free_resources->next;
                memset(resource, 0, sizeof(*resource));
-               dev->resources++;
+               resource->next = NULL;
+               tail = dev->resource_list;
+               if (tail) {
+                       while (tail->next) tail = tail->next;
+                       tail->next = resource;
+               }
+               else
+                       dev->resource_list = resource;
        }
        /* Initialize the resource values */
        if (!(resource->flags & IORESOURCE_FIXED)) {
@@ -329,7 +388,7 @@ struct resource *find_resource(device_t dev, unsigned index)
        /* See if there is a resource with the appropriate index */
        resource = probe_resource(dev, index);
        if (!resource) {
-               printk_emerg("%s missing resource: %02x\n",
+               printk(BIOS_EMERG, "%s missing resource: %02x\n",
                        dev_path(dev), index);
                die("");
        }
@@ -382,7 +441,7 @@ resource_t resource_end(struct resource *resource)
         * the bridge.  While the granularity is simply how many low bits of the
         * address cannot be set.
         */
-       
+
        /* Get the end (rounded up) */
        end = base + align_up(resource->size, resource->gran) - 1;
 
@@ -430,23 +489,24 @@ const char *resource_type(struct resource *resource)
 void report_resource_stored(device_t dev, struct resource *resource, const char *comment)
 {
        if (resource->flags & IORESOURCE_STORED) {
-               unsigned char buf[10];
+               char buf[10];
                unsigned long long base, end;
                base = resource->base;
                end = resource_end(resource);
                buf[0] = '\0';
                if (resource->flags & IORESOURCE_PCI_BRIDGE) {
-#if PCI_BUS_SEGN_BITS
-                       sprintf(buf, "bus %04x:%02x ", dev->bus->secondary>>8, dev->link[0].secondary & 0xff);
+#if CONFIG_PCI_BUS_SEGN_BITS
+                       sprintf(buf, "bus %04x:%02x ", dev->bus->secondary>>8, dev->link_list->secondary & 0xff);
 #else
-                       sprintf(buf, "bus %02x ", dev->link[0].secondary);
+                       sprintf(buf, "bus %02x ", dev->link_list->secondary);
 #endif
                }
-               printk_debug(
-                       "%s %02x <- [0x%010Lx - 0x%010Lx] %s%s%s\n",
+               printk(BIOS_DEBUG,
+                       "%s %02lx <- [0x%010Lx - 0x%010Lx] size 0x%08Lx gran 0x%02x %s%s%s\n",
                        dev_path(dev),
                        resource->index,
                        base, end,
+                       resource->size, resource->gran,
                        buf,
                        resource_type(resource),
                        comment);
@@ -458,24 +518,25 @@ void search_bus_resources(struct bus *bus,
        resource_search_t search, void *gp)
 {
        struct device *curdev;
-       for(curdev = bus->children; curdev; curdev = curdev->sibling) {
-               int i;
+       for (curdev = bus->children; curdev; curdev = curdev->sibling) {
+               struct resource *res;
                /* Ignore disabled devices */
-               if (!curdev->have_resources) continue;
-               for(i = 0; i < curdev->resources; i++) {
-                       struct resource *resource = &curdev->resource[i];
+               if (!curdev->enabled) continue;
+               for (res = curdev->resource_list; res; res = res->next) {
                        /* If it isn't the right kind of resource ignore it */
-                       if ((resource->flags & type_mask) != type) {
+                       if ((res->flags & type_mask) != type) {
                                continue;
                        }
                        /* If it is a subtractive resource recurse */
-                       if (resource->flags & IORESOURCE_SUBTRACTIVE) {
+                       if (res->flags & IORESOURCE_SUBTRACTIVE) {
                                struct bus * subbus;
-                               subbus = &curdev->link[IOINDEX_SUBTRACTIVE_LINK(resource->index)];
+                               for (subbus = curdev->link_list; subbus; subbus = subbus->next)
+                                       if (subbus->link_num == IOINDEX_SUBTRACTIVE_LINK(res->index))
+                                               break;
                                search_bus_resources(subbus, type_mask, type, search, gp);
                                continue;
                        }
-                       search(gp, curdev, resource);
+                       search(gp, curdev, res);
                }
        }
 }
@@ -485,21 +546,20 @@ void search_global_resources(
        resource_search_t search, void *gp)
 {
        struct device *curdev;
-       for(curdev = all_devices; curdev; curdev = curdev->next) {
-               int i;
+       for (curdev = all_devices; curdev; curdev = curdev->next) {
+               struct resource *res;
                /* Ignore disabled devices */
-               if (!curdev->have_resources) continue;
-               for(i = 0; i < curdev->resources; i++) {
-                       struct resource *resource = &curdev->resource[i];
+               if (!curdev->enabled) continue;
+               for (res = curdev->resource_list; res; res = res->next) {
                        /* If it isn't the right kind of resource ignore it */
-                       if ((resource->flags & type_mask) != type) {
+                       if ((res->flags & type_mask) != type) {
                                continue;
                        }
                        /* If it is a subtractive resource ignore it */
-                       if (resource->flags & IORESOURCE_SUBTRACTIVE) {
+                       if (res->flags & IORESOURCE_SUBTRACTIVE) {
                                continue;
                        }
-                       search(gp, curdev, resource);
+                       search(gp, curdev, res);
                }
        }
 }
@@ -521,11 +581,196 @@ void dev_set_enabled(device_t dev, int enable)
 void disable_children(struct bus *bus)
 {
        device_t child;
-       for(child = bus->children; child; child = child->sibling) {
-               int link;
-               for(link = 0; link < child->links; link++) {
-                       disable_children(&child->link[link]);
+       for (child = bus->children; child; child = child->sibling) {
+               struct bus *link;
+               for (link = child->link_list; link; link = link->next) {
+                       disable_children(link);
                }
                dev_set_enabled(child, 0);
        }
 }
+
+static void resource_tree(struct device *root, int debug_level, int depth)
+{
+       int i = 0;
+       struct device *child;
+       struct bus *link;
+       struct resource *res;
+       char indent[30];        /* If your tree has more levels, it's wrong. */
+
+       for (i = 0; i < depth + 1 && i < 29; i++)
+               indent[i] = ' ';
+       indent[i] = '\0';
+
+       do_printk(BIOS_DEBUG, "%s%s", indent, dev_path(root));
+       if (root->link_list && root->link_list->children)
+               do_printk(BIOS_DEBUG, " child on link 0 %s",
+                         dev_path(root->link_list->children));
+       do_printk(BIOS_DEBUG, "\n");
+
+       for (res = root->resource_list; res; res = res->next) {
+               do_printk(debug_level,
+                         "%s%s resource base %llx size %llx align %d gran %d limit %llx flags %lx index %lx\n",
+                         indent, dev_path(root), res->base,
+                         res->size, res->align,
+                         res->gran, res->limit,
+                         res->flags, res->index);
+       }
+
+       for (link = root->link_list; link; link = link->next) {
+               for (child = link->children; child; child = child->sibling)
+                       resource_tree(child, debug_level, depth + 1);
+       }
+}
+
+void print_resource_tree(struct device * root, int debug_level,
+                        const char *msg)
+{
+       /* Bail if root is null. */
+       if (!root) {
+               do_printk(debug_level, "%s passed NULL for root!\n", __func__);
+               return;
+       }
+
+       /* Bail if not printing to screen. */
+       if (!do_printk(debug_level, "Show resources in subtree (%s)...%s\n",
+                   dev_path(root), msg))
+               return;
+       resource_tree(root, debug_level, 0);
+}
+
+void show_devs_tree(struct device *dev, int debug_level, int depth, int linknum)
+{
+       char depth_str[20] = "";
+       int i;
+       struct device *sibling;
+       struct bus *link;
+
+       for (i = 0; i < depth; i++)
+               depth_str[i] = ' ';
+       depth_str[i] = '\0';
+       do_printk(debug_level, "%s%s: enabled %d\n",
+                 depth_str, dev_path(dev), dev->enabled);
+       for (link = dev->link_list; link; link = link->next) {
+               for (sibling = link->children; sibling;
+                    sibling = sibling->sibling)
+                       show_devs_tree(sibling, debug_level, depth + 1, i);
+       }
+}
+
+void show_all_devs_tree(int debug_level, const char *msg)
+{
+       /* Bail if not printing to screen. */
+       if (!do_printk(debug_level, "Show all devs in tree form...%s\n", msg))
+               return;
+       show_devs_tree(all_devices, debug_level, 0, -1);
+}
+
+void show_devs_subtree(struct device *root, int debug_level, const char *msg)
+{
+       /* Bail if not printing to screen. */
+       if (!do_printk(debug_level, "Show all devs in subtree %s...%s\n",
+                   dev_path(root), msg))
+               return;
+       do_printk(debug_level, "%s\n", msg);
+       show_devs_tree(root, debug_level, 0, -1);
+}
+
+void show_all_devs(int debug_level, const char *msg)
+{
+       struct device *dev;
+
+       /* Bail if not printing to screen. */
+       if (!do_printk(debug_level, "Show all devs...%s\n", msg))
+               return;
+       for (dev = all_devices; dev; dev = dev->next) {
+               do_printk(debug_level, "%s: enabled %d\n",
+                         dev_path(dev), dev->enabled);
+       }
+}
+
+void show_one_resource(int debug_level, struct device *dev,
+                      struct resource *resource, const char *comment)
+{
+       char buf[10];
+       unsigned long long base, end;
+       base = resource->base;
+       end = resource_end(resource);
+       buf[0] = '\0';
+/*
+       if (resource->flags & IORESOURCE_BRIDGE) {
+#if CONFIG_PCI_BUS_SEGN_BITS
+               sprintf(buf, "bus %04x:%02x ", dev->bus->secondary >> 8,
+                       dev->link[0].secondary & 0xff);
+#else
+               sprintf(buf, "bus %02x ", dev->link[0].secondary);
+#endif
+       }
+*/
+       do_printk(debug_level, "%s %02lx <- [0x%010llx - 0x%010llx] "
+                 "size 0x%08Lx gran 0x%02x %s%s%s\n",
+                 dev_path(dev), resource->index, base, end,
+                 resource->size, resource->gran, buf,
+                 resource_type(resource), comment);
+
+}
+
+void show_all_devs_resources(int debug_level, const char* msg)
+{
+       struct device *dev;
+
+       if(!do_printk(debug_level, "Show all devs with resources...%s\n", msg))
+               return;
+
+       for (dev = all_devices; dev; dev = dev->next) {
+               struct resource *res;
+               do_printk(debug_level, "%s: enabled %d\n",
+                         dev_path(dev), dev->enabled);
+               for (res = dev->resource_list; res; res = res->next)
+                       show_one_resource(debug_level, dev, res, "");
+       }
+}
+
+void ram_resource(device_t dev, unsigned long index,
+                 unsigned long basek, unsigned long sizek)
+{
+       struct resource *resource;
+
+       if (!sizek)
+               return;
+
+       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;
+}
+
+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;
+}
+
+u32 find_pci_tolm(struct bus *bus)
+{
+       struct resource *min = NULL;
+       u32 tolm;
+
+       search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM,
+                            tolm_test, &min);
+
+       tolm = 0xffffffffUL;
+
+       if (min && tolm > min->base)
+               tolm = min->base;
+
+       return tolm;
+}