summaryrefslogtreecommitdiff
path: root/src/devices/chip.c
diff options
context:
space:
mode:
authorEric Biederman <ebiederm@xmission.com>2003-09-02 03:36:25 +0000
committerEric Biederman <ebiederm@xmission.com>2003-09-02 03:36:25 +0000
commite9a271e32c53076445ef70da8aec8201c82693ec (patch)
treeaf88f51ba907922157d3b97f9713a07480223372 /src/devices/chip.c
parentd4c14524f53d8e812cf52b57e16c53d259c44ea0 (diff)
- Major update of the dynamic device tree so it can handle
* subtractive resources * merging with the static device tree * more device types than just pci - The piece to watch out for is the new enable_resources method that was needed in all of the drivers git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1096 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/devices/chip.c')
-rw-r--r--src/devices/chip.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/devices/chip.c b/src/devices/chip.c
index 0074f2bede..b7eace38f0 100644
--- a/src/devices/chip.c
+++ b/src/devices/chip.c
@@ -5,7 +5,9 @@
* path, etc.
*/
+#include <console/console.h>
#include <device/chip.h>
+#include <device/pci.h>
void
chip_configure(struct chip *root, enum chip_pass pass)
@@ -22,3 +24,86 @@ chip_configure(struct chip *root, enum chip_pass pass)
chip_configure(c->children, pass);
}
}
+
+/** Convert a static struct chip structure to a set of dynamic device structures.
+ * @param chip Static chip structure to start with.
+ */
+
+void chip_enumerate(struct chip *chip)
+{
+ struct chip *child;
+ device_t dev;
+ int link;
+ int i;
+ dev = 0;
+ link = 0;
+#if 1
+ if (chip->control && chip->control->name) {
+ printk_debug("Enumerating: %s\n", chip->control->name);
+ }
+#endif
+ for(i = 0; i < MAX_CHIP_PATHS; i++) {
+ int identical_paths;
+ identical_paths =
+ (i > 0) &&
+ (path_eq(&chip->path[i - 1].path, &chip->path[i].path)) &&
+ (chip->path[i - 1].channel == chip->path[i].channel);
+ if (!identical_paths) {
+ link = 0;
+ dev = 0;
+ switch(chip->path[i].path.type) {
+ case DEVICE_PATH_NONE:
+ break;
+ default:
+ dev = alloc_dev(chip->bus, &chip->path[i].path);
+ break;
+ }
+ }
+ else {
+ link += 1;
+ }
+ if (dev) {
+ printk_spew("path %s %s\n", dev_path(dev), identical_paths?"identical":"");
+ dev->enable = chip->path[i].enable;
+ dev->links = link + 1;
+ for(child = chip->children; child; child = child->next) {
+ if (!child->bus &&
+ child->path[0].channel == i) {
+ child->bus = &dev->link[link];
+ }
+ }
+ }
+ if (dev && !chip->dev) {
+ chip->dev = dev;
+ }
+ }
+ for(child = chip->children; child; child = child->next) {
+ if (!child->bus) {
+ child->bus = &chip->dev->link[0];
+ }
+ }
+}
+
+static void enumerate_static_device_chain(struct chip *root)
+{
+ struct chip *chip;
+ for(chip = root; chip; chip = chip->next) {
+ void (*enumerate)(struct chip *chip);
+ enumerate = chip_enumerate;
+ if (chip->control && chip->control->enumerate) {
+ enumerate = chip->control->enumerate;
+ }
+ enumerate(chip);
+ }
+
+ for(chip = root; chip; chip = chip->next) {
+ if (chip->children) {
+ enumerate_static_device_chain(chip->children);
+ }
+ }
+}
+
+void enumerate_static_devices(void)
+{
+ enumerate_static_device_chain(&static_root);
+}