1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
8 const char mainboard_name
[] = CONFIG_MAINBOARD_VENDOR
" " CONFIG_MAINBOARD_PART_NUMBER
;
10 void enable_static_device(struct device
*dev
)
12 if (dev
->chip_ops
&& dev
->chip_ops
->enable_dev
)
13 dev
->chip_ops
->enable_dev(dev
);
15 if (dev
->ops
&& dev
->ops
->enable
)
16 dev
->ops
->enable(dev
);
18 printk(BIOS_DEBUG
, "%s %s\n", dev_path(dev
),
19 dev
->enabled
? "enabled" : "disabled");
23 * Enable devices on static buses.
25 * The enumeration of certain buses is purely static. The existence of
26 * devices on those buses can be completely determined at compile time
27 * and is specified in the config file. Typical examples are the 'PNP'
28 * devices on a legacy ISA/LPC bus. There is no need of probing of any kind,
29 * the only thing we have to do is to walk through the bus and
30 * enable or disable devices as indicated in the config file.
32 * On the other hand, some devices are virtual and their existence is
33 * artificial. They can not be probed at run time. One example is the
34 * debug device. Those virtual devices have to be listed in the config
35 * file under some static bus in order to be enumerated at run time.
37 * @param bus Pointer to the device to which the static buses are attached to.
40 void enable_static_devices(struct device
*bus
)
45 for (link
= bus
->link_list
; link
; link
= link
->next
) {
46 for (child
= link
->children
; child
; child
= child
->sibling
) {
47 enable_static_device(child
);
52 void scan_generic_bus(struct device
*bus
)
56 static int bus_max
= 0;
58 printk(BIOS_SPEW
, "%s for %s\n", __func__
, dev_path(bus
));
60 for (link
= bus
->link_list
; link
; link
= link
->next
) {
62 link
->secondary
= ++bus_max
;
64 for (child
= link
->children
; child
; child
= child
->sibling
) {
65 enable_static_device(child
);
66 printk(BIOS_DEBUG
, "bus: %s[%d]->", dev_path(child
->bus
->dev
),
67 child
->bus
->link_num
);
71 printk(BIOS_SPEW
, "%s for %s done\n", __func__
, dev_path(bus
));
74 void scan_smbus(struct device
*bus
)
76 scan_generic_bus(bus
);
80 * Default scan_bus() implementation
82 * This is the default implementation for buses that can't
83 * be probed at runtime. It simply walks through the topology
84 * given by the mainboard's `devicetree.cb`.
86 * First, all direct descendants of the given device are
87 * enabled. Then, downstream buses are scanned.
89 void scan_static_bus(struct device
*bus
)
93 printk(BIOS_SPEW
, "%s for %s\n", __func__
, dev_path(bus
));
95 enable_static_devices(bus
);
97 for (link
= bus
->link_list
; link
; link
= link
->next
)
100 printk(BIOS_SPEW
, "%s for %s done\n", __func__
, dev_path(bus
));
103 static void root_dev_reset(struct bus
*bus
)
105 printk(BIOS_INFO
, "Resetting board...\n");
109 #if CONFIG(HAVE_ACPI_TABLES)
110 static const char *root_dev_acpi_name(const struct device
*dev
)
117 * Default device operation for root device.
119 * This is the default device operation for root devices. These operations
120 * should be fully usable as is. However the chip_operations::enable_dev()
121 * of a motherboard can override this if you want non-default behavior.
123 struct device_operations default_dev_ops_root
= {
124 .read_resources
= noop_read_resources
,
125 .set_resources
= noop_set_resources
,
126 .scan_bus
= scan_static_bus
,
127 .reset_bus
= root_dev_reset
,
128 #if CONFIG(HAVE_ACPI_TABLES)
129 .acpi_name
= root_dev_acpi_name
,