summaryrefslogtreecommitdiffstats
path: root/sys/dev/fxp
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2001-07-25 18:00:17 +0000
committerjlemon <jlemon@FreeBSD.org>2001-07-25 18:00:17 +0000
commit14e433b6b78db71a76fff7d87fdc38174d09f67c (patch)
tree685cd6209cff5b4ef6dfd69760d70838d45469ea /sys/dev/fxp
parenta100af4fa8fb439e081a08bd1feaeee8228d209e (diff)
downloadFreeBSD-src-14e433b6b78db71a76fff7d87fdc38174d09f67c.zip
FreeBSD-src-14e433b6b78db71a76fff7d87fdc38174d09f67c.tar.gz
Reset the device's powerstate to d0 when resuming from a suspend
operation, not just when we initally attach to the device. Submitted by: warner
Diffstat (limited to 'sys/dev/fxp')
-rw-r--r--sys/dev/fxp/if_fxp.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
index 2f2a8a4..b4dce37 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -174,6 +174,7 @@ static int fxp_resume(device_t dev);
static void fxp_intr(void *xsc);
static void fxp_init(void *xsc);
static void fxp_tick(void *xsc);
+static void fxp_powerstate_d0(device_t dev);
static void fxp_start(struct ifnet *ifp);
static void fxp_stop(struct fxp_softc *sc);
static void fxp_release(struct fxp_softc *sc);
@@ -310,6 +311,32 @@ fxp_probe(device_t dev)
return (ENXIO);
}
+static void
+fxp_powerstate_d0(device_t dev)
+{
+#if __FreeBSD_version >= 430002
+ u_int32_t iobase, membase, irq;
+
+ if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
+ /* Save important PCI config data. */
+ iobase = pci_read_config(dev, FXP_PCI_IOBA, 4);
+ membase = pci_read_config(dev, FXP_PCI_MMBA, 4);
+ irq = pci_read_config(dev, PCIR_INTLINE, 4);
+
+ /* Reset the power state. */
+ device_printf(dev, "chip is in D%d power mode "
+ "-- setting to D0\n", pci_get_powerstate(dev));
+
+ pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+
+ /* Restore PCI config data. */
+ pci_write_config(dev, FXP_PCI_IOBA, iobase, 4);
+ pci_write_config(dev, FXP_PCI_MMBA, membase, 4);
+ pci_write_config(dev, PCIR_INTLINE, irq, 4);
+ }
+#endif
+}
+
static int
fxp_attach(device_t dev)
{
@@ -337,27 +364,7 @@ fxp_attach(device_t dev)
pci_write_config(dev, PCIR_COMMAND, val, 2);
val = pci_read_config(dev, PCIR_COMMAND, 2);
-#if __FreeBSD_version >= 500000
- if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_read_config(dev, FXP_PCI_IOBA, 4);
- membase = pci_read_config(dev, FXP_PCI_MMBA, 4);
- irq = pci_read_config(dev, PCIR_INTLINE, 4);
-
- /* Reset the power state. */
- device_printf(dev, "chip is in D%d power mode "
- "-- setting to D0\n", pci_get_powerstate(dev));
-
- pci_set_powerstate(dev, PCI_POWERSTATE_D0);
-
- /* Restore PCI config data. */
- pci_write_config(dev, FXP_PCI_IOBA, iobase, 4);
- pci_write_config(dev, FXP_PCI_MMBA, membase, 4);
- pci_write_config(dev, PCIR_INTLINE, irq, 4);
- }
-#endif
+ fxp_powerstate_d0(dev);
/*
* Figure out which we should try first - memory mapping or i/o mapping?
@@ -676,8 +683,8 @@ fxp_suspend(device_t dev)
fxp_stop(sc);
- for (i=0; i<5; i++)
- sc->saved_maps[i] = pci_read_config(dev, PCIR_MAPS + i*4, 4);
+ for (i = 0; i < 5; i++)
+ sc->saved_maps[i] = pci_read_config(dev, PCIR_MAPS + i * 4, 4);
sc->saved_biosaddr = pci_read_config(dev, PCIR_BIOS, 4);
sc->saved_intline = pci_read_config(dev, PCIR_INTLINE, 1);
sc->saved_cachelnsz = pci_read_config(dev, PCIR_CACHELNSZ, 1);
@@ -704,9 +711,11 @@ fxp_resume(device_t dev)
s = splimp();
+ fxp_powerstate_d0(dev);
+
/* better way to do this? */
- for (i=0; i<5; i++)
- pci_write_config(dev, PCIR_MAPS + i*4, sc->saved_maps[i], 4);
+ for (i = 0; i < 5; i++)
+ pci_write_config(dev, PCIR_MAPS + i * 4, sc->saved_maps[i], 4);
pci_write_config(dev, PCIR_BIOS, sc->saved_biosaddr, 4);
pci_write_config(dev, PCIR_INTLINE, sc->saved_intline, 1);
pci_write_config(dev, PCIR_CACHELNSZ, sc->saved_cachelnsz, 1);
OpenPOWER on IntegriCloud