summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2015-02-26 20:47:47 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2015-06-04 11:19:01 +0200
commitd0e212cdce76b42090325f429e7bd78e0b1a9bb5 (patch)
treee4f423a12bcce87ce93f79874df83f517312fbb6 /src/device
parent6ccf119932661eaf63af0ee3a276a6d2f2f27b89 (diff)
downloadcoreboot-d0e212cdce76b42090325f429e7bd78e0b1a9bb5.tar.xz
devicetree: Discriminate device ops scan_bus()
Use of scan_static_bus() and tree traversals is somewhat convoluted. Start cleaning this up by assigning each path type with separate static scan_bus() function. For ME, SMBus and LPC paths a bus cannot expose bridges, as those would add to the number of encountered PCI buses. Change-Id: I8bb11450516faad4fa33b8f69bce5b9978ec75e5 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/8534 Tested-by: build bot (Jenkins) Reviewed-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
Diffstat (limited to 'src/device')
-rw-r--r--src/device/root_device.c84
1 files changed, 60 insertions, 24 deletions
diff --git a/src/device/root_device.c b/src/device/root_device.c
index 1ec6f7fb37..0575b565c0 100644
--- a/src/device/root_device.c
+++ b/src/device/root_device.c
@@ -44,51 +44,69 @@ const char mainboard_name[] = CONFIG_MAINBOARD_VENDOR " " CONFIG_MAINBOARD_PART_
* debug device. Those virtual devices have to be listed in the config
* file under some static bus in order to be enumerated at run time.
*
- * This function is the default scan_bus() method for the root device and
- * LPC bridges.
- *
* @param bus Pointer to the device to which the static buses are attached to.
* @param max Maximum bus number currently used before scanning.
* @return The largest bus number used.
*/
-static int smbus_max = 0;
-unsigned int scan_static_bus(device_t bus, unsigned int max)
+
+static unsigned int scan_static_bus(device_t bus, unsigned int max)
{
device_t child;
struct bus *link;
- printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
-
for (link = bus->link_list; link; link = link->next) {
- /* For SMBus bus enumerate. */
- child = link->children;
-
- if (child && child->path.type == DEVICE_PATH_I2C)
- link->secondary = ++smbus_max;
-
for (child = link->children; child; child = child->sibling) {
+
if (child->chip_ops && child->chip_ops->enable_dev)
child->chip_ops->enable_dev(child);
if (child->ops && child->ops->enable)
child->ops->enable(child);
- if (child->path.type == DEVICE_PATH_I2C) {
- printk(BIOS_DEBUG, "smbus: %s[%d]->",
- dev_path(child->bus->dev),
- child->bus->link_num);
- }
printk(BIOS_DEBUG, "%s %s\n", dev_path(child),
child->enabled ? "enabled" : "disabled");
}
}
+ return max;
+}
+
+unsigned int scan_lpc_bus(device_t bus, unsigned int max)
+{
+ printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
+
+ max = scan_static_bus(bus, max);
+
+ printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
+
+ return max;
+}
+
+unsigned int scan_smbus(device_t bus, unsigned int max)
+{
+ device_t child;
+ struct bus *link;
+ static int smbus_max = 0;
+
+ printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
+
for (link = bus->link_list; link; link = link->next) {
+
+ link->secondary = ++smbus_max;
+
for (child = link->children; child; child = child->sibling) {
- if (!child->ops || !child->ops->scan_bus)
- continue;
- printk(BIOS_SPEW, "%s scanning...\n", dev_path(child));
- max = scan_bus(child, max);
+
+ if (child->chip_ops && child->chip_ops->enable_dev)
+ child->chip_ops->enable_dev(child);
+
+ if (child->ops && child->ops->enable)
+ child->ops->enable(child);
+
+ printk(BIOS_DEBUG, "smbus: %s[%d]->", dev_path(child->bus->dev),
+ child->bus->link_num);
+
+ printk(BIOS_DEBUG, "%s %s\n", dev_path(child),
+ child->enabled ? "enabled" : "disabled");
}
}
@@ -106,9 +124,27 @@ unsigned int scan_static_bus(device_t bus, unsigned int max)
* @param max The current bus number scanned so far, usually 0x00.
* @return The largest bus number used.
*/
-static unsigned int root_dev_scan_bus(device_t root, unsigned int max)
+static unsigned int root_dev_scan_bus(device_t bus, unsigned int max)
{
- return scan_static_bus(root, max);
+ device_t child;
+ struct bus *link;
+
+ printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
+
+ max = scan_static_bus(bus, max);
+
+ 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(BIOS_SPEW, "%s scanning...\n", dev_path(child));
+ max = scan_bus(child, max);
+ }
+ }
+
+ printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
+
+ return max;
}
static void root_dev_reset(struct bus *bus)