diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -2951,6 +2951,32 @@ } } +/* Clear any active PME# and enable PME# generation. */ +void +pci_enable_pme(device_t dev) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + pcicfgregs *cfg = &dinfo->cfg; + uint16_t status; + + if (cfg->pp.pp_location != 0) { + status = pci_read_config(dev, dinfo->cfg.pp.pp_location + + PCIR_POWER_STATUS, 2); + status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; + pci_write_config(dev, dinfo->cfg.pp.pp_location + + PCIR_POWER_STATUS, status, 2); + } +} + +bool +pci_has_pm(device_t dev) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + pcicfgregs *cfg = &dinfo->cfg; + + return (cfg->pp.pp_location != 0); +} + /* * Some convenience functions for PCI device drivers. */ diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -685,6 +685,8 @@ int pci_set_max_read_req(device_t dev, int size); int pci_power_reset(device_t dev); void pci_clear_pme(device_t dev); +void pci_enable_pme(device_t dev); +bool pci_has_pm(device_t dev); uint32_t pcie_read_config(device_t dev, int reg, int width); void pcie_write_config(device_t dev, int reg, uint32_t value, int width); uint32_t pcie_adjust_config(device_t dev, int reg, uint32_t mask,