Tim Wawrzynczak has uploaded this change for review.

View Change

device: Add pci_s_dev_is_wake_source function

This function is the SIMPLE_DEVICE equivalent of
`pci_dev_is_wake_source`, which is required so that elog can use this
function, which since it runs in SMM as well, it uses the simple device
model.

Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: Ie5583c04366c9a16bc1b00a6892d39eeafe5da49
---
M src/device/pci_ops.c
M src/include/device/pci_ops.h
2 files changed, 23 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/47260/1
diff --git a/src/device/pci_ops.c b/src/device/pci_ops.c
index 90f45bf..cb833f8 100644
--- a/src/device/pci_ops.c
+++ b/src/device/pci_ops.c
@@ -78,3 +78,18 @@
{
die("PCI: dev is NULL!\n");
}
+
+bool pci_s_dev_is_wake_source(pci_devfn_t dev)
+{
+ unsigned int pm_cap;
+ uint16_t pmcs;
+
+ pm_cap = pci_s_find_capability(dev, PCI_CAP_ID_PM);
+ if (!pm_cap)
+ return false;
+
+ pmcs = pci_s_read_config16(dev, pm_cap + PCI_PM_CTRL);
+
+ /* PCI Device is a wake source if PME_ENABLE and PME_STATUS are set in PMCS register. */
+ return (pmcs & PCI_PM_CTRL_PME_ENABLE) && (pmcs & PCI_PM_CTRL_PME_STATUS);
+}
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h
index cdf02d6..1738cd1 100644
--- a/src/include/device/pci_ops.h
+++ b/src/include/device/pci_ops.h
@@ -209,4 +209,12 @@
return pci_s_find_capability(PCI_BDF(dev), cap);
}

+/*
+ * Determine if the given PCI device is the source of wake from sleep by checking PME_STATUS and
+ * PME_ENABLE bits in PM control and status register.
+ *
+ * Returns true if PCI device is wake source, false otherwise.
+ */
+bool pci_s_dev_is_wake_source(pci_devfn_t dev);
+
#endif /* PCI_OPS_H */

To view, visit change 47260. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ie5583c04366c9a16bc1b00a6892d39eeafe5da49
Gerrit-Change-Number: 47260
Gerrit-PatchSet: 1
Gerrit-Owner: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-MessageType: newchange