autoport: Add support for Haswell-Lynx Point platform
[coreboot.git] / src / device / root_device.c
blob0164b19e99a810dc60dacf48fc586327fd715bbd
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <reset.h>
8 void enable_static_device(struct device *dev)
10 if (dev->chip_ops && dev->chip_ops->enable_dev)
11 dev->chip_ops->enable_dev(dev);
13 if (dev->ops && dev->ops->enable)
14 dev->ops->enable(dev);
16 printk(BIOS_DEBUG, "%s %s\n", dev_path(dev),
17 dev->enabled ? "enabled" : "disabled");
20 /**
21 * Enable devices on static buses.
23 * The enumeration of certain buses is purely static. The existence of
24 * devices on those buses can be completely determined at compile time
25 * and is specified in the config file. Typical examples are the 'PNP'
26 * devices on a legacy ISA/LPC bus. There is no need of probing of any kind,
27 * the only thing we have to do is to walk through the bus and
28 * enable or disable devices as indicated in the config file.
30 * On the other hand, some devices are virtual and their existence is
31 * artificial. They can not be probed at run time. One example is the
32 * debug device. Those virtual devices have to be listed in the config
33 * file under some static bus in order to be enumerated at run time.
35 * @param bus Pointer to the device to which the static buses are attached to.
38 void enable_static_devices(struct device *bus)
40 struct device *child;
42 if (!bus->downstream)
43 return;
45 for (child = bus->downstream->children; child; child = child->sibling)
46 enable_static_device(child);
49 void scan_generic_bus(struct device *bus)
51 struct device *child;
52 static int bus_max = 0;
54 printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
56 if (bus->downstream) {
57 bus->downstream->secondary = ++bus_max;
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));
65 printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
68 void scan_smbus(struct device *bus)
70 scan_generic_bus(bus);
74 * Default scan_bus() implementation
76 * This is the default implementation for buses that can't
77 * be probed at runtime. It simply walks through the topology
78 * given by the mainboard's `devicetree.cb`.
80 * First, all direct descendants of the given device are
81 * enabled. Then, downstream buses are scanned.
83 void scan_static_bus(struct device *bus)
85 printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
87 enable_static_devices(bus);
89 if (bus->downstream)
90 scan_bridges(bus->downstream);
92 printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
95 static void root_dev_reset(struct bus *bus)
97 printk(BIOS_INFO, "Resetting board...\n");
98 board_reset();
101 #if CONFIG(HAVE_ACPI_TABLES)
102 static const char *root_dev_acpi_name(const struct device *dev)
104 return "\\_SB";
106 #endif
109 * Default device operation for root device.
111 * This is the default device operation for root devices. These operations
112 * should be fully usable as is. However the chip_operations::enable_dev()
113 * of a motherboard can override this if you want non-default behavior.
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