diff options
-rw-r--r-- | sys/dev/pci/xhci_pci.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/xhci.c | 47 | ||||
-rw-r--r-- | sys/dev/usb/xhcivar.h | 5 |
3 files changed, 34 insertions, 24 deletions
diff --git a/sys/dev/pci/xhci_pci.c b/sys/dev/pci/xhci_pci.c index 75013f9c3e9..6b881036fb5 100644 --- a/sys/dev/pci/xhci_pci.c +++ b/sys/dev/pci/xhci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci_pci.c,v 1.1 2014/03/08 14:34:12 mpi Exp $ */ +/* $OpenBSD: xhci_pci.c,v 1.2 2014/03/25 17:23:40 mpi Exp $ */ /* * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -145,7 +145,7 @@ xhci_pci_attach(struct device *parent, struct device *self, void *aux) } /* Attach usb device. */ - psc->sc.sc_child = config_found(self, &psc->sc.sc_bus, usbctlprint); + config_found(self, &psc->sc.sc_bus, usbctlprint); return; @@ -161,7 +161,7 @@ xhci_pci_detach(struct device *self, int flags) struct xhci_pci_softc *psc = (struct xhci_pci_softc *)self; int rv; - rv = xhci_detach(&psc->sc, flags); + rv = xhci_detach(self, flags); if (rv) return (rv); if (psc->sc_ih != NULL) { diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index f2deac66b4c..155e0b5e42a 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.3 2014/03/18 15:47:23 mpi Exp $ */ +/* $OpenBSD: xhci.c,v 1.4 2014/03/25 17:23:40 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -69,6 +69,7 @@ struct xhci_pipe { }; int xhci_reset(struct xhci_softc *); +void xhci_config(struct xhci_softc *); int xhci_intr1(struct xhci_softc *); void xhci_waitintr(struct xhci_softc *, struct usbd_xfer *); void xhci_event_dequeue(struct xhci_softc *); @@ -204,7 +205,6 @@ xhci_dump_trb(struct xhci_trb *trb) int xhci_init(struct xhci_softc *sc) { - uint64_t paddr; uint32_t hcr; int npage, error; @@ -250,12 +250,6 @@ xhci_init(struct xhci_softc *sc) DPRINTF(("%s: %d ports and %d slots\n", DEVNAME(sc), sc->sc_noport, sc->sc_noslot)); - /* Make sure to program a number of device slots we can handle. */ - if (sc->sc_noslot > USB_MAX_DEVICES) - sc->sc_noslot = USB_MAX_DEVICES; - hcr = XOREAD4(sc, XHCI_CONFIG) & ~XHCI_CONFIG_SLOTS_MASK; - XOWRITE4(sc, XHCI_CONFIG, hcr | sc->sc_noslot); - /* * Section 6.1 - Device Context Base Address Array * shall be aligned to a 64 byte boundary. @@ -321,6 +315,24 @@ xhci_init(struct xhci_softc *sc) return (ENOMEM); } + + xhci_config(sc); + + return (0); +} + +void +xhci_config(struct xhci_softc *sc) +{ + uint64_t paddr; + uint32_t hcr; + + /* Make sure to program a number of device slots we can handle. */ + if (sc->sc_noslot > USB_MAX_DEVICES) + sc->sc_noslot = USB_MAX_DEVICES; + hcr = XOREAD4(sc, XHCI_CONFIG) & ~XHCI_CONFIG_SLOTS_MASK; + XOWRITE4(sc, XHCI_CONFIG, hcr | sc->sc_noslot); + /* Set the device context base array address. */ paddr = (uint64_t)DMAADDR(&sc->sc_dcbaa.dma, 0); XOWRITE4(sc, XHCI_DCBAAP_LO, (uint32_t)paddr); @@ -368,18 +380,15 @@ xhci_init(struct xhci_softc *sc) DPRINTF(("%s: USBCMD=%08lx\n", DEVNAME(sc), XOREAD4(sc, XHCI_USBCMD))); DPRINTF(("%s: IMAN=%08lx\n", DEVNAME(sc), XRREAD4(sc, XHCI_IMAN(0)))); - - return (0); } int -xhci_detach(struct xhci_softc *sc, int flags) +xhci_detach(struct device *self, int flags) { + struct xhci_softc *sc = (struct xhci_softc *)self; int rv; - if (sc->sc_child != NULL) - rv = config_detach(sc->sc_child, flags); - + rv = config_detach_children(self, flags); if (rv != 0) { printf("%s: error while detaching %d\n", DEVNAME(sc), rv); return (rv); @@ -428,10 +437,12 @@ xhci_activate(struct device *self, int act) int rv = 0; switch (act) { - case DVACT_DEACTIVATE: - if (sc->sc_child != NULL) - rv = config_deactivate(sc->sc_child); - sc->sc_bus.dying = 1; + case DVACT_RESUME: + xhci_reset(sc); + xhci_ring_reset(sc, &sc->sc_cmd_ring); + xhci_ring_reset(sc, &sc->sc_evt_ring); + xhci_config(sc); + rv = config_activate_children(self, act); break; case DVACT_POWERDOWN: rv = config_activate_children(self, act); diff --git a/sys/dev/usb/xhcivar.h b/sys/dev/usb/xhcivar.h index edcdfb85bdf..4634eacfbef 100644 --- a/sys/dev/usb/xhcivar.h +++ b/sys/dev/usb/xhcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xhcivar.h,v 1.1 2014/03/08 14:34:11 mpi Exp $ */ +/* $OpenBSD: xhcivar.h,v 1.2 2014/03/25 17:23:40 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -109,12 +109,11 @@ struct xhci_softc { char sc_vendor[16]; /* Vendor string for root hub */ int sc_id_vendor; /* Vendor ID for root hub */ - struct device *sc_child; /* /dev/usb# device */ }; int xhci_init(struct xhci_softc *); int xhci_intr(void *); -int xhci_detach(struct xhci_softc *, int); +int xhci_detach(struct device *, int); int xhci_activate(struct device *, int); #define XREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (a)) |