summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2007-10-22 03:16:36 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2007-10-22 03:16:36 +0000
commitd4c68f93dc3b59f50991aad50fc6d1175f988124 (patch)
tree28aef8afa5df31eb49206fc5747c4a1bb9d600df /sys/dev/pci
parentd69e7e7d6e618c28d4b1141d46816e29b42e3cfd (diff)
Use pci_set_powerstate(), shrinking the code and unifying the different
versions. ok by many.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/ahd_pci.c17
-rw-r--r--sys/dev/pci/auixp.c27
-rw-r--r--sys/dev/pci/cs4280.c13
-rw-r--r--sys/dev/pci/cs4281.c16
-rw-r--r--sys/dev/pci/esa.c26
-rw-r--r--sys/dev/pci/if_atw_pci.c28
-rw-r--r--sys/dev/pci/if_epic_pci.c30
-rw-r--r--sys/dev/pci/if_pcn.c20
-rw-r--r--sys/dev/pci/if_rtw_pci.c27
-rw-r--r--sys/dev/pci/if_sf_pci.c27
-rw-r--r--sys/dev/pci/if_stge.c19
11 files changed, 62 insertions, 188 deletions
diff --git a/sys/dev/pci/ahd_pci.c b/sys/dev/pci/ahd_pci.c
index 5631122e262..b4ef6d3e2ba 100644
--- a/sys/dev/pci/ahd_pci.c
+++ b/sys/dev/pci/ahd_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahd_pci.c,v 1.16 2007/10/20 22:44:01 fgsch Exp $ */
+/* $OpenBSD: ahd_pci.c,v 1.17 2007/10/22 03:16:35 fgsch Exp $ */
/*
* Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom
@@ -339,9 +339,9 @@ ahd_pci_attach(struct device *parent, struct device *self, void *aux)
struct ahd_softc *ahd = (void *)self;
pci_intr_handle_t ih;
const char *intrstr;
- pcireg_t devconfig, memtype, reg, subid;
+ pcireg_t devconfig, memtype, subid;
uint16_t device, subvendor;
- int error, ioh_valid, ioh2_valid, l, memh_valid, offset;
+ int error, ioh_valid, ioh2_valid, l, memh_valid;
ahd->dev_softc = pa;
ahd->parent_dmat = pa->pa_dmat;
@@ -457,16 +457,7 @@ ahd_pci_attach(struct device *parent, struct device *self, void *aux)
/*
* Set Power State D0.
*/
- if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PWRMGMT, &offset,
- NULL)) {
- /* Increment offset from cap register to csr register. */
- offset += 4;
- reg = pci_conf_read(pa->pa_pc, pa->pa_tag, offset);
- if ((reg & PCI_PMCSR_STATE_MASK) != PCI_PMCSR_STATE_D0) {
- pci_conf_write(pa->pa_pc, pa->pa_tag, offset,
- (reg & ~PCI_PMCSR_STATE_MASK) | PCI_PMCSR_STATE_D0);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Should we bother disabling 39Bit addressing
diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c
index 35499f99977..3c0c8a716d7 100644
--- a/sys/dev/pci/auixp.c
+++ b/sys/dev/pci/auixp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auixp.c,v 1.11 2007/09/17 00:50:46 krw Exp $ */
+/* $OpenBSD: auixp.c,v 1.12 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: auixp.c,v 1.9 2005/06/27 21:13:09 thorpej Exp $ */
/*
@@ -136,7 +136,6 @@ paddr_t auixp_mappage(void *, void *, off_t, int);
/* power management (do we support that already?) */
-int auixp_power(struct auixp_softc *, int);
#if 0
void auixp_powerhook(int, void *);
int auixp_suspend(struct auixp_softc *);
@@ -1284,7 +1283,7 @@ auixp_attach(struct device *parent, struct device *self, void *aux)
sizeof sc->sc_audev.config);
/* power up chip */
- auixp_power(sc, PCI_PMCSR_STATE_D0);
+ pci_set_powerstate(pc, tag, PCI_PMCSR_STATE_D0);
/* init chip */
if (auixp_init(sc) == -1) {
@@ -1800,28 +1799,6 @@ auixp_init(struct auixp_softc *sc)
return 0;
}
-/*
- * TODO power saving and suspend / resume support
- */
-int
-auixp_power(struct auixp_softc *sc, int state)
-{
- pcitag_t tag;
- pci_chipset_tag_t pc;
- pcireg_t data;
- int pmcapreg;
-
- tag = sc->sc_tag;
- pc = sc->sc_pct;
- if (pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &pmcapreg, 0)) {
- data = pci_conf_read(pc, tag, pmcapreg + PCI_PMCSR);
- if ((data & PCI_PMCSR_STATE_MASK) != state)
- pci_conf_write(pc, tag, pmcapreg + PCI_PMCSR, state);
- }
-
- return 0;
-}
-
#if 0
void
auixp_powerhook(int why, void *hdl)
diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c
index baefecfbf41..9485f5f37e6 100644
--- a/sys/dev/pci/cs4280.c
+++ b/sys/dev/pci/cs4280.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cs4280.c,v 1.27 2007/10/21 12:43:25 fgsch Exp $ */
+/* $OpenBSD: cs4280.c,v 1.28 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */
/*
@@ -604,8 +604,6 @@ cs4280_attach(parent, self, aux)
char const *intrstr;
pci_intr_handle_t ih;
u_int32_t mem;
- pcireg_t pmode;
- int pmreg;
/* Map I/O register */
if (pci_mapreg_map(pa, CSCC_PCI_BA0,
@@ -624,14 +622,7 @@ cs4280_attach(parent, self, aux)
sc->sc_dmatag = pa->pa_dmat;
/* Get out of power save mode if needed. */
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- pmode = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR);
- if ((pmode & PCI_PMCSR_STATE_MASK) != PCI_PMCSR_STATE_D0) {
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (pmode & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- }
- }
+ pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/* LATENCY_TIMER setting */
mem = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c
index 84b236ddd95..8e6cc2cd47c 100644
--- a/sys/dev/pci/cs4281.c
+++ b/sys/dev/pci/cs4281.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cs4281.c,v 1.19 2005/11/29 05:42:17 tedu Exp $ */
+/* $OpenBSD: cs4281.c,v 1.20 2007/10/22 03:16:35 fgsch Exp $ */
/* $Tera: cs4281.c,v 1.18 2000/12/27 14:24:45 tacha Exp $ */
/*
@@ -295,7 +295,6 @@ cs4281_attach(parent, self, aux)
pci_chipset_tag_t pc = pa->pa_pc;
char const *intrstr;
pci_intr_handle_t ih;
- int pci_pwrmgmt_cap_reg, pci_pwrmgmt_csr_reg;
/* Map I/O register */
if (pci_mapreg_map(pa, CSCC_PCI_BA0,
@@ -319,18 +318,7 @@ cs4281_attach(parent, self, aux)
* using Windows and rebooting into OpenBSD.
* On my IBM ThinkPad X20, it is set to D3 after using Windows2000.
*/
- if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PWRMGMT,
- &pci_pwrmgmt_cap_reg, 0)) {
- pcireg_t reg;
-
- pci_pwrmgmt_csr_reg = pci_pwrmgmt_cap_reg + PCI_PMCSR;
- reg = pci_conf_read(pa->pa_pc, pa->pa_tag, pci_pwrmgmt_csr_reg);
- if ((reg & PCI_PMCSR_STATE_MASK) != PCI_PMCSR_STATE_D0) {
- pci_conf_write(pc, pa->pa_tag, pci_pwrmgmt_csr_reg,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- }
- }
+ pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/* Map and establish the interrupt. */
if (pci_intr_map(pa, &ih)) {
diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c
index 938b12f1c7d..ece7ca74fd5 100644
--- a/sys/dev/pci/esa.c
+++ b/sys/dev/pci/esa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: esa.c,v 1.12 2007/09/17 00:50:46 krw Exp $ */
+/* $OpenBSD: esa.c,v 1.13 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */
/*
@@ -159,7 +159,6 @@ int esa_add_list(struct esa_voice *, struct esa_list *, u_int16_t,
void esa_remove_list(struct esa_voice *, struct esa_list *, int);
/* power management */
-int esa_power(struct esa_softc *, int);
void esa_powerhook(int, void *);
int esa_suspend(struct esa_softc *);
int esa_resume(struct esa_softc *);
@@ -1058,7 +1057,7 @@ esa_attach(struct device *parent, struct device *self, void *aux)
printf(": %s\n", intrstr);
/* Power up chip */
- esa_power(sc, PCI_PMCSR_STATE_D0);
+ pci_set_powerstate(pc, tag, PCI_PMCSR_STATE_D0);
/* Init chip */
if (esa_init(sc) == -1) {
@@ -1591,23 +1590,6 @@ esa_remove_list(struct esa_voice *vc, struct esa_list *el, int index)
return;
}
-int
-esa_power(struct esa_softc *sc, int state)
-{
- pcitag_t tag = sc->sc_tag;
- pci_chipset_tag_t pc = sc->sc_pct;
- pcireg_t data;
- int pmcapreg;
-
- if (pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &pmcapreg, 0)) {
- data = pci_conf_read(pc, tag, pmcapreg + PCI_PMCSR);
- if ((data & PCI_PMCSR_STATE_MASK) != state)
- pci_conf_write(pc, tag, pmcapreg + PCI_PMCSR, state);
- }
-
- return (0);
-}
-
void
esa_powerhook(int why, void *hdl)
{
@@ -1649,7 +1631,7 @@ esa_suspend(struct esa_softc *sc)
sc->savemem[index++] = esa_read_assp(sc,
ESA_MEMTYPE_INTERNAL_DATA, i);
- esa_power(sc, PCI_PMCSR_STATE_D3);
+ pci_set_powerstate(sc->sc_pct, sc->sc_tag, PCI_PMCSR_STATE_D3);
return (0);
}
@@ -1663,7 +1645,7 @@ esa_resume(struct esa_softc *sc) {
index = 0;
- esa_power(sc, PCI_PMCSR_STATE_D0);
+ pci_set_powerstate(sc->sc_pct, sc->sc_tag, PCI_PMCSR_STATE_D0);
delay(10000);
esa_config(sc);
diff --git a/sys/dev/pci/if_atw_pci.c b/sys/dev/pci/if_atw_pci.c
index 621c9aa35b8..170d1b53edc 100644
--- a/sys/dev/pci/if_atw_pci.c
+++ b/sys/dev/pci/if_atw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atw_pci.c,v 1.7 2005/09/08 12:44:55 jsg Exp $ */
+/* $OpenBSD: if_atw_pci.c,v 1.8 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_atw_pci.c,v 1.7 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -151,8 +151,7 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
int ioh_valid, memh_valid;
- pcireg_t reg;
- int pmreg;
+ int state;
psc->psc_pc = pa->pa_pc;
psc->psc_pcitag = pa->pa_tag;
@@ -178,28 +177,19 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
* same place in the ADM8211, but the docs do not assign its bits
* any meanings. -dcy
*/
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- reg = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR);
- switch (reg & PCI_PMCSR_STATE_MASK) {
- case PCI_PMCSR_STATE_D1:
- case PCI_PMCSR_STATE_D2:
- printf(": waking up from power state D%d\n%s",
- reg & PCI_PMCSR_STATE_MASK, sc->sc_dev.dv_xname);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- break;
- case PCI_PMCSR_STATE_D3:
+ state = pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
/*
* The card has lost all configuration data in
* this state, so punt.
*/
printf(": unable to wake up from power state D3, "
- "reboot required.\n");
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
+ "reboot required.\n");
return;
+ } else {
+ printf(": waking up from power state D%d\n%s",
+ state, sc->sc_dev.dv_xname);
}
}
diff --git a/sys/dev/pci/if_epic_pci.c b/sys/dev/pci/if_epic_pci.c
index e6f0d53ccd6..eef2e5147c2 100644
--- a/sys/dev/pci/if_epic_pci.c
+++ b/sys/dev/pci/if_epic_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_epic_pci.c,v 1.5 2006/04/20 20:31:12 miod Exp $ */
+/* $OpenBSD: if_epic_pci.c,v 1.6 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_epic_pci.c,v 1.28 2005/02/27 00:27:32 perry Exp $ */
/*-
@@ -158,32 +158,20 @@ epic_pci_attach(struct device *parent, struct device *self, void *aux)
const struct epic_pci_subsys_info *esp;
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
- pcireg_t reg;
- int pmreg, ioh_valid, memh_valid;
-
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- reg = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR);
- switch (reg & PCI_PMCSR_STATE_MASK) {
- case PCI_PMCSR_STATE_D1:
- case PCI_PMCSR_STATE_D2:
- printf(": waking up from power state D%d\n",
- reg & PCI_PMCSR_STATE_MASK);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- break;
- case PCI_PMCSR_STATE_D3:
+ int state, ioh_valid, memh_valid;
+
+ state = pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
/*
* IO and MEM are disabled. We can't enable
* the card because the BARs might be invalid.
*/
- printf(
- ": unable to wake up from power state D3, "
+ printf(": unable to wake up from power state D3, "
"reboot required.\n");
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
return;
+ } else {
+ printf(": waking up from power state D%d\n", state);
}
}
diff --git a/sys/dev/pci/if_pcn.c b/sys/dev/pci/if_pcn.c
index b1925658f39..089bf7f5f46 100644
--- a/sys/dev/pci/if_pcn.c
+++ b/sys/dev/pci/if_pcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pcn.c,v 1.15 2006/11/09 14:25:23 reyk Exp $ */
+/* $OpenBSD: if_pcn.c,v 1.16 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_pcn.c,v 1.26 2005/05/07 09:15:44 is Exp $ */
/*
@@ -584,10 +584,9 @@ pcn_attach(struct device *parent, struct device *self, void *aux)
bus_dma_segment_t seg;
int ioh_valid, memh_valid;
int i, rseg, error;
- pcireg_t pmode;
uint32_t chipid, reg;
uint8_t enaddr[ETHER_ADDR_LEN];
- int pmreg;
+ int state;
timeout_set(&sc->sc_tick_timeout, pcn_tick, sc);
@@ -614,22 +613,17 @@ pcn_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dmat = pa->pa_dmat;
/* Get it out of power save mode, if needed. */
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- pmode = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR) &
- PCI_PMCSR_STATE_MASK;
- if (pmode == PCI_PMCSR_STATE_D3) {
+ state = pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
/*
* The card has lost all configuration data in
* this state, so punt.
*/
printf(": unable to wake from power state D3\n");
return;
- }
- if (pmode != PCI_PMCSR_STATE_D0) {
- printf(": waking up from power date D%d",
- pmode);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- PCI_PMCSR_STATE_D0);
+ } else {
+ printf(": waking up from power date D%d", state);
}
}
diff --git a/sys/dev/pci/if_rtw_pci.c b/sys/dev/pci/if_rtw_pci.c
index b1d122db629..47a5961577a 100644
--- a/sys/dev/pci/if_rtw_pci.c
+++ b/sys/dev/pci/if_rtw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rtw_pci.c,v 1.8 2007/09/05 11:09:08 jsg Exp $ */
+/* $OpenBSD: if_rtw_pci.c,v 1.9 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_rtw_pci.c,v 1.1 2004/09/26 02:33:36 dyoung Exp $ */
/*-
@@ -162,8 +162,7 @@ rtw_pci_attach(struct device *parent, struct device *self, void *aux)
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
int ioh_valid, memh_valid;
- pcireg_t reg;
- int pmreg;
+ int state;
psc->psc_pc = pa->pa_pc;
psc->psc_pcitag = pa->pa_tag;
@@ -189,28 +188,18 @@ rtw_pci_attach(struct device *parent, struct device *self, void *aux)
* same place in the ADM8211, but the docs do not assign its bits
* any meanings. -dcy
*/
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- reg = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR);
- switch (reg & PCI_PMCSR_STATE_MASK) {
- case PCI_PMCSR_STATE_D1:
- case PCI_PMCSR_STATE_D2:
- printf(": waking up from power state D%d\n",
- reg & PCI_PMCSR_STATE_MASK);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- break;
- case PCI_PMCSR_STATE_D3:
+ state = pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
/*
* The card has lost all configuration data in
* this state, so punt.
*/
printf(": unable to wake up from power state D3, "
- "reboot required.\n");
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
+ "reboot required.\n");
return;
+ } else {
+ printf(": waking up from power state D%d\n", state);
}
}
diff --git a/sys/dev/pci/if_sf_pci.c b/sys/dev/pci/if_sf_pci.c
index ab9e383a62f..abe23af56c1 100644
--- a/sys/dev/pci/if_sf_pci.c
+++ b/sys/dev/pci/if_sf_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sf_pci.c,v 1.2 2006/12/06 22:43:38 martin Exp $ */
+/* $OpenBSD: if_sf_pci.c,v 1.3 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_sf_pci.c,v 1.10 2006/06/17 23:34:27 christos Exp $ */
/*-
@@ -112,29 +112,18 @@ sf_pci_attach(struct device *parent, struct device *self, void *aux)
const char *intrstr = NULL;
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
+ int state, ioh_valid, memh_valid;
pcireg_t reg;
- int pmreg, ioh_valid, memh_valid;
-
- if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PWRMGMT,
- &pmreg, 0)) {
- reg = pci_conf_read(pa->pa_pc, pa->pa_tag, pmreg + PCI_PMCSR);
- switch (reg & PCI_PMCSR_STATE_MASK) {
- case PCI_PMCSR_STATE_D1:
- case PCI_PMCSR_STATE_D2:
- printf(": waking up from power state D%d\n%s",
- reg & PCI_PMCSR_STATE_MASK, sc->sc_dev.dv_xname);
- pci_conf_write(pa->pa_pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- break;
- case PCI_PMCSR_STATE_D3:
+ state = pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
printf("%s: unable to wake up from power state D3\n",
sc->sc_dev.dv_xname);
- pci_conf_write(pa->pa_pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
return;
+ } else {
+ printf(": waking up from power state D%d\n%s",
+ state, sc->sc_dev.dv_xname);
}
}
diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c
index 5b9f40ae193..a837a531c33 100644
--- a/sys/dev/pci/if_stge.c
+++ b/sys/dev/pci/if_stge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_stge.c,v 1.35 2006/12/29 22:16:05 kettenis Exp $ */
+/* $OpenBSD: if_stge.c,v 1.36 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_stge.c,v 1.27 2005/05/16 21:35:32 bouyer Exp $ */
/*-
@@ -189,8 +189,7 @@ stge_attach(struct device *parent, struct device *self, void *aux)
bus_size_t iosize;
int ioh_valid, memh_valid;
int i, rseg, error;
- pcireg_t pmode;
- int pmreg;
+ int state;
timeout_set(&sc->sc_timeout, stge_tick, sc);
@@ -220,21 +219,17 @@ stge_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dmat = pa->pa_dmat;
/* Get it out of power save mode if needed. */
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- pmode = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR) &
- PCI_PMCSR_STATE_MASK;
- if (pmode == PCI_PMCSR_STATE_D3) {
+ state = pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
/*
* The card has lost all configuration data in
* this state, so punt.
*/
printf(": unable to wake up from power state D3\n");
return;
- }
- if (pmode != 0) {
- printf(": waking up from power state D%d\n", pmode);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- PCI_PMCSR_STATE_D0);
+ } else {
+ printf(": waking up from power state D%d\n", state);
}
}