summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2012-10-18 21:44:22 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2012-10-18 21:44:22 +0000
commitc6f059840162b2c543b98d25d52c1ab9bef6abdb (patch)
tree995710b7c307dbd984f1a701ba82f8dd58ea7968 /sys
parent3009bb760d67d343c20274e3b032edd5b53e2ea3 (diff)
Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had bugs in them, especially missing delay() calls. Some of them were doing things our PCI subsystem is now responsible for handling. If you have any of the affected devices, please keep an eye out for regressions. ok kettenis
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/esareg.h7
-rw-r--r--sys/dev/pci/if_atw_pci.c14
-rw-r--r--sys/dev/pci/if_dc_pci.c48
-rw-r--r--sys/dev/pci/if_epic_pci.c17
-rw-r--r--sys/dev/pci/if_lge.c33
-rw-r--r--sys/dev/pci/if_lgereg.h7
-rw-r--r--sys/dev/pci/if_msk.c34
-rw-r--r--sys/dev/pci/if_nge.c33
-rw-r--r--sys/dev/pci/if_ngereg.h7
-rw-r--r--sys/dev/pci/if_pcn.c11
-rw-r--r--sys/dev/pci/if_re_pci.c30
-rw-r--r--sys/dev/pci/if_rtw_pci.c24
-rw-r--r--sys/dev/pci/if_sf_pci.c11
-rw-r--r--sys/dev/pci/if_sis.c31
-rw-r--r--sys/dev/pci/if_sisreg.h7
-rw-r--r--sys/dev/pci/if_sk.c34
-rw-r--r--sys/dev/pci/if_skreg.h7
-rw-r--r--sys/dev/pci/if_ste.c31
-rw-r--r--sys/dev/pci/if_stereg.h7
-rw-r--r--sys/dev/pci/if_stge.c14
-rw-r--r--sys/dev/pci/if_vr.c37
-rw-r--r--sys/dev/pci/if_vrreg.h7
-rw-r--r--sys/dev/pci/if_wb.c34
-rw-r--r--sys/dev/pci/if_wbreg.h7
-rw-r--r--sys/dev/pci/if_xl_pci.c70
25 files changed, 59 insertions, 503 deletions
diff --git a/sys/dev/pci/esareg.h b/sys/dev/pci/esareg.h
index a393283cfea..101a50beade 100644
--- a/sys/dev/pci/esareg.h
+++ b/sys/dev/pci/esareg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: esareg.h,v 1.1 2002/04/08 01:47:33 frantzen Exp $ */
+/* $OpenBSD: esareg.h,v 1.2 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: esareg.h,v 1.8 2002/03/06 18:30:31 jmcneill Exp $ */
/*
@@ -89,11 +89,6 @@
#define ESA_INT_CLK_SRC_NOT_PCI 0x00100000
#define ESA_INT_CLK_MULT_ENABLE 0x80000000
-#define ESA_PCI_ACPI_CONTROL 0x54
-#define ESA_PCI_ACPI_D0 0x00000000
-#define ESA_PCI_ACPI_D1 0xB4F70000
-#define ESA_PCI_ACPI_D2 0xB4F7B4F7
-
#define ESA_PCI_USER_CONFIG 0x58
#define ESA_EXT_PCI_MASTER_ENABLE 0x00000001
#define ESA_SPDIF_OUT_SELECT 0x00000002
diff --git a/sys/dev/pci/if_atw_pci.c b/sys/dev/pci/if_atw_pci.c
index 2b44e73b3c0..a2a14d33f9a 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.14 2011/04/03 15:36:02 jasper Exp $ */
+/* $OpenBSD: if_atw_pci.c,v 1.15 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: if_atw_pci.c,v 1.7 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -148,7 +148,6 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
bus_space_handle_t ioh, memh;
bus_size_t iosize, memsize;
int ioh_valid, memh_valid;
- int state;
psc->psc_pc = pa->pa_pc;
psc->psc_pcitag = pa->pa_tag;
@@ -174,16 +173,7 @@ 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
*/
- state = pci_set_powerstate(pc, pa->pa_tag, 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");
- return;
- }
+ pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map the device.
diff --git a/sys/dev/pci/if_dc_pci.c b/sys/dev/pci/if_dc_pci.c
index bf8dd577537..6083b4947be 100644
--- a/sys/dev/pci/if_dc_pci.c
+++ b/sys/dev/pci/if_dc_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_dc_pci.c,v 1.67 2010/08/27 19:54:03 deraadt Exp $ */
+/* $OpenBSD: if_dc_pci.c,v 1.68 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -125,7 +125,6 @@ struct dc_type dc_devs[] = {
int dc_pci_match(struct device *, void *, void *);
void dc_pci_attach(struct device *, struct device *, void *);
int dc_pci_detach(struct device *, int);
-void dc_pci_acpi(struct device *, void *);
struct dc_pci_softc {
struct dc_softc psc_softc;
@@ -170,46 +169,6 @@ dc_pci_match(struct device *parent, void *match, void *aux)
return (0);
}
-void
-dc_pci_acpi(struct device *self, void *aux)
-{
- struct dc_pci_softc *psc = (struct dc_pci_softc *)self;
- struct dc_softc *sc = &psc->psc_softc;
- struct pci_attach_args *pa = (struct pci_attach_args *)aux;
- pci_chipset_tag_t pc = pa->pa_pc;
- u_int32_t r, cptr;
-
- /* Find the location of the capabilities block */
- cptr = pci_conf_read(pc, pa->pa_tag, DC_PCI_CCAP) & 0xFF;
-
- r = pci_conf_read(pc, pa->pa_tag, cptr) & 0xFF;
- if (r == 0x01) {
-
- r = pci_conf_read(pc, pa->pa_tag, cptr + PCI_PMCSR);
- if (r & DC_PSTATE_D3) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, DC_PCI_CFBIO);
- membase = pci_conf_read(pc, pa->pa_tag, DC_PCI_CFBMA);
- irq = pci_conf_read(pc, pa->pa_tag, DC_PCI_CFIT);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode "
- "-- setting to D0\n", sc->sc_dev.dv_xname,
- r & DC_PSTATE_D3);
- r &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag, cptr + PCI_PMCSR, r);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, DC_PCI_CFBIO, iobase);
- pci_conf_write(pc, pa->pa_tag, DC_PCI_CFBMA, membase);
- pci_conf_write(pc, pa->pa_tag, DC_PCI_CFIT, irq);
- }
- }
- return;
-}
-
/*
* Attach the interface. Allocate softc structures, do ifmedia
* setup and ethernet/BPF attach.
@@ -229,10 +188,7 @@ dc_pci_attach(struct device *parent, struct device *self, void *aux)
psc->psc_pc = pa->pa_pc;
sc->sc_dmat = pa->pa_dmat;
- /*
- * Handle power management nonsense.
- */
- dc_pci_acpi(self, aux);
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
sc->dc_csid = pci_conf_read(pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
diff --git a/sys/dev/pci/if_epic_pci.c b/sys/dev/pci/if_epic_pci.c
index 4b4b54518f4..66ad0914b5e 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.10 2011/04/03 15:36:02 jasper Exp $ */
+/* $OpenBSD: if_epic_pci.c,v 1.11 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: if_epic_pci.c,v 1.28 2005/02/27 00:27:32 perry Exp $ */
/*-
@@ -146,18 +146,9 @@ 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;
- int state, ioh_valid, memh_valid;
-
- state = pci_set_powerstate(pc, pa->pa_tag, 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, "
- "reboot required.\n");
- return;
- }
+ int ioh_valid, memh_valid;
+
+ pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map the device.
diff --git a/sys/dev/pci/if_lge.c b/sys/dev/pci/if_lge.c
index 5390a9718a0..1169875c7d0 100644
--- a/sys/dev/pci/if_lge.c
+++ b/sys/dev/pci/if_lge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_lge.c,v 1.55 2011/06/22 16:44:27 tedu Exp $ */
+/* $OpenBSD: if_lge.c,v 1.56 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
* Copyright (c) 1997, 1998, 1999, 2000, 2001
@@ -404,42 +404,13 @@ lge_attach(struct device *parent, struct device *self, void *aux)
bus_dmamap_t dmamap;
int rseg;
u_char eaddr[ETHER_ADDR_LEN];
- pcireg_t command;
#ifndef LGE_USEIOSPACE
pcireg_t memtype;
#endif
struct ifnet *ifp;
caddr_t kva;
- /*
- * Handle power management nonsense.
- */
- DPRINTFN(5, ("Preparing for conf read\n"));
- command = pci_conf_read(pc, pa->pa_tag, LGE_PCI_CAPID) & 0x000000FF;
- if (command == 0x01) {
- command = pci_conf_read(pc, pa->pa_tag, LGE_PCI_PWRMGMTCTRL);
- if (command & LGE_PSTATE_MASK) {
- pcireg_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, LGE_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, LGE_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, LGE_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode "
- "-- setting to D0\n", sc->sc_dv.dv_xname,
- command & LGE_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag,
- LGE_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, LGE_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, LGE_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, LGE_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_lgereg.h b/sys/dev/pci/if_lgereg.h
index a8ca1970886..103a1ca0aef 100644
--- a/sys/dev/pci/if_lgereg.h
+++ b/sys/dev/pci/if_lgereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_lgereg.h,v 1.6 2006/05/28 00:20:21 brad Exp $ */
+/* $OpenBSD: if_lgereg.h,v 1.7 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
* Copyright (c) 1997, 1998, 1999, 2000, 2001
@@ -585,11 +585,6 @@ struct lge_softc {
#define LGE_PCI_PWRMGMTCAP 0x52 /* 16 bits */
#define LGE_PCI_PWRMGMTCTRL 0x54 /* 16 bits */
-#define LGE_PSTATE_MASK 0x0003
-#define LGE_PSTATE_D0 0x0000
-#define LGE_PSTATE_D1 0x0001
-#define LGE_PSTATE_D2 0x0002
-#define LGE_PSTATE_D3 0x0003
#define LGE_PME_EN 0x0010
#define LGE_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_msk.c b/sys/dev/pci/if_msk.c
index a1d4ef4abde..e60d3458c68 100644
--- a/sys/dev/pci/if_msk.c
+++ b/sys/dev/pci/if_msk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_msk.c,v 1.94 2012/03/28 12:02:49 jsg Exp $ */
+/* $OpenBSD: if_msk.c,v 1.95 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -1118,7 +1118,7 @@ mskc_attach(struct device *parent, struct device *self, void *aux)
struct pci_attach_args *pa = aux;
struct skc_attach_args skca;
pci_chipset_tag_t pc = pa->pa_pc;
- pcireg_t command, memtype;
+ pcireg_t memtype;
pci_intr_handle_t ih;
const char *intrstr = NULL;
u_int8_t hw, pmd;
@@ -1127,35 +1127,7 @@ mskc_attach(struct device *parent, struct device *self, void *aux)
DPRINTFN(2, ("begin mskc_attach\n"));
- /*
- * Handle power management nonsense.
- */
- command = pci_conf_read(pc, pa->pa_tag, SK_PCI_CAPID) & 0x000000FF;
-
- if (command == 0x01) {
- command = pci_conf_read(pc, pa->pa_tag, SK_PCI_PWRMGMTCTRL);
- if (command & SK_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, SK_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, SK_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, SK_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s chip is in D%d power mode "
- "-- setting to D0\n", sc->sk_dev.dv_xname,
- command & SK_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag,
- SK_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, SK_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, SK_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, SK_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c
index d85594f779b..d806adf868a 100644
--- a/sys/dev/pci/if_nge.c
+++ b/sys/dev/pci/if_nge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nge.c,v 1.71 2011/06/22 16:44:27 tedu Exp $ */
+/* $OpenBSD: if_nge.c,v 1.72 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
* Copyright (c) 1997, 1998, 1999, 2000, 2001
@@ -729,42 +729,13 @@ nge_attach(parent, self, aux)
bus_dmamap_t dmamap;
int rseg;
u_char eaddr[ETHER_ADDR_LEN];
- pcireg_t command;
#ifndef NGE_USEIOSPACE
pcireg_t memtype;
#endif
struct ifnet *ifp;
caddr_t kva;
- /*
- * Handle power management nonsense.
- */
- DPRINTFN(5, ("%s: preparing for conf read\n", sc->sc_dv.dv_xname));
- command = pci_conf_read(pc, pa->pa_tag, NGE_PCI_CAPID) & 0x000000FF;
- if (command == 0x01) {
- command = pci_conf_read(pc, pa->pa_tag, NGE_PCI_PWRMGMTCTRL);
- if (command & NGE_PSTATE_MASK) {
- pcireg_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, NGE_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, NGE_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, NGE_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode "
- "-- setting to D0\n", sc->sc_dv.dv_xname,
- command & NGE_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag,
- NGE_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, NGE_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, NGE_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, NGE_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_ngereg.h b/sys/dev/pci/if_ngereg.h
index f878bb4cf78..c9f9db59298 100644
--- a/sys/dev/pci/if_ngereg.h
+++ b/sys/dev/pci/if_ngereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ngereg.h,v 1.8 2006/05/28 00:20:21 brad Exp $ */
+/* $OpenBSD: if_ngereg.h,v 1.9 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
* Copyright (c) 1997, 1998, 1999, 2000, 2001
@@ -710,11 +710,6 @@ struct nge_softc {
#define NGE_PCI_PWRMGMTCAP 0x52 /* 16 bits */
#define NGE_PCI_PWRMGMTCTRL 0x54 /* 16 bits */
-#define NGE_PSTATE_MASK 0x0003
-#define NGE_PSTATE_D0 0x0000
-#define NGE_PSTATE_D1 0x0001
-#define NGE_PSTATE_D2 0x0002
-#define NGE_PSTATE_D3 0x0003
#define NGE_PME_EN 0x0010
#define NGE_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_pcn.c b/sys/dev/pci/if_pcn.c
index 222fa28bbe0..980f903825f 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.24 2011/04/03 15:36:02 jasper Exp $ */
+/* $OpenBSD: if_pcn.c,v 1.25 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: if_pcn.c,v 1.26 2005/05/07 09:15:44 is Exp $ */
/*
@@ -606,15 +606,6 @@ pcn_attach(struct device *parent, struct device *self, void *aux)
/* Get it out of power save mode, if needed. */
state = pci_set_powerstate(pc, pa->pa_tag, 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");
- return;
- }
/*
* Reset the chip to a known state. This also puts the
diff --git a/sys/dev/pci/if_re_pci.c b/sys/dev/pci/if_re_pci.c
index d030578bd28..8792b77fb7e 100644
--- a/sys/dev/pci/if_re_pci.c
+++ b/sys/dev/pci/if_re_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_re_pci.c,v 1.35 2012/09/26 16:32:22 rfreeman Exp $ */
+/* $OpenBSD: if_re_pci.c,v 1.36 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
@@ -135,34 +135,8 @@ re_pci_attach(struct device *parent, struct device *self, void *aux)
pci_chipset_tag_t pc = pa->pa_pc;
pci_intr_handle_t ih;
const char *intrstr = NULL;
- pcireg_t command;
- /*
- * Handle power management nonsense.
- */
-
- command = pci_conf_read(pc, pa->pa_tag, RL_PCI_CAPID) & 0x000000FF;
-
- if (command == 0x01) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, RL_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, RL_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, RL_PCI_INTLINE);
-
-#if 0
- /* Reset the power state. */
- printf(": chip is in D%d power mode "
- "-- setting to D0", command & RL_PSTATE_MASK);
-#endif
- command &= 0xFFFFFFFC;
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, RL_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, RL_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, RL_PCI_INTLINE, irq);
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
#ifndef SMALL_KERNEL
/* Enable power management for wake on lan. */
diff --git a/sys/dev/pci/if_rtw_pci.c b/sys/dev/pci/if_rtw_pci.c
index fe6a7bb17ed..230cce32364 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.15 2011/04/03 15:36:02 jasper Exp $ */
+/* $OpenBSD: if_rtw_pci.c,v 1.16 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: if_rtw_pci.c,v 1.1 2004/09/26 02:33:36 dyoung Exp $ */
/*-
@@ -161,7 +161,6 @@ rtw_pci_attach(struct device *parent, struct device *self, void *aux)
bus_space_handle_t ioh, memh;
bus_size_t iosize, memsize;
int ioh_valid, memh_valid;
- int state;
psc->psc_pc = pa->pa_pc;
psc->psc_pcitag = pa->pa_tag;
@@ -177,26 +176,7 @@ rtw_pci_attach(struct device *parent, struct device *self, void *aux)
*/
sc->sc_rev = PCI_REVISION(pa->pa_class);
- /*
- * Check to see if the device is in power-save mode, and
- * being it out if necessary.
- *
- * XXX This code comes almost verbatim from if_tlp_pci.c. I do
- * not understand it. Tulip clears the "sleep mode" bit in the
- * CFDA register, first. There is an equivalent (?) register at the
- * same place in the ADM8211, but the docs do not assign its bits
- * any meanings. -dcy
- */
- state = pci_set_powerstate(pc, pa->pa_tag, 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");
- return;
- }
+ pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map the device.
diff --git a/sys/dev/pci/if_sf_pci.c b/sys/dev/pci/if_sf_pci.c
index a6df377b8ca..dbb7e255c52 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.8 2011/04/03 15:36:02 jasper Exp $ */
+/* $OpenBSD: if_sf_pci.c,v 1.9 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: if_sf_pci.c,v 1.10 2006/06/17 23:34:27 christos Exp $ */
/*-
@@ -105,16 +105,11 @@ 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;
+ int ioh_valid, memh_valid;
bus_size_t iosize, memsize;
pcireg_t reg;
- state = pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
- if (state == PCI_PMCSR_STATE_D3) {
- printf(": unable to wake up from power state D3, "
- "reboot required.\n");
- return;
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map the device.
diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c
index 60fecc63595..c267720f08a 100644
--- a/sys/dev/pci/if_sis.c
+++ b/sys/dev/pci/if_sis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sis.c,v 1.105 2011/06/22 16:44:27 tedu Exp $ */
+/* $OpenBSD: if_sis.c,v 1.106 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@@ -873,7 +873,6 @@ sis_attach(struct device *parent, struct device *self, void *aux)
{
int i;
const char *intrstr = NULL;
- pcireg_t command;
struct sis_softc *sc = (struct sis_softc *)self;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
@@ -883,33 +882,7 @@ sis_attach(struct device *parent, struct device *self, void *aux)
sc->sis_stopped = 1;
- /*
- * Handle power management nonsense.
- */
- command = pci_conf_read(pc, pa->pa_tag, SIS_PCI_CAPID) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_conf_read(pc, pa->pa_tag, SIS_PCI_PWRMGMTCTRL);
- if (command & SIS_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, SIS_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, SIS_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, SIS_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode -- setting to D0\n",
- sc->sc_dev.dv_xname, command & SIS_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag, SIS_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, SIS_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, SIS_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, SIS_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_sisreg.h b/sys/dev/pci/if_sisreg.h
index 0aa4aff3841..0d046450460 100644
--- a/sys/dev/pci/if_sisreg.h
+++ b/sys/dev/pci/if_sisreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sisreg.h,v 1.31 2009/07/22 21:32:50 miod Exp $ */
+/* $OpenBSD: if_sisreg.h,v 1.32 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@@ -510,10 +510,5 @@ struct sis_softc {
#define SIS_PCI_PWRMGMTCAP 0x52 /* 16 bits */
#define SIS_PCI_PWRMGMTCTRL 0x54 /* 16 bits */
-#define SIS_PSTATE_MASK 0x0003
-#define SIS_PSTATE_D0 0x0000
-#define SIS_PSTATE_D1 0x0001
-#define SIS_PSTATE_D2 0x0002
-#define SIS_PSTATE_D3 0x0003
#define SIS_PME_EN 0x0010
#define SIS_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c
index 0c357fc8800..0330ea1274c 100644
--- a/sys/dev/pci/if_sk.c
+++ b/sys/dev/pci/if_sk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sk.c,v 1.161 2012/02/24 06:19:00 guenther Exp $ */
+/* $OpenBSD: if_sk.c,v 1.162 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -1304,7 +1304,7 @@ skc_attach(struct device *parent, struct device *self, void *aux)
struct pci_attach_args *pa = aux;
struct skc_attach_args skca;
pci_chipset_tag_t pc = pa->pa_pc;
- pcireg_t command, memtype;
+ pcireg_t memtype;
pci_intr_handle_t ih;
const char *intrstr = NULL;
u_int8_t skrs;
@@ -1312,35 +1312,7 @@ skc_attach(struct device *parent, struct device *self, void *aux)
DPRINTFN(2, ("begin skc_attach\n"));
- /*
- * Handle power management nonsense.
- */
- command = pci_conf_read(pc, pa->pa_tag, SK_PCI_CAPID) & 0x000000FF;
-
- if (command == 0x01) {
- command = pci_conf_read(pc, pa->pa_tag, SK_PCI_PWRMGMTCTRL);
- if (command & SK_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, SK_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, SK_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, SK_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s chip is in D%d power mode "
- "-- setting to D0\n", sc->sk_dev.dv_xname,
- command & SK_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag,
- SK_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, SK_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, SK_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, SK_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_skreg.h b/sys/dev/pci/if_skreg.h
index c7eed99c41b..321d4ab20e5 100644
--- a/sys/dev/pci/if_skreg.h
+++ b/sys/dev/pci/if_skreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_skreg.h,v 1.56 2012/03/28 12:02:49 jsg Exp $ */
+/* $OpenBSD: if_skreg.h,v 1.57 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -1500,11 +1500,6 @@
#define SK_Y2_REG5_TIM_VMAIN_AV_MASK 0x18000000
-#define SK_PSTATE_MASK 0x0003
-#define SK_PSTATE_D0 0x0000
-#define SK_PSTATE_D1 0x0001
-#define SK_PSTATE_D2 0x0002
-#define SK_PSTATE_D3 0x0003
#define SK_PME_EN 0x0010
#define SK_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_ste.c b/sys/dev/pci/if_ste.c
index 6152d25a3e4..12c2455d653 100644
--- a/sys/dev/pci/if_ste.c
+++ b/sys/dev/pci/if_ste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ste.c,v 1.47 2011/06/22 16:44:27 tedu Exp $ */
+/* $OpenBSD: if_ste.c,v 1.48 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@@ -845,7 +845,6 @@ void
ste_attach(struct device *parent, struct device *self, void *aux)
{
const char *intrstr = NULL;
- pcireg_t command;
struct ste_softc *sc = (struct ste_softc *)self;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
@@ -853,33 +852,7 @@ ste_attach(struct device *parent, struct device *self, void *aux)
struct ifnet *ifp;
bus_size_t size;
- /*
- * Handle power management nonsense.
- */
- command = pci_conf_read(pc, pa->pa_tag, STE_PCI_CAPID) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_conf_read(pc, pa->pa_tag, STE_PCI_PWRMGMTCTRL);
- if (command & STE_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pc, pa->pa_tag, STE_PCI_LOIO);
- membase = pci_conf_read(pc, pa->pa_tag, STE_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, STE_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode -- setting to D0\n",
- sc->sc_dev.dv_xname, command & STE_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag, STE_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, STE_PCI_LOIO, iobase);
- pci_conf_write(pc, pa->pa_tag, STE_PCI_LOMEM, membase);
- pci_conf_write(pc, pa->pa_tag, STE_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Only use one PHY since this chip reports multiple
diff --git a/sys/dev/pci/if_stereg.h b/sys/dev/pci/if_stereg.h
index 2e6db9ad0a3..863d3e683a8 100644
--- a/sys/dev/pci/if_stereg.h
+++ b/sys/dev/pci/if_stereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_stereg.h,v 1.10 2005/12/17 07:31:27 miod Exp $ */
+/* $OpenBSD: if_stereg.h,v 1.11 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@@ -376,11 +376,6 @@
#define STE_PCI_PWRMGMTCAP 0x52 /* 16 bits */
#define STE_PCI_PWRMGMTCTRL 0x54 /* 16 bits */
-#define STE_PSTATE_MASK 0x0003
-#define STE_PSTATE_D0 0x0000
-#define STE_PSTATE_D1 0x0002
-#define STE_PSTATE_D2 0x0002
-#define STE_PSTATE_D3 0x0003
#define STE_PME_EN 0x0010
#define STE_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c
index 601ace58561..4fd07399b63 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.53 2011/04/05 18:01:21 henning Exp $ */
+/* $OpenBSD: if_stge.c,v 1.54 2012/10/18 21:44:21 deraadt Exp $ */
/* $NetBSD: if_stge.c,v 1.27 2005/05/16 21:35:32 bouyer Exp $ */
/*-
@@ -176,7 +176,6 @@ stge_attach(struct device *parent, struct device *self, void *aux)
bus_size_t iosize;
int ioh_valid, memh_valid;
int i, rseg, error;
- int state;
timeout_set(&sc->sc_timeout, stge_tick, sc);
@@ -206,16 +205,7 @@ 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. */
- state = pci_set_powerstate(pc, pa->pa_tag, 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");
- return;
- }
+ pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map and establish our interrupt.
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c
index 723382c57b4..faf289a1c1d 100644
--- a/sys/dev/pci/if_vr.c
+++ b/sys/dev/pci/if_vr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vr.c,v 1.115 2012/09/18 14:49:44 gerhard Exp $ */
+/* $OpenBSD: if_vr.c,v 1.116 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -489,7 +489,6 @@ void
vr_attach(struct device *parent, struct device *self, void *aux)
{
int i;
- pcireg_t command;
struct vr_softc *sc = (struct vr_softc *)self;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
@@ -500,39 +499,7 @@ vr_attach(struct device *parent, struct device *self, void *aux)
int rseg;
caddr_t kva;
- /*
- * Handle power management nonsense.
- */
- command = pci_conf_read(pa->pa_pc, pa->pa_tag,
- VR_PCI_CAPID) & 0x000000ff;
- if (command == 0x01) {
- command = pci_conf_read(pa->pa_pc, pa->pa_tag,
- VR_PCI_PWRMGMTCTRL);
- if (command & VR_PSTATE_MASK) {
- pcireg_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_conf_read(pa->pa_pc, pa->pa_tag,
- VR_PCI_LOIO);
- membase = pci_conf_read(pa->pa_pc, pa->pa_tag,
- VR_PCI_LOMEM);
- irq = pci_conf_read(pa->pa_pc, pa->pa_tag,
- VR_PCI_INTLINE);
-
- /* Reset the power state. */
- command &= 0xFFFFFFFC;
- pci_conf_write(pa->pa_pc, pa->pa_tag,
- VR_PCI_PWRMGMTCTRL, command);
-
- /* Restore PCI config data. */
- pci_conf_write(pa->pa_pc, pa->pa_tag,
- VR_PCI_LOIO, iobase);
- pci_conf_write(pa->pa_pc, pa->pa_tag,
- VR_PCI_LOMEM, membase);
- pci_conf_write(pa->pa_pc, pa->pa_tag,
- VR_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_vrreg.h b/sys/dev/pci/if_vrreg.h
index 7885c98aad6..574e0a58cd8 100644
--- a/sys/dev/pci/if_vrreg.h
+++ b/sys/dev/pci/if_vrreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vrreg.h,v 1.30 2012/01/05 19:08:25 deraadt Exp $ */
+/* $OpenBSD: if_vrreg.h,v 1.31 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -574,10 +574,5 @@ struct vr_softc {
#define VR_PCI_PWRMGMTCAP 0xDE /* 16 bits */
#define VR_PCI_PWRMGMTCTRL 0xE0 /* 16 bits */
-#define VR_PSTATE_MASK 0x0003
-#define VR_PSTATE_D0 0x0000
-#define VR_PSTATE_D1 0x0002
-#define VR_PSTATE_D2 0x0002
-#define VR_PSTATE_D3 0x0003
#define VR_PME_EN 0x0010
#define VR_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c
index 0eaa5899996..963a81a0b7f 100644
--- a/sys/dev/pci/if_wb.c
+++ b/sys/dev/pci/if_wb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wb.c,v 1.48 2011/06/22 16:44:29 tedu Exp $ */
+/* $OpenBSD: if_wb.c,v 1.49 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -714,41 +714,11 @@ wb_attach(parent, self, aux)
struct ifnet *ifp = &sc->arpcom.ac_if;
bus_size_t size;
int rseg;
- pcireg_t command;
bus_dma_segment_t seg;
bus_dmamap_t dmamap;
caddr_t kva;
- /*
- * Handle power management nonsense.
- */
-
- command = pci_conf_read(pc, pa->pa_tag, WB_PCI_CAPID) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_conf_read(pc, pa->pa_tag, WB_PCI_PWRMGMTCTRL);
- if (command & WB_PSTATE_MASK) {
- u_int32_t io, mem, irq;
-
- /* Save important PCI config data. */
- io = pci_conf_read(pc, pa->pa_tag, WB_PCI_LOIO);
- mem = pci_conf_read(pc, pa->pa_tag, WB_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, WB_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode "
- "-- setting to D0\n", sc->sc_dev.dv_xname,
- command & WB_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag, WB_PCI_PWRMGMTCTRL,
- command);
-
- /* Restore PCI config data. */
- pci_conf_write(pc, pa->pa_tag, WB_PCI_LOIO, io);
- pci_conf_write(pc, pa->pa_tag, WB_PCI_LOMEM, mem);
- pci_conf_write(pc, pa->pa_tag, WB_PCI_INTLINE, irq);
- }
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
/*
* Map control/status registers.
diff --git a/sys/dev/pci/if_wbreg.h b/sys/dev/pci/if_wbreg.h
index 4cb6cff01bf..8ae824e2bb6 100644
--- a/sys/dev/pci/if_wbreg.h
+++ b/sys/dev/pci/if_wbreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wbreg.h,v 1.8 2005/12/17 07:31:27 miod Exp $ */
+/* $OpenBSD: if_wbreg.h,v 1.9 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -449,11 +449,6 @@ struct wb_softc {
#define WB_PCI_PWRMGMTCAP 0xDE /* 16 bits */
#define WB_PCI_PWRMGMTCTRL 0xE0 /* 16 bits */
-#define WB_PSTATE_MASK 0x0003
-#define WB_PSTATE_D0 0x0000
-#define WB_PSTATE_D1 0x0002
-#define WB_PSTATE_D2 0x0002
-#define WB_PSTATE_D3 0x0003
#define WB_PME_EN 0x0010
#define WB_PME_STATUS 0x8000
diff --git a/sys/dev/pci/if_xl_pci.c b/sys/dev/pci/if_xl_pci.c
index f4701177675..47bd6803314 100644
--- a/sys/dev/pci/if_xl_pci.c
+++ b/sys/dev/pci/if_xl_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_xl_pci.c,v 1.39 2012/10/13 17:24:03 deraadt Exp $ */
+/* $OpenBSD: if_xl_pci.c,v 1.40 2012/10/18 21:44:21 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -157,7 +157,9 @@ xl_pci_attach(struct device *parent, struct device *self, void *aux)
pci_intr_handle_t ih;
const char *intrstr = NULL;
bus_size_t iosize, funsize;
+#ifndef SMALL_KERNEL
u_int32_t command;
+#endif
psc->psc_pc = pc;
psc->psc_tag = pa->pa_tag;
@@ -224,63 +226,21 @@ xl_pci_attach(struct device *parent, struct device *self, void *aux)
break;
}
- /*
- * If this is a 3c905B, we have to check one extra thing.
- * The 905B supports power management and may be placed in
- * a low-power mode (D3 mode), typically by certain operating
- * systems which shall not be named. The PCI BIOS is supposed
- * to reset the NIC and bring it out of low-power mode, but
- * some do not. Consequently, we have to see if this chip
- * supports power management, and if so, make sure it's not
- * in low-power mode. If power management is available, the
- * capid byte will be 0x01.
- *
- * I _think_ that what actually happens is that the chip
- * loses its PCI configuration during the transition from
- * D3 back to D0; this means that it should be possible for
- * us to save the PCI iobase, membase and IRQ, put the chip
- * back in the D0 state, then restore the PCI config ourselves.
- */
- command = pci_conf_read(pc, pa->pa_tag, XL_PCI_CAPID) & 0xff;
- if (command == 0x01) {
-
- command = pci_conf_read(pc, pa->pa_tag,
- XL_PCI_PWRMGMTCTRL);
- if (command & XL_PSTATE_MASK) {
- u_int32_t io, mem, irq;
-
- /* Save PCI config */
- io = pci_conf_read(pc, pa->pa_tag, XL_PCI_LOIO);
- mem = pci_conf_read(pc, pa->pa_tag, XL_PCI_LOMEM);
- irq = pci_conf_read(pc, pa->pa_tag, XL_PCI_INTLINE);
-
- /* Reset the power state. */
- printf("%s: chip is in D%d power mode "
- "-- setting to D0\n",
- sc->sc_dev.dv_xname, command & XL_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_conf_write(pc, pa->pa_tag,
- XL_PCI_PWRMGMTCTRL, command);
-
- pci_conf_write(pc, pa->pa_tag, XL_PCI_LOIO, io);
- pci_conf_write(pc, pa->pa_tag, XL_PCI_LOMEM, mem);
- pci_conf_write(pc, pa->pa_tag, XL_PCI_INTLINE, irq);
- }
+ pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
#ifndef SMALL_KERNEL
- /*
- * The card is WOL-capable if it supports PME# assertion
- * from D3hot power state. Install a callback to configure
- * PCI power state for WOL. It will be invoked when the
- * interface stops and WOL was enabled.
- */
- command = pci_conf_read(pc, pa->pa_tag, XL_PCI_CAPID);
- if ((command >> 16) & XL_PME_CAP_D3_HOT) {
- sc->wol_power = xl_pci_wol_power;
- sc->wol_power_arg = psc;
- }
-#endif
+ /*
+ * The card is WOL-capable if it supports PME# assertion
+ * from D3hot power state. Install a callback to configure
+ * PCI power state for WOL. It will be invoked when the
+ * interface stops and WOL was enabled.
+ */
+ command = pci_conf_read(pc, pa->pa_tag, XL_PCI_CAPID);
+ if ((command >> 16) & XL_PME_CAP_D3_HOT) {
+ sc->wol_power = xl_pci_wol_power;
+ sc->wol_power_arg = psc;
}
+#endif
/*
* Map control/status registers.