Lean Sheng Tan has submitted this change. ( https://review.coreboot.org/c/coreboot/+/84793?usp=email )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pci: Add method to read PME capability ......................................................................
pci: Add method to read PME capability
Add a helper method to read the PME capability. Will be used in the following commit.
Change-Id: Id1fdc98c9ce86d3ddf8056bb609afc58008cf2e9 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/84793 Reviewed-by: Shuo Liu shuo.liu@intel.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Subrata Banik subratabanik@google.com --- M src/device/pci_device.c M src/include/device/pci.h 2 files changed, 19 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Subrata Banik: Looks good to me, approved Shuo Liu: Looks good to me, approved
diff --git a/src/device/pci_device.c b/src/device/pci_device.c index a2ad2b3..d03d88d 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -1346,6 +1346,24 @@ }
/** + * Returns if the device support PMEs. + * + * @param dev Pointer to the device structure. + * @return Returns true when the device support PMEs. The PME generation can be + * disabled though. + */ +bool pci_has_pme_pin(const struct device *dev) +{ + const uint16_t cap = pci_find_capability(dev, PCI_CAP_ID_PM); + if (!cap) + return false; + + const uint16_t pmecap = pci_read_config16(dev, cap + PCI_PM_PMC); + + return !!(pmecap & PCI_PM_CAP_PME); +} + +/** * PCI devices that are marked as "hidden" do not get probed. However, the same * initialization logic is still performed as if it were. This is useful when * devices would like to be described in the devicetree.cb file, and/or present diff --git a/src/include/device/pci.h b/src/include/device/pci.h index 2e75195..83d6628 100644 --- a/src/include/device/pci.h +++ b/src/include/device/pci.h @@ -98,6 +98,7 @@ void pci_dev_init(struct device *dev); unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev); uint16_t pci_find_cap_recursive(const struct device *dev, uint16_t cap); +bool pci_has_pme_pin(const struct device *dev);
const char *pin_to_str(int pin); int get_pci_irq_pins(struct device *dev, struct device **parent_bdg);