mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: device/device_util: Add function to determine bridge state
Add a method to get the state of a bridge device.
Return true if at least one enabled device on the secondary
bus is found.
Useful to disable non hotplugable bridges without any devices attached.
BUG=none
BRANCH=none
TEST=none
Change-Id: Ib399f149940b6686273bf7818463a3f25ee53f96
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: a6909f88e9
Original-Change-Id: Ic8fe539d233031d4d177b03dd2c03edb5ab8c88d
Original-Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Original-Reviewed-on: https://review.coreboot.org/19817
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Philippe Mathieu-Daud <philippe.mathieu.daude@gmail.com>
Original-Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://chromium-review.googlesource.com/523972
This commit is contained in:
parent
e8e84a4166
commit
b4f329c78d
2 changed files with 26 additions and 0 deletions
|
@ -775,6 +775,31 @@ void disable_children(struct bus *bus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns true if the device is an enabled bridge that has at least
|
||||||
|
* one enabled device on its secondary bus.
|
||||||
|
*/
|
||||||
|
bool dev_is_active_bridge(device_t dev)
|
||||||
|
{
|
||||||
|
struct bus *link;
|
||||||
|
device_t child;
|
||||||
|
|
||||||
|
if (!dev || !dev->enabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!dev->link_list || !dev->link_list->children)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (link = dev->link_list; link; link = link->next) {
|
||||||
|
for (child = link->children; child; child = child->sibling) {
|
||||||
|
if (child->enabled)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void resource_tree(struct device *root, int debug_level, int depth)
|
static void resource_tree(struct device *root, int debug_level, int depth)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
|
@ -190,6 +190,7 @@ u32 dev_path_encode(device_t dev);
|
||||||
const char *bus_path(struct bus *bus);
|
const char *bus_path(struct bus *bus);
|
||||||
void dev_set_enabled(device_t dev, int enable);
|
void dev_set_enabled(device_t dev, int enable);
|
||||||
void disable_children(struct bus *bus);
|
void disable_children(struct bus *bus);
|
||||||
|
bool dev_is_active_bridge(device_t dev);
|
||||||
|
|
||||||
/* Option ROM helper functions */
|
/* Option ROM helper functions */
|
||||||
void run_bios(struct device *dev, unsigned long addr);
|
void run_bios(struct device *dev, unsigned long addr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue