|
@@ -1194,6 +1194,41 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
|
|
|
return pcibios_set_pcie_reset_state(dev, state);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * pci_check_pme_status - Check if given device has generated PME.
|
|
|
+ * @dev: Device to check.
|
|
|
+ *
|
|
|
+ * Check the PME status of the device and if set, clear it and clear PME enable
|
|
|
+ * (if set). Return 'true' if PME status and PME enable were both set or
|
|
|
+ * 'false' otherwise.
|
|
|
+ */
|
|
|
+bool pci_check_pme_status(struct pci_dev *dev)
|
|
|
+{
|
|
|
+ int pmcsr_pos;
|
|
|
+ u16 pmcsr;
|
|
|
+ bool ret = false;
|
|
|
+
|
|
|
+ if (!dev->pm_cap)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ pmcsr_pos = dev->pm_cap + PCI_PM_CTRL;
|
|
|
+ pci_read_config_word(dev, pmcsr_pos, &pmcsr);
|
|
|
+ if (!(pmcsr & PCI_PM_CTRL_PME_STATUS))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ /* Clear PME status. */
|
|
|
+ pmcsr |= PCI_PM_CTRL_PME_STATUS;
|
|
|
+ if (pmcsr & PCI_PM_CTRL_PME_ENABLE) {
|
|
|
+ /* Disable PME to avoid interrupt flood. */
|
|
|
+ pmcsr &= ~PCI_PM_CTRL_PME_ENABLE;
|
|
|
+ ret = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ pci_write_config_word(dev, pmcsr_pos, pmcsr);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* pci_pme_capable - check the capability of PCI device to generate PME#
|
|
|
* @dev: PCI device to handle.
|