Marc,
Hopefully this makes everything right again. I still think some of
the geode functions should be moved, but that's really a separate
issue.
> You have to specify to make things breadth first, which seems like the
> correct way.
I guess it's not really breadth first. It's just parents before siblings.
I think this should be done for all the phases unless there's some
compelling reason not to.
Signed-off-by: Myles Watson <[email protected]>
Thanks,
Myles
Index: device/device.c
===================================================================
--- device/device.c (revision 1094)
+++ device/device.c (working copy)
@@ -997,32 +997,47 @@
post_code(POST_STAGE2_PHASE1_EXIT);
}
+/*
+ * Starting at the root device, walk the tree and call the device's phase2()
+ * method to do early setup. It's done parents before children in case there
+ * are dependencies.
+ */
+void phase2_tree(struct device *root)
+{
+ struct device *child;
+ unsigned link;
+
+ for (link = 0; link < root->links; link++) {
+ for (child = root->link[link].children; child;
+ child = child->sibling) {
+ printk(BIOS_SPEW,
+ "%s: dev %s: ops %sNULL ops->phase2_fixup %s\n",
+ __FUNCTION__, child->dtsname, child->ops ?
+ "NOT " : "",
+ child->ops ? (child->ops->phase2_fixup ?
+ "NOT NULL" : "NULL")
+ : "N/A");
+ if (child->ops && child->ops->phase2_fixup) {
+ printk(BIOS_SPEW, "Calling phase2_fixup...\n");
+ child->ops->phase2_fixup(child);
+ printk(BIOS_SPEW, "phase2_fixup done\n");
+ }
+ phase2_tree(child);
+ }
+ }
+}
+
/**
- * Do early setup for all devices in the global device list.
+ * Do early setup for all devices in the global device tree.
*
- * Starting at the first device on the global device link list,
- * walk the list and call the device's phase2() method to do
- * early setup.
*/
void dev_phase2(void)
{
- struct device *dev;
-
post_code(POST_STAGE2_PHASE2_ENTER);
printk(BIOS_DEBUG, "Phase 2: Early setup...\n");
- for (dev = all_devices; dev; dev = dev->next) {
- printk(BIOS_SPEW,
- "%s: dev %s: ops %sNULL ops->phase2_fixup %s\n",
- __FUNCTION__, dev->dtsname, dev->ops ? "NOT " : "",
- dev->ops ? (dev->ops->phase2_fixup ? "NOT NULL" : "NULL")
- : "N/A");
- if (dev->ops && dev->ops->phase2_fixup) {
- printk(BIOS_SPEW, "Calling phase2 phase2_fixup...\n");
- dev->ops->phase2_fixup(dev);
- printk(BIOS_SPEW, "phase2_fixup done\n");
- }
- }
+ phase2_tree(&dev_root);
+
post_code(POST_STAGE2_PHASE2_DONE);
printk(BIOS_DEBUG, "Phase 2: Done.\n");
post_code(POST_STAGE2_PHASE2_EXIT);
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot