aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Shibagaki <shiba@FreeBSD.org>2003-12-22 15:18:46 +0000
committerTakeshi Shibagaki <shiba@FreeBSD.org>2003-12-22 15:18:46 +0000
commite394a3e85dde3bdf112ce41b345c8c3e8c4841f1 (patch)
tree0c2171805339cf2370a697d9a770bb647640c606
parent07a65634d95e1b2106b63dc770aaff733b44bc9a (diff)
Notes
-rw-r--r--sys/dev/usb/ohci.c14
-rw-r--r--sys/dev/usb/ohci_pci.c40
-rw-r--r--sys/dev/usb/ohcivar.h3
3 files changed, 45 insertions, 12 deletions
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index ce54cdff1b7d9..00a92c68af37c 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1001,7 +1001,6 @@ ohci_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
/*
* Shut down the controller when the system is going down.
*/
-#if defined(__NetBSD__) || defined(__OpenBSD__)
void
ohci_shutdown(void *v)
{
@@ -1031,9 +1030,7 @@ ohci_power(int why, void *v)
#endif
s = splhardusb();
- switch (why) {
- case PWR_SUSPEND:
- case PWR_STANDBY:
+ if (why != PWR_RESUME) {
sc->sc_bus.use_polling++;
ctl = OREAD4(sc, OHCI_CONTROL) & ~OHCI_HCFS_MASK;
if (sc->sc_control == 0) {
@@ -1048,8 +1045,7 @@ ohci_power(int why, void *v)
OWRITE4(sc, OHCI_CONTROL, ctl);
usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT);
sc->sc_bus.use_polling--;
- break;
- case PWR_RESUME:
+ } else {
sc->sc_bus.use_polling++;
/* Some broken BIOSes do not recover these values */
OWRITE4(sc, OHCI_HCCA, DMAADDR(&sc->sc_hccadma, 0));
@@ -1070,15 +1066,9 @@ ohci_power(int why, void *v)
usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY);
sc->sc_control = sc->sc_intre = 0;
sc->sc_bus.use_polling--;
- break;
- case PWR_SOFTSUSPEND:
- case PWR_SOFTSTANDBY:
- case PWR_SOFTRESUME:
- break;
}
splx(s);
}
-#endif
#ifdef USB_DEBUG
void
diff --git a/sys/dev/usb/ohci_pci.c b/sys/dev/usb/ohci_pci.c
index 37d4d2f31c3b5..558c44072203d 100644
--- a/sys/dev/usb/ohci_pci.c
+++ b/sys/dev/usb/ohci_pci.c
@@ -119,6 +119,44 @@ static const char *ohci_device_generic = "OHCI (generic) USB controller";
static int ohci_pci_attach(device_t self);
static int ohci_pci_detach(device_t self);
+static int ohci_pci_suspend(device_t self);
+static int ohci_pci_resume(device_t self);
+
+static int
+ohci_pci_suspend(device_t self)
+{
+ ohci_softc_t *sc = device_get_softc(self);
+ int err;
+
+ err = bus_generic_suspend(self);
+ if (err)
+ return err;
+ ohci_power(PWR_SUSPEND, sc);
+
+ return 0;
+}
+
+static int
+ohci_pci_resume(device_t self)
+{
+ ohci_softc_t *sc = device_get_softc(self);
+ u_int32_t reg, int_line;
+
+ if (pci_get_powerstate(self) != PCI_POWERSTATE_D0) {
+ device_printf(self, "chip is in D%d mode "
+ "-- setting to D0\n", pci_get_powerstate(self));
+ reg = pci_read_config(self, PCI_CBMEM, 4);
+ int_line = pci_read_config(self, PCIR_INTLINE, 4);
+ pci_set_powerstate(self, PCI_POWERSTATE_D0);
+ pci_write_config(self, PCI_CBMEM, reg, 4);
+ pci_write_config(self, PCIR_INTLINE, int_line, 4);
+ }
+
+ ohci_power(PWR_RESUME, sc);
+ bus_generic_resume(self);
+
+ return 0;
+}
static const char *
ohci_pci_match(device_t self)
@@ -310,6 +348,8 @@ static device_method_t ohci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ohci_pci_probe),
DEVMETHOD(device_attach, ohci_pci_attach),
+ DEVMETHOD(device_suspend, ohci_pci_suspend),
+ DEVMETHOD(device_resume, ohci_pci_resume),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
/* Bus interface */
diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h
index 2d19f49ddcaef..84b54476335bd 100644
--- a/sys/dev/usb/ohcivar.h
+++ b/sys/dev/usb/ohcivar.h
@@ -165,3 +165,6 @@ int ohci_activate(device_ptr_t, enum devact);
#endif
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
+
+void ohci_shutdown(void *v);
+void ohci_power(int state, void *priv);