summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/pci.c19
-rw-r--r--sys/dev/pci/pcivar.h3
2 files changed, 20 insertions, 2 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
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index c369df9b949..1e2ed3bbea5 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcivar.h,v 1.54 2007/08/01 21:43:03 deraadt Exp $ */
+/* $OpenBSD: pcivar.h,v 1.55 2007/10/22 03:08:53 fgsch Exp $ */
/* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */
/*
@@ -223,6 +223,7 @@ struct pci_matchid {
};
int pci_matchbyid(struct pci_attach_args *, const struct pci_matchid *, int);
+int pci_set_powerstate(pci_chipset_tag_t, pcitag_t, int);
/*
* Helper functions for autoconfiguration.