summaryrefslogtreecommitdiffstats
path: root/sys/pci/if_xl.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2000-12-18 21:53:05 +0000
committerwpaul <wpaul@FreeBSD.org>2000-12-18 21:53:05 +0000
commit29d9ced63d2cf6eded71df28817fa9e8ae59ee1b (patch)
treee3519b2ccedc704ee1a4d7f8328fa5073f68dd5d /sys/pci/if_xl.c
parentc5b98ef61d504239bd2e1470af7539364f3e0e53 (diff)
downloadFreeBSD-src-29d9ced63d2cf6eded71df28817fa9e8ae59ee1b.zip
FreeBSD-src-29d9ced63d2cf6eded71df28817fa9e8ae59ee1b.tar.gz
Use pci_get_powerstate()/pci_set_powerstate() which now exists in the
PCI code. This saves each driver from having to grovel around looking for the right registers to twiddle. I should eventually convert the other PCI drivers to do this; for now, these three are ones which I know need power state handling.
Diffstat (limited to 'sys/pci/if_xl.c')
-rw-r--r--sys/pci/if_xl.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c
index eaa8901..e7a3174 100644
--- a/sys/pci/if_xl.c
+++ b/sys/pci/if_xl.c
@@ -1282,29 +1282,25 @@ static int xl_attach(dev)
* back in the D0 state, then restore the PCI config ourselves.
*/
- command = pci_read_config(dev, XL_PCI_CAPID, 4) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_read_config(dev, XL_PCI_PWRMGMTCTRL, 4);
- if (command & XL_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_read_config(dev, XL_PCI_LOIO, 4);
- membase = pci_read_config(dev, XL_PCI_LOMEM, 4);
- irq = pci_read_config(dev, XL_PCI_INTLINE, 4);
-
- /* Reset the power state. */
- printf("xl%d: chip is in D%d power mode "
- "-- setting to D0\n", unit, command & XL_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_write_config(dev, XL_PCI_PWRMGMTCTRL, command, 4);
-
- /* Restore PCI config data. */
- pci_write_config(dev, XL_PCI_LOIO, iobase, 4);
- pci_write_config(dev, XL_PCI_LOMEM, membase, 4);
- pci_write_config(dev, XL_PCI_INTLINE, irq, 4);
- }
+ if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
+ u_int32_t iobase, membase, irq;
+
+ /* Save important PCI config data. */
+ iobase = pci_read_config(dev, XL_PCI_LOIO, 4);
+ membase = pci_read_config(dev, XL_PCI_LOMEM, 4);
+ irq = pci_read_config(dev, XL_PCI_INTLINE, 4);
+
+ /* Reset the power state. */
+ printf("xl%d: chip is in D%d power mode "
+ "-- setting to D0\n", unit,
+ pci_get_powerstate(dev));
+
+ pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+
+ /* Restore PCI config data. */
+ pci_write_config(dev, XL_PCI_LOIO, iobase, 4);
+ pci_write_config(dev, XL_PCI_LOMEM, membase, 4);
+ pci_write_config(dev, XL_PCI_INTLINE, irq, 4);
}
/*
OpenPOWER on IntegriCloud