Attention is currently required from: Arthur Heymans, Christian Walter, Johnny Lin, Lean Sheng Tan, Patrick Rudolph, Tim Chu.
Shuo Liu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81109?usp=email )
Change subject: soc/intel/xeon_sp: Add utils to find stack from device or domain ......................................................................
soc/intel/xeon_sp: Add utils to find stack from device or domain
TEST=intel/archercity CRB
Change-Id: Id0bf83975e66937a3860378074749dbecbef4eb9 Signed-off-by: Shuo Liu shuo.liu@intel.com --- M src/soc/intel/xeon_sp/chip_common.c M src/soc/intel/xeon_sp/include/soc/chip_common.h 2 files changed, 26 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/09/81109/1
diff --git a/src/soc/intel/xeon_sp/chip_common.c b/src/soc/intel/xeon_sp/chip_common.c index f061b87..fbeedf1 100644 --- a/src/soc/intel/xeon_sp/chip_common.c +++ b/src/soc/intel/xeon_sp/chip_common.c @@ -11,19 +11,37 @@ #include <soc/util.h> #include <stdlib.h>
-static const STACK_RES *domain_to_stack_res(const struct device *dev) +const STACK_RES *domain_to_stack_res(struct device *dev) { - assert(dev->path.type == DEVICE_PATH_DOMAIN); + if ((!dev) && (dev->path.type != DEVICE_PATH_DOMAIN)) + return NULL; + + const IIO_UDS *hob = get_iio_uds(); + if (hob == NULL) + return NULL; + const union xeon_domain_path dn = { .domain_path = dev->path.domain.domain }; - - const IIO_UDS *hob = get_iio_uds(); - assert(hob != NULL); - return &hob->PlatformData.IIO_resource[dn.socket].StackRes[dn.stack]; }
+const STACK_RES *device_to_stack_res(struct device *dev) +{ + if (!dev) + return NULL; + + struct device *domain; + if (dev->path.type == DEVICE_PATH_DOMAIN) + domain = dev; + else + domain = dev_get_pci_domain(dev); + if (!domain) + return NULL; + + return domain_to_stack_res(domain); +} + /** * Find all device of a given vendor and type for the specified socket. * The function iterates over all PCI domains of the specified socket diff --git a/src/soc/intel/xeon_sp/include/soc/chip_common.h b/src/soc/intel/xeon_sp/include/soc/chip_common.h index d61f23a..faf9717 100644 --- a/src/soc/intel/xeon_sp/include/soc/chip_common.h +++ b/src/soc/intel/xeon_sp/include/soc/chip_common.h @@ -58,6 +58,8 @@ struct device *dev_find_device_on_socket(uint8_t socket, u16 vendor, u16 device); struct device *dev_find_all_devices_on_socket(uint8_t socket, u16 vendor, u16 device, struct device *from); struct device *dev_find_all_devices_on_stack(uint8_t socket, uint8_t stack, u16 vendor, u16 device, struct device *from); +const STACK_RES *domain_to_stack_res(struct device *dev); +const STACK_RES *device_to_stack_res(struct device *dev);
int iio_pci_domain_socket_from_dev(struct device *dev); int iio_pci_domain_stack_from_dev(struct device *dev);