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/+/81043?usp=email )
Change subject: soc/intel/xeon_sp: Add dev_find_all_devices_on_socket ......................................................................
soc/intel/xeon_sp: Add dev_find_all_devices_on_socket
Change-Id: I163eacae363334919fd66d571b7e0415e77bd52d 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, 21 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/43/81043/1
diff --git a/src/soc/intel/xeon_sp/chip_common.c b/src/soc/intel/xeon_sp/chip_common.c index 0c1d52b..7aa8c4b 100644 --- a/src/soc/intel/xeon_sp/chip_common.c +++ b/src/soc/intel/xeon_sp/chip_common.c @@ -23,20 +23,27 @@ }
/** - * Find a device of a given vendor and type for the specified socket. + * Find all device of a given vendor and type for the specified socket. * The function iterates over all PCI domains of the specified socket * and matches the PCI vendor and device ID. * * @param socket The socket where to search for the device. * @param vendor A PCI vendor ID (e.g. 0x8086 for Intel). * @param device A PCI device ID. - * @return Pointer to the device struct. + * @param from The device pointer to start search from. + * + * @return Pointer to the device struct. When there are multiple device + * instances, the caller should continue search upon a non-NULL match. */ -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 *domain, *dev = NULL; union xeon_domain_path dn;
+ if (from != NULL) + dev = from; + while ((dev = dev_find_device(vendor, device, dev))) { domain = dev_get_pci_domain(dev); if (!domain) @@ -50,6 +57,15 @@ return NULL; }
+/* + * Find device of a given vendor and type for the specified socket. + * The function will return at the 1st match. + */ +struct device *dev_find_device_on_socket(uint8_t socket, u16 vendor, u16 device) +{ + return dev_find_all_devices_on_socket(socket, vendor, device, NULL); +} + /** * Returns the socket ID where the specified device is connected to. * This is an integer in the range [0, CONFIG_MAX_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 556e510..e5e6da6 100644 --- a/src/soc/intel/xeon_sp/include/soc/chip_common.h +++ b/src/soc/intel/xeon_sp/include/soc/chip_common.h @@ -23,6 +23,8 @@
void soc_create_ioat_domains(union xeon_domain_path path, struct bus *bus, const xSTACK_RES *sr); 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); int iio_pci_domain_socket_from_dev(struct device *dev); int iio_pci_domain_stack_from_dev(struct device *dev);