summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2011-12-14 00:28:54 +0000
committerhselasky <hselasky@FreeBSD.org>2011-12-14 00:28:54 +0000
commit7076389cec83009f9046b6c6e2695fe340a63802 (patch)
tree56520f5d0635d8db6259b372fff280b4e6288da5 /sys/mips
parent145914e3e7153161b6dd67fdcd58c7a8201845bc (diff)
downloadFreeBSD-src-7076389cec83009f9046b6c6e2695fe340a63802.zip
FreeBSD-src-7076389cec83009f9046b6c6e2695fe340a63802.tar.gz
Implement better support for USB controller suspend and resume.
This patch should remove the need for kldunload of USB controller drivers at suspend and kldload of USB controller drivers at resume. This patch also fixes some build issues in avr32dci.c MFC after: 2 weeks
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/atheros/ar71xx_ehci.c54
-rw-r--r--sys/mips/atheros/ar71xx_ohci.c8
-rw-r--r--sys/mips/cavium/usb/octusb.c29
-rw-r--r--sys/mips/cavium/usb/octusb.h2
-rw-r--r--sys/mips/cavium/usb/octusb_octeon.c25
-rw-r--r--sys/mips/rmi/xls_ehci.c58
-rw-r--r--sys/mips/rt305x/rt305x_dotg.c26
7 files changed, 56 insertions, 146 deletions
diff --git a/sys/mips/atheros/ar71xx_ehci.c b/sys/mips/atheros/ar71xx_ehci.c
index 1f24d7c..c04e069 100644
--- a/sys/mips/atheros/ar71xx_ehci.c
+++ b/sys/mips/atheros/ar71xx_ehci.c
@@ -65,53 +65,11 @@ struct ar71xx_ehci_softc {
static device_attach_t ar71xx_ehci_attach;
static device_detach_t ar71xx_ehci_detach;
-static device_shutdown_t ar71xx_ehci_shutdown;
-static device_suspend_t ar71xx_ehci_suspend;
-static device_resume_t ar71xx_ehci_resume;
bs_r_1_proto(reversed);
bs_w_1_proto(reversed);
static int
-ar71xx_ehci_suspend(device_t self)
-{
- ehci_softc_t *sc = device_get_softc(self);
- int err;
-
- err = bus_generic_suspend(self);
- if (err)
- return (err);
- ehci_suspend(sc);
- return (0);
-}
-
-static int
-ar71xx_ehci_resume(device_t self)
-{
- ehci_softc_t *sc = device_get_softc(self);
-
- ehci_resume(sc);
-
- bus_generic_resume(self);
-
- return (0);
-}
-
-static int
-ar71xx_ehci_shutdown(device_t self)
-{
- ehci_softc_t *sc = device_get_softc(self);
- int err;
-
- err = bus_generic_shutdown(self);
- if (err)
- return (err);
- ehci_shutdown(sc);
-
- return (0);
-}
-
-static int
ar71xx_ehci_probe(device_t self)
{
@@ -280,17 +238,17 @@ static device_method_t ehci_methods[] = {
DEVMETHOD(device_probe, ar71xx_ehci_probe),
DEVMETHOD(device_attach, ar71xx_ehci_attach),
DEVMETHOD(device_detach, ar71xx_ehci_detach),
- DEVMETHOD(device_suspend, ar71xx_ehci_suspend),
- DEVMETHOD(device_resume, ar71xx_ehci_resume),
- DEVMETHOD(device_shutdown, ar71xx_ehci_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD_END
};
static driver_t ehci_driver = {
- "ehci",
- ehci_methods,
- sizeof(struct ar71xx_ehci_softc),
+ .name = "ehci",
+ .methods = ehci_methods,
+ .size = sizeof(struct ar71xx_ehci_softc),
};
static devclass_t ehci_devclass;
diff --git a/sys/mips/atheros/ar71xx_ohci.c b/sys/mips/atheros/ar71xx_ohci.c
index 9e0a63f..6292372 100644
--- a/sys/mips/atheros/ar71xx_ohci.c
+++ b/sys/mips/atheros/ar71xx_ohci.c
@@ -194,15 +194,17 @@ static device_method_t ohci_methods[] = {
DEVMETHOD(device_probe, ar71xx_ohci_probe),
DEVMETHOD(device_attach, ar71xx_ohci_attach),
DEVMETHOD(device_detach, ar71xx_ohci_detach),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD_END
};
static driver_t ohci_driver = {
- "ohci",
- ohci_methods,
- sizeof(struct ar71xx_ohci_softc),
+ .name = "ohci",
+ .methods = ohci_methods,
+ .size = sizeof(struct ar71xx_ohci_softc),
};
static devclass_t ohci_devclass;
diff --git a/sys/mips/cavium/usb/octusb.c b/sys/mips/cavium/usb/octusb.c
index d8ea9fb..9d6884b 100644
--- a/sys/mips/cavium/usb/octusb.c
+++ b/sys/mips/cavium/usb/octusb.c
@@ -913,16 +913,16 @@ octusb_uninit(struct octusb_softc *sc)
}
-void
+static void
octusb_suspend(struct octusb_softc *sc)
{
-
+ /* TODO */
}
-void
+static void
octusb_resume(struct octusb_softc *sc)
{
-
+ /* TODO */
}
/*------------------------------------------------------------------------*
@@ -1908,6 +1908,26 @@ octusb_set_hw_power(struct usb_bus *bus)
DPRINTF("Nothing to do.\n");
}
+static void
+octusb_set_hw_power_sleep(struct usb_bus *bus, uint32_t state)
+{
+ struct octusb_softc *sc = OCTUSB_BUS2SC(bus);
+
+ switch (state) {
+ case USB_HW_POWER_SUSPEND:
+ octusb_suspend(sc);
+ break;
+ case USB_HW_POWER_SHUTDOWN:
+ octusb_uninit(sc);
+ break;
+ case USB_HW_POWER_RESUME:
+ octusb_resume(sc);
+ break;
+ default:
+ break;
+ }
+}
+
struct usb_bus_methods octusb_bus_methods = {
.endpoint_init = octusb_ep_init,
.xfer_setup = octusb_xfer_setup,
@@ -1916,6 +1936,7 @@ struct usb_bus_methods octusb_bus_methods = {
.device_resume = octusb_device_resume,
.device_suspend = octusb_device_suspend,
.set_hw_power = octusb_set_hw_power,
+ .set_hw_power_sleep = octusb_set_hw_power_sleep,
.roothub_exec = octusb_roothub_exec,
.xfer_poll = octusb_do_poll,
};
diff --git a/sys/mips/cavium/usb/octusb.h b/sys/mips/cavium/usb/octusb.h
index 31f4fc0..41320ef 100644
--- a/sys/mips/cavium/usb/octusb.h
+++ b/sys/mips/cavium/usb/octusb.h
@@ -140,8 +140,6 @@ struct octusb_softc {
usb_bus_mem_cb_t octusb_iterate_hw_softc;
usb_error_t octusb_init(struct octusb_softc *);
usb_error_t octusb_uninit(struct octusb_softc *);
-void octusb_suspend(struct octusb_softc *);
-void octusb_resume(struct octusb_softc *);
void octusb_interrupt(struct octusb_softc *);
#endif /* _OCTUSB_H_ */
diff --git a/sys/mips/cavium/usb/octusb_octeon.c b/sys/mips/cavium/usb/octusb_octeon.c
index d160eda..4448f4e 100644
--- a/sys/mips/cavium/usb/octusb_octeon.c
+++ b/sys/mips/cavium/usb/octusb_octeon.c
@@ -182,36 +182,23 @@ octusb_octeon_detach(device_t dev)
return (0);
}
-static int
-octusb_octeon_shutdown(device_t dev)
-{
- struct octusb_octeon_softc *sc = device_get_softc(dev);
- int err;
-
- err = bus_generic_shutdown(dev);
- if (err)
- return (err);
-
- octusb_uninit(&sc->sc_dci);
-
- return (0);
-}
-
static device_method_t octusb_octeon_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, octusb_octeon_identify),
DEVMETHOD(device_probe, octusb_octeon_probe),
DEVMETHOD(device_attach, octusb_octeon_attach),
DEVMETHOD(device_detach, octusb_octeon_detach),
- DEVMETHOD(device_shutdown, octusb_octeon_shutdown),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD_END
};
static driver_t octusb_octeon_driver = {
- "octusb",
- octusb_octeon_methods,
- sizeof(struct octusb_octeon_softc),
+ .name = "octusb",
+ .methods = octusb_octeon_methods,
+ .size = sizeof(struct octusb_octeon_softc),
};
static devclass_t octusb_octeon_devclass;
diff --git a/sys/mips/rmi/xls_ehci.c b/sys/mips/rmi/xls_ehci.c
index 4870872..c4ae065 100644
--- a/sys/mips/rmi/xls_ehci.c
+++ b/sys/mips/rmi/xls_ehci.c
@@ -69,50 +69,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/controller/ehcireg.h>
#include <mips/rmi/pic.h>
-static int ehci_xls_attach(device_t self);
-static int ehci_xls_detach(device_t self);
-static int ehci_xls_shutdown(device_t self);
-static int ehci_xls_suspend(device_t self);
-static int ehci_xls_resume(device_t self);
-
-static int
-ehci_xls_suspend(device_t self)
-{
- ehci_softc_t *sc = device_get_softc(self);
- int err;
-
- err = bus_generic_suspend(self);
- if (err)
- return (err);
- ehci_suspend(sc);
- return (0);
-}
-
-static int
-ehci_xls_resume(device_t self)
-{
- ehci_softc_t *sc = device_get_softc(self);
-
- ehci_resume(sc);
-
- bus_generic_resume(self);
-
- return (0);
-}
-
-static int
-ehci_xls_shutdown(device_t self)
-{
- ehci_softc_t *sc = device_get_softc(self);
- int err;
-
- err = bus_generic_shutdown(self);
- if (err)
- return (err);
- ehci_shutdown(sc);
-
- return (0);
-}
+static device_attach_t ehci_xls_attach;
+static device_detach_t ehci_xls_detach;
static const char *xlr_usb_dev_desc = "RMI XLR USB 2.0 controller";
static const char *xlr_vendor_desc = "RMI Corp";
@@ -248,17 +206,17 @@ static device_method_t ehci_methods[] = {
DEVMETHOD(device_probe, ehci_xls_probe),
DEVMETHOD(device_attach, ehci_xls_attach),
DEVMETHOD(device_detach, ehci_xls_detach),
- DEVMETHOD(device_suspend, ehci_xls_suspend),
- DEVMETHOD(device_resume, ehci_xls_resume),
- DEVMETHOD(device_shutdown, ehci_xls_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD_END
};
static driver_t ehci_driver = {
- "ehci",
- ehci_methods,
- sizeof(struct ehci_softc),
+ .name = "ehci",
+ .methods = ehci_methods,
+ .size = sizeof(struct ehci_softc),
};
static devclass_t ehci_devclass;
diff --git a/sys/mips/rt305x/rt305x_dotg.c b/sys/mips/rt305x/rt305x_dotg.c
index 67666f7..89b4933 100644
--- a/sys/mips/rt305x/rt305x_dotg.c
+++ b/sys/mips/rt305x/rt305x_dotg.c
@@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$");
static device_probe_t dotg_obio_probe;
static device_attach_t dotg_obio_attach;
static device_detach_t dotg_obio_detach;
-static device_shutdown_t dotg_obio_shutdown;
struct dotg_obio_softc {
struct dotg_softc sc_dci; /* must be first */
@@ -208,35 +207,22 @@ dotg_obio_detach(device_t dev)
return (0);
}
-static int
-dotg_obio_shutdown(device_t dev)
-{
- struct dotg_obio_softc *sc = device_get_softc(dev);
- int err;
-
- err = bus_generic_shutdown(dev);
- if (err)
- return (err);
-
- dotg_uninit(&sc->sc_dci);
-
- return (0);
-}
-
static device_method_t dotg_obio_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, dotg_obio_probe),
DEVMETHOD(device_attach, dotg_obio_attach),
DEVMETHOD(device_detach, dotg_obio_detach),
- DEVMETHOD(device_shutdown, dotg_obio_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD_END
};
static driver_t dotg_obio_driver = {
- "dotg",
- dotg_obio_methods,
- sizeof(struct dotg_obio_softc),
+ .name = "dotg",
+ .methods = dotg_obio_methods,
+ .size = sizeof(struct dotg_obio_softc),
};
static devclass_t dotg_obio_devclass;
OpenPOWER on IntegriCloud