Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/55354 )
Change subject: device: Add helper function devfn_disable() ......................................................................
device: Add helper function devfn_disable()
devfn_disable() function is used to disable a device based on given device function number. Usage of this function is limited to later coreboot boot stage. This function internally called is_dev_enabled() to check the device enable state and disable the device if its enabled.
Change-Id: Ia4a8bfec7fc95c729a5bb156f88e9aab3bf5dd41 Signed-off-by: Subrata Banik subrata.banik@intel.com --- M src/device/device_const.c M src/include/device/device.h 2 files changed, 13 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/55354/1
diff --git a/src/device/device_const.c b/src/device/device_const.c index 7e7f2f1..e59882e 100644 --- a/src/device/device_const.c +++ b/src/device/device_const.c @@ -403,3 +403,12 @@ const struct device *dev = pcidev_path_on_root(devfn); return is_dev_enabled(dev); } + +#if !DEVTREE_EARLY +void devfn_disable(unsigned int devfn) +{ + struct device *dev = pcidev_path_on_root(devfn); + if (is_dev_enabled(dev)) + dev->enabled = 0; +} +#endif diff --git a/src/include/device/device.h b/src/include/device/device.h index afa6a40..275117b 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -193,6 +193,10 @@ void add_more_links(struct device *dev, unsigned int total_links); bool is_dev_enabled(const struct device *const dev); bool is_devfn_enabled(unsigned int devfn); +/* Function used for later boot stage to override device state */ +#if !DEVTREE_EARLY +void devfn_disable(unsigned int devfn); +#endif
/* Option ROM helper functions */ void run_bios(struct device *dev, unsigned long addr);