1 /* chips are arbitrary chips (superio, southbridge, etc.)
2 * They have private structures that define chip resources and default
3 * settings. They have four externally visible functions for control.
4 * They have a generic component which applies to all chips for
8 #include <console/console.h>
9 #include <device/chip.h>
10 #include <device/pci.h>
13 chip_configure(struct chip *root, enum chip_pass pass)
17 for (c = root; c; c = c->next) {
18 if (c->control && c->control->enable)
19 c->control->enable(c, pass);
22 for (c = root; c; c = c->next) {
24 chip_configure(c->children, pass);
28 /** Convert a static struct chip structure to a set of dynamic device structures.
29 * @param chip Static chip structure to start with.
32 void chip_enumerate(struct chip *chip)
41 if (chip->control && chip->control->name) {
42 printk_debug("Enumerating: %s\n", chip->control->name);
45 for(i = 0; i < MAX_CHIP_PATHS; i++) {
49 (path_eq(&chip->path[i - 1].path, &chip->path[i].path));
50 if (!identical_paths) {
56 switch(chip->path[i].path.type) {
57 case DEVICE_PATH_NONE:
60 bus = chip->path[i].path.u.pci.bus;
65 while(dev && (i != bus)) {
69 if ((i == bus) && dev) {
70 parent = &dev->link[0];
75 dev = alloc_dev(parent, &chip->path[i].path);
83 printk_spew("path (%p) %s %s", dev, dev_path(dev), identical_paths?"identical":"");
84 printk_spew(" parent: (%p) %s\n",dev->bus->dev, dev_path(dev->bus->dev));
86 dev->enable = chip->path[i].enable;
87 dev->links = link + 1;
88 for(child = chip->children; child; child = child->next) {
89 if (!child->bus && child->link == i) {
90 child->bus = &dev->link[link];
94 if (dev && !chip->dev) {
98 for(child = chip->children; child; child = child->next) {
100 child->bus = &chip->dev->link[0];
105 static void enumerate_static_device_chain(struct chip *root)
108 for(chip = root; chip; chip = chip->next) {
109 void (*enumerate)(struct chip *chip);
110 enumerate = chip_enumerate;
111 if (chip->control && chip->control->enumerate) {
112 enumerate = chip->control->enumerate;
117 for(chip = root; chip; chip = chip->next) {
118 if (chip->children) {
119 enumerate_static_device_chain(chip->children);
124 void enumerate_static_devices(void)
126 enumerate_static_device_chain(&static_root);