| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <device/pci.h> |
| 6 |
#include <reset.h> |
| 7 |
|
| 8 |
void enable_static_device(struct device *dev) |
| 9 |
{ |
| 10 |
if (dev->chip_ops && dev->chip_ops->enable_dev) |
| 11 |
dev->chip_ops->enable_dev(dev); |
| 12 |
|
| 13 |
if (dev->ops && dev->ops->enable) |
| 14 |
dev->ops->enable(dev); |
| 15 |
|
| 16 |
printk(BIOS_DEBUG, "%s %s\n", dev_path(dev), |
| 17 |
dev->enabled ? "enabled" : "disabled"); |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
void enable_static_devices(struct device *bus) |
| 39 |
{ |
| 40 |
struct device *child; |
| 41 |
|
| 42 |
if (!bus->downstream) |
| 43 |
return; |
| 44 |
|
| 45 |
for (child = bus->downstream->children; child; child = child->sibling) |
| 46 |
enable_static_device(child); |
| 47 |
} |
| 48 |
|
| 49 |
void scan_generic_bus(struct device *bus) |
| 50 |
{ |
| 51 |
struct device *child; |
| 52 |
static int bus_max = 0; |
| 53 |
|
| 54 |
printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus)); |
| 55 |
|
| 56 |
if (bus->downstream) { |
| 57 |
bus->downstream->secondary = ++bus_max; |
| 58 |
|
| 59 |
for (child = bus->downstream->children; child; child = child->sibling) { |
| 60 |
enable_static_device(child); |
| 61 |
printk(BIOS_DEBUG, "bus: %s->", dev_path(child->upstream->dev)); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus)); |
| 66 |
} |
| 67 |
|
| 68 |
void scan_smbus(struct device *bus) |
| 69 |
{ |
| 70 |
scan_generic_bus(bus); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
void scan_static_bus(struct device *bus) |
| 84 |
{ |
| 85 |
printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus)); |
| 86 |
|
| 87 |
enable_static_devices(bus); |
| 88 |
|
| 89 |
if (bus->downstream) |
| 90 |
scan_bridges(bus->downstream); |
| 91 |
|
| 92 |
printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus)); |
| 93 |
} |
| 94 |
|
| 95 |
static void root_dev_reset(struct bus *bus) |
| 96 |
{ |
| 97 |
printk(BIOS_INFO, "Resetting board...\n"); |
| 98 |
board_reset(); |
| 99 |
} |
| 100 |
|
| 101 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 102 |
static const char *root_dev_acpi_name(const struct device *dev) |
| 103 |
{ |
| 104 |
return "\\_SB"; |
| 105 |
} |
| 106 |
#endif |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
struct device_operations default_dev_ops_root = { |
| 116 |
.read_resources = noop_read_resources, |
| 117 |
.set_resources = noop_set_resources, |
| 118 |
.scan_bus = scan_static_bus, |
| 119 |
.reset_bus = root_dev_reset, |
| 120 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 121 |
.acpi_name = root_dev_acpi_name, |
| 122 |
#endif |
| 123 |
}; |