diff options
| author | 2007-10-22 03:08:53 +0000 | |
|---|---|---|
| committer | 2007-10-22 03:08:53 +0000 | |
| commit | e2d4b8c17119328d90521c16198b58791989cf8f (patch) | |
| tree | 062b5b9c5a1c1779adeacc1688285197fb6fdf5c /sys/dev/pci/pci.c | |
| parent | sync (diff) | |
| download | wireguard-openbsd-e2d4b8c17119328d90521c16198b58791989cf8f.tar.xz wireguard-openbsd-e2d4b8c17119328d90521c16198b58791989cf8f.zip | |
Add pci_set_powerstate() to change the pm state for a given device.
ok by many.
Diffstat (limited to 'sys/dev/pci/pci.c')
| -rw-r--r-- | sys/dev/pci/pci.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index fa79de1ffcc..8a56aef3468 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.50 2007/05/21 22:10:45 kettenis Exp $ */ +/* $OpenBSD: pci.c,v 1.51 2007/10/22 03:08:53 fgsch Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -410,6 +410,23 @@ pci_find_device(struct pci_attach_args *pa, return (0); } +int +pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int state) +{ + pcireg_t reg; + int offset; + + if (pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &offset, 0)) { + reg = pci_conf_read(pc, tag, offset + PCI_PMCSR); + if ((reg & PCI_PMCSR_STATE_MASK) != state) { + pci_conf_write(pc, tag, offset + PCI_PMCSR, + (reg & ~PCI_PMCSR_STATE_MASK) | state); + return (reg & PCI_PMCSR_STATE_MASK); + } + } + return (state); +} + #ifndef PCI_MACHDEP_ENUMERATE_BUS /* * Generic PCI bus enumeration routine. Used unless machine-dependent |
