Always enable parent resources before child resources.
[coreboot.git] / src / devices / root_device.c
index b8d56b646b46b3582ad09257dbf8a9c0682caa56..cd576a15b63329f9487bd54cd51e4546747932f2 100644 (file)
 #include <console/console.h>
 #include <device/device.h>
 #include <device/pci.h>
-#include <part/hard_reset.h>
+#include <reset.h>
 
-/** 
+/**
  * Read the resources for the root device,
  * that encompass the resources for the entire system.
  * @param root Pointer to the device structure for the system root device
  */
-void root_dev_read_resources(device_t root)
+static void root_dev_read_resources(device_t root)
 {
-       printk_err("%s should never be called.\n", __func__);
+       printk(BIOS_ERR, "%s should never be called.\n", __func__);
 }
 
 /**
@@ -44,9 +44,9 @@ void root_dev_read_resources(device_t root)
  * and every device under it which are all of the devices.
  * @param root Pointer to the device structure for the system root device
  */
-void root_dev_set_resources(device_t root)
+static void root_dev_set_resources(device_t root)
 {
-       printk_err("%s should never be called.\n", __func__);
+       printk(BIOS_ERR, "%s should never be called.\n", __func__);
 }
 
 /**
@@ -54,9 +54,9 @@ void root_dev_set_resources(device_t root)
  *
  * The enumeration of certain buses is purely static. The existence of
  * devices on those buses can be completely determined at compile time
- * and is specified in the config file. Typical examples are the 'PNP' 
- * devices on a legacy ISA/LPC bus. There is no need of probing of any kind, 
- * the only thing we have to do is to walk through the bus and 
+ * and is specified in the config file. Typical examples are the 'PNP'
+ * devices on a legacy ISA/LPC bus. There is no need of probing of any kind,
+ * the only thing we have to do is to walk through the bus and
  * enable or disable devices as indicated in the config file.
  *
  * On the other hand, some devices are virtual and their existence is
@@ -75,17 +75,17 @@ static int smbus_max = 0;
 unsigned int scan_static_bus(device_t bus, unsigned int max)
 {
        device_t child;
-       unsigned link;
+       struct bus* link;
 
-       printk_spew("%s for %s\n", __func__, dev_path(bus));
+       printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
 
-       for(link = 0; link < bus->links; link++) {
+       for(link = bus->link_list; link; link = link->next) {
                /* for smbus bus enumerate */
-               child = bus->link[link].children;
+               child = link->children;
                if(child && child->path.type == DEVICE_PATH_I2C) {
-                       bus->link[link].secondary = ++smbus_max;
+                       link->secondary = ++smbus_max;
                }
-               for(child = bus->link[link].children; child; child = child->sibling) {
+               for(child =link->children; child; child = child->sibling) {
                        if (child->chip_ops && child->chip_ops->enable_dev) {
                                child->chip_ops->enable_dev(child);
                        }
@@ -93,55 +93,30 @@ unsigned int scan_static_bus(device_t bus, unsigned int max)
                                child->ops->enable(child);
                        }
                        if (child->path.type == DEVICE_PATH_I2C) {
-                               printk_debug("smbus: %s[%d]->",  
-                                       dev_path(child->bus->dev), child->bus->link );
+                               printk(BIOS_DEBUG, "smbus: %s[%d]->",
+                                       dev_path(child->bus->dev), child->bus->link_num );
                        }
-                       printk_debug("%s %s\n",
+                       printk(BIOS_DEBUG, "%s %s\n",
                                dev_path(child),
                                child->enabled?"enabled": "disabled");
                }
        }
-       for(link = 0; link < bus->links; link++) {
-               for(child = bus->link[link].children; child; child = child->sibling) {
+       for(link = bus->link_list; link; link = link->next) {
+               for(child = link->children; child; child = child->sibling) {
                        if (!child->ops || !child->ops->scan_bus)
                                continue;
-                       printk_spew("%s scanning...\n", dev_path(child));
+                       printk(BIOS_SPEW, "%s scanning...\n", dev_path(child));
                        max = scan_bus(child, max);
                }
        }
 
-       printk_spew("%s for %s done\n", __func__, dev_path(bus));
+       printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
 
        return max;
 }
 
-/**
- * @brief Enable resources for children devices
- *
- * @param dev the device whos children's resources are to be enabled
- *
- * This function is called by the global enable_resource() indirectly via the
- * device_operation::enable_resources() method of devices.
- *
- * Indirect mutual recursion:
- *     enable_childrens_resources() -> enable_resources()
- *     enable_resources() -> device_operation::enable_resources()
- *     device_operation::enable_resources() -> enable_children_resources()
- */
-void enable_childrens_resources(device_t dev)
-{
-       unsigned link;
-       for(link = 0; link < dev->links; link++) {
-               device_t child;
-               for(child = dev->link[link].children; child; child = child->sibling) {
-                       enable_resources(child);
-               }
-       }
-}
-
-void root_dev_enable_resources(device_t dev)
+static void root_dev_enable_resources(device_t dev)
 {
-       enable_childrens_resources(dev);
 }
 
 /**
@@ -152,18 +127,18 @@ void root_dev_enable_resources(device_t dev)
  *
  * This function is the default scan_bus() method of the root device.
  */
-unsigned int root_dev_scan_bus(device_t root, unsigned int max)
+static unsigned int root_dev_scan_bus(device_t root, unsigned int max)
 {
        return scan_static_bus(root, max);
 }
 
-void root_dev_init(device_t root)
+static void root_dev_init(device_t root)
 {
 }
 
-void root_dev_reset(struct bus *bus)
+static void root_dev_reset(struct bus *bus)
 {
-       printk_info("Reseting board...\n");
+       printk(BIOS_INFO, "Reseting board...\n");
        hard_reset();
 }