mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
MFp4 //depot/projects/usb@157853
Clean up old way of polling the USB hardware. The existing polling support was a bit hackish. Submitted by: Hans Petter Selasky
This commit is contained in:
parent
bce32d7bc4
commit
4a35cda731
12 changed files with 33 additions and 246 deletions
|
|
@ -260,23 +260,16 @@ static void
|
|||
at91dci_wakeup_peer(struct usb2_xfer *xfer)
|
||||
{
|
||||
struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
|
||||
uint8_t use_polling;
|
||||
|
||||
if (!(sc->sc_flags.status_suspend)) {
|
||||
return;
|
||||
}
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, AT91_UDP_GSTATE_ESR);
|
||||
|
||||
/* wait 8 milliseconds */
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(8000);
|
||||
} else {
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
|
||||
}
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
|
||||
|
||||
AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, 0);
|
||||
}
|
||||
|
|
@ -1826,7 +1819,6 @@ at91dci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
|
||||
uint16_t value;
|
||||
uint16_t index;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -1844,8 +1836,6 @@ at91dci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
/* demultiplex the control request */
|
||||
|
||||
switch (std->req.bmRequestType) {
|
||||
|
|
@ -2459,7 +2449,6 @@ struct usb2_bus_methods at91dci_bus_methods =
|
|||
.pipe_init = &at91dci_pipe_init,
|
||||
.xfer_setup = &at91dci_xfer_setup,
|
||||
.xfer_unsetup = &at91dci_xfer_unsetup,
|
||||
.do_poll = &at91dci_do_poll,
|
||||
.get_hw_ep_profile = &at91dci_get_hw_ep_profile,
|
||||
.set_stall = &at91dci_set_stall,
|
||||
.clear_stall = &at91dci_clear_stall,
|
||||
|
|
|
|||
|
|
@ -204,25 +204,18 @@ static void
|
|||
atmegadci_wakeup_peer(struct usb2_xfer *xfer)
|
||||
{
|
||||
struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
|
||||
uint8_t use_polling;
|
||||
uint8_t temp;
|
||||
|
||||
if (!sc->sc_flags.status_suspend) {
|
||||
return;
|
||||
}
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
temp = ATMEGA_READ_1(sc, ATMEGA_UDCON);
|
||||
ATMEGA_WRITE_1(sc, ATMEGA_UDCON, temp | ATMEGA_UDCON_RMWKUP);
|
||||
|
||||
/* wait 8 milliseconds */
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(8000);
|
||||
} else {
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
|
||||
}
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
|
||||
|
||||
/* hardware should have cleared RMWKUP bit */
|
||||
}
|
||||
|
|
@ -1695,7 +1688,6 @@ atmegadci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
|
||||
uint16_t value;
|
||||
uint16_t index;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -1713,8 +1705,6 @@ atmegadci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
/* demultiplex the control request */
|
||||
|
||||
switch (std->req.bmRequestType) {
|
||||
|
|
@ -2319,7 +2309,6 @@ struct usb2_bus_methods atmegadci_bus_methods =
|
|||
.pipe_init = &atmegadci_pipe_init,
|
||||
.xfer_setup = &atmegadci_xfer_setup,
|
||||
.xfer_unsetup = &atmegadci_xfer_unsetup,
|
||||
.do_poll = &atmegadci_do_poll,
|
||||
.get_hw_ep_profile = &atmegadci_get_hw_ep_profile,
|
||||
.set_stall = &atmegadci_set_stall,
|
||||
.clear_stall = &atmegadci_clear_stall,
|
||||
|
|
|
|||
|
|
@ -3051,7 +3051,6 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
uint16_t value;
|
||||
uint16_t index;
|
||||
uint8_t l;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -3069,8 +3068,6 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
|
||||
"wValue=0x%04x wIndex=0x%04x\n",
|
||||
std->req.bmRequestType, std->req.bRequest,
|
||||
|
|
@ -3217,23 +3214,13 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
EOWRITE4(sc, port, v | EHCI_PS_FPR);
|
||||
}
|
||||
/* wait 20ms for resume sequence to complete */
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(20000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50);
|
||||
}
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50);
|
||||
|
||||
EOWRITE4(sc, port, v & ~(EHCI_PS_SUSP |
|
||||
EHCI_PS_FPR | (3 << 10) /* High Speed */ ));
|
||||
|
||||
/* settle time */
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(4000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250);
|
||||
}
|
||||
/* 4ms settle time */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250);
|
||||
break;
|
||||
case UHF_PORT_POWER:
|
||||
EOWRITE4(sc, port, v & ~EHCI_PS_PP);
|
||||
|
|
@ -3382,27 +3369,17 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
v &= ~(EHCI_PS_PE | EHCI_PS_PR);
|
||||
EOWRITE4(sc, port, v | EHCI_PS_PR);
|
||||
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
|
||||
} else {
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
}
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
|
||||
/* Terminate reset sequence. */
|
||||
if (!(sc->sc_flags & EHCI_SCFLG_NORESTERM))
|
||||
EOWRITE4(sc, port, v);
|
||||
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(EHCI_PORT_RESET_COMPLETE * 1000);
|
||||
} else {
|
||||
/* Wait for HC to complete reset. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(EHCI_PORT_RESET_COMPLETE));
|
||||
}
|
||||
/* Wait for HC to complete reset. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(EHCI_PORT_RESET_COMPLETE));
|
||||
|
||||
v = EOREAD4(sc, port);
|
||||
DPRINTF("ehci after reset, status=0x%08x\n", v);
|
||||
|
|
@ -3956,7 +3933,6 @@ struct usb2_bus_methods ehci_bus_methods =
|
|||
.pipe_init = ehci_pipe_init,
|
||||
.xfer_setup = ehci_xfer_setup,
|
||||
.xfer_unsetup = ehci_xfer_unsetup,
|
||||
.do_poll = ehci_do_poll,
|
||||
.get_dma_delay = ehci_get_dma_delay,
|
||||
.device_resume = ehci_device_resume,
|
||||
.device_suspend = ehci_device_suspend,
|
||||
|
|
|
|||
|
|
@ -206,25 +206,18 @@ musbotg_wakeup_peer(struct usb2_xfer *xfer)
|
|||
{
|
||||
struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus);
|
||||
uint8_t temp;
|
||||
uint8_t use_polling;
|
||||
|
||||
if (!(sc->sc_flags.status_suspend)) {
|
||||
return;
|
||||
}
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
temp = MUSB2_READ_1(sc, MUSB2_REG_POWER);
|
||||
temp |= MUSB2_MASK_RESUME;
|
||||
MUSB2_WRITE_1(sc, MUSB2_REG_POWER, temp);
|
||||
|
||||
/* wait 8 milliseconds */
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(8000);
|
||||
} else {
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
|
||||
}
|
||||
/* Wait for reset to complete. */
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
|
||||
|
||||
temp = MUSB2_READ_1(sc, MUSB2_REG_POWER);
|
||||
temp &= ~MUSB2_MASK_RESUME;
|
||||
|
|
@ -2232,7 +2225,6 @@ musbotg_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus);
|
||||
uint16_t value;
|
||||
uint16_t index;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -2250,8 +2242,6 @@ musbotg_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
/* demultiplex the control request */
|
||||
|
||||
switch (std->req.bmRequestType) {
|
||||
|
|
@ -2867,7 +2857,6 @@ struct usb2_bus_methods musbotg_bus_methods =
|
|||
.pipe_init = &musbotg_pipe_init,
|
||||
.xfer_setup = &musbotg_xfer_setup,
|
||||
.xfer_unsetup = &musbotg_xfer_unsetup,
|
||||
.do_poll = &musbotg_do_poll,
|
||||
.get_hw_ep_profile = &musbotg_get_hw_ep_profile,
|
||||
.set_stall = &musbotg_set_stall,
|
||||
.clear_stall = &musbotg_clear_stall,
|
||||
|
|
|
|||
|
|
@ -2156,7 +2156,6 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
uint16_t value;
|
||||
uint16_t index;
|
||||
uint8_t l;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -2174,8 +2173,6 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
|
||||
"wValue=0x%04x wIndex=0x%04x\n",
|
||||
std->req.bmRequestType, std->req.bRequest,
|
||||
|
|
@ -2410,13 +2407,8 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
OWRITE4(sc, port, UPS_RESET);
|
||||
for (v = 0;; v++) {
|
||||
if (v < 12) {
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
}
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
|
||||
if ((OREAD4(sc, port) & UPS_RESET) == 0) {
|
||||
break;
|
||||
|
|
@ -2853,7 +2845,6 @@ struct usb2_bus_methods ohci_bus_methods =
|
|||
.pipe_init = ohci_pipe_init,
|
||||
.xfer_setup = ohci_xfer_setup,
|
||||
.xfer_unsetup = ohci_xfer_unsetup,
|
||||
.do_poll = ohci_do_poll,
|
||||
.get_dma_delay = ohci_get_dma_delay,
|
||||
.device_resume = ohci_device_resume,
|
||||
.device_suspend = ohci_device_suspend,
|
||||
|
|
|
|||
|
|
@ -2382,7 +2382,7 @@ struct usb2_hub_descriptor_min uhci_hubd_piix =
|
|||
* events have been reset.
|
||||
*/
|
||||
static usb2_error_t
|
||||
uhci_portreset(uhci_softc_t *sc, uint16_t index, uint8_t use_polling)
|
||||
uhci_portreset(uhci_softc_t *sc, uint16_t index)
|
||||
{
|
||||
uint16_t port;
|
||||
uint16_t x;
|
||||
|
|
@ -2406,23 +2406,14 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index, uint8_t use_polling)
|
|||
UHCICMD(sc, (UHCI_CMD_MAXP | UHCI_CMD_RS));
|
||||
|
||||
/* wait a little bit */
|
||||
if (use_polling) {
|
||||
DELAY(10000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
|
||||
}
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
|
||||
}
|
||||
|
||||
x = URWMASK(UREAD2(sc, port));
|
||||
UWRITE2(sc, port, x | UHCI_PORTSC_PR);
|
||||
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
}
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
|
||||
DPRINTFN(4, "uhci port %d reset, status0 = 0x%04x\n",
|
||||
index, UREAD2(sc, port));
|
||||
|
|
@ -2449,13 +2440,8 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index, uint8_t use_polling)
|
|||
|
||||
for (lim = 0; lim < 12; lim++) {
|
||||
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(USB_PORT_RESET_DELAY * 1000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
|
||||
}
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
|
||||
|
||||
x = UREAD2(sc, port);
|
||||
|
||||
|
|
@ -2540,7 +2526,6 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
uint16_t index;
|
||||
uint16_t status;
|
||||
uint16_t change;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -2558,8 +2543,6 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
|
||||
"wValue=0x%04x wIndex=0x%04x\n",
|
||||
std->req.bmRequestType, std->req.bRequest,
|
||||
|
|
@ -2779,12 +2762,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
UWRITE2(sc, port, URWMASK(x));
|
||||
|
||||
/* wait 20ms for resume sequence to complete */
|
||||
if (use_polling) {
|
||||
/* polling */
|
||||
DELAY(20000);
|
||||
} else {
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50);
|
||||
}
|
||||
usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50);
|
||||
|
||||
/* clear suspend and resume detect */
|
||||
UWRITE2(sc, port, URWMASK(x) & ~(UHCI_PORTSC_RD |
|
||||
|
|
@ -2831,7 +2809,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
UWRITE2(sc, port, x | UHCI_PORTSC_SUSP);
|
||||
break;
|
||||
case UHF_PORT_RESET:
|
||||
std->err = uhci_portreset(sc, index, use_polling);
|
||||
std->err = uhci_portreset(sc, index);
|
||||
goto done;
|
||||
case UHF_PORT_POWER:
|
||||
/* pretend we turned on power */
|
||||
|
|
@ -3372,7 +3350,6 @@ struct usb2_bus_methods uhci_bus_methods =
|
|||
.pipe_init = uhci_pipe_init,
|
||||
.xfer_setup = uhci_xfer_setup,
|
||||
.xfer_unsetup = uhci_xfer_unsetup,
|
||||
.do_poll = uhci_do_poll,
|
||||
.get_dma_delay = uhci_get_dma_delay,
|
||||
.device_resume = uhci_device_resume,
|
||||
.device_suspend = uhci_device_suspend,
|
||||
|
|
|
|||
|
|
@ -1844,7 +1844,6 @@ uss820dci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
struct uss820dci_softc *sc = USS820_DCI_BUS2SC(xfer->xroot->bus);
|
||||
uint16_t value;
|
||||
uint16_t index;
|
||||
uint8_t use_polling;
|
||||
|
||||
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
|
||||
|
||||
|
|
@ -1862,8 +1861,6 @@ uss820dci_root_ctrl_done(struct usb2_xfer *xfer,
|
|||
value = UGETW(std->req.wValue);
|
||||
index = UGETW(std->req.wIndex);
|
||||
|
||||
use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0;
|
||||
|
||||
/* demultiplex the control request */
|
||||
|
||||
switch (std->req.bmRequestType) {
|
||||
|
|
@ -2481,7 +2478,6 @@ struct usb2_bus_methods uss820dci_bus_methods =
|
|||
.pipe_init = &uss820dci_pipe_init,
|
||||
.xfer_setup = &uss820dci_xfer_setup,
|
||||
.xfer_unsetup = &uss820dci_xfer_unsetup,
|
||||
.do_poll = &uss820dci_do_poll,
|
||||
.get_hw_ep_profile = &uss820dci_get_hw_ep_profile,
|
||||
.set_stall = &uss820dci_set_stall,
|
||||
.clear_stall = &uss820dci_clear_stall,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ struct usb2_bus_methods {
|
|||
/* USB Device and Host mode - Mandatory */
|
||||
|
||||
void (*pipe_init) (struct usb2_device *udev, struct usb2_endpoint_descriptor *edesc, struct usb2_pipe *pipe);
|
||||
void (*do_poll) (struct usb2_bus *);
|
||||
void (*xfer_setup) (struct usb2_setup_params *parm);
|
||||
void (*xfer_unsetup) (struct usb2_xfer *xfer);
|
||||
void (*get_dma_delay) (struct usb2_bus *, uint32_t *pdelay);
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@
|
|||
|
||||
/* Default USB configuration */
|
||||
|
||||
#ifndef USB_NO_POLL
|
||||
#define USB_NO_POLL 0
|
||||
#endif
|
||||
|
||||
#ifndef USB_USE_CONDVAR
|
||||
#define USB_USE_CONDVAR 0
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ struct usb2_read_dir {
|
|||
struct usb2_ctl_request {
|
||||
void *ucr_data;
|
||||
uint16_t ucr_flags;
|
||||
#define USB_USE_POLLING 0x0001 /* internal flag */
|
||||
#define USB_SHORT_XFER_OK 0x0004 /* allow short reads */
|
||||
#define USB_DELAY_STATUS_STAGE 0x0010 /* insert delay before STATUS stage */
|
||||
#define USB_USER_DATA_PTR 0x0020 /* internal flag */
|
||||
|
|
|
|||
|
|
@ -201,10 +201,6 @@ tr_setup:
|
|||
* o USB_SHORT_XFER_OK: allows the data transfer to be shorter than
|
||||
* specified
|
||||
*
|
||||
* o USB_USE_POLLING: forces the transfer to complete from the
|
||||
* current context by polling the interrupt handler. This flag can be
|
||||
* used to perform USB transfers after that the kernel has crashed.
|
||||
*
|
||||
* o USB_DELAY_STATUS_STAGE: allows the status stage to be performed
|
||||
* at a later point in time. This is tunable by the "hw.usb.ss_delay"
|
||||
* sysctl. This flag is mostly useful for debugging.
|
||||
|
|
@ -385,12 +381,8 @@ usb2_do_request_flags(struct usb2_device *udev, struct mtx *mtx,
|
|||
usb2_transfer_start(xfer);
|
||||
|
||||
while (usb2_transfer_pending(xfer)) {
|
||||
if ((flags & USB_USE_POLLING) || cold) {
|
||||
usb2_do_poll(udev->default_xfer, USB_DEFAULT_XFER_MAX);
|
||||
} else {
|
||||
usb2_cv_wait(udev->default_cv,
|
||||
xfer->xroot->xfer_mtx);
|
||||
}
|
||||
usb2_cv_wait(udev->default_cv,
|
||||
xfer->xroot->xfer_mtx);
|
||||
}
|
||||
|
||||
err = xfer->error;
|
||||
|
|
|
|||
|
|
@ -2705,120 +2705,14 @@ usb2_clear_stall_callback(struct usb2_xfer *xfer1,
|
|||
return (1); /* Clear Stall Finished */
|
||||
}
|
||||
|
||||
#if (USB_NO_POLL == 0)
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usb2_callout_poll
|
||||
*------------------------------------------------------------------------*/
|
||||
static void
|
||||
usb2_callout_poll(struct usb2_xfer *xfer)
|
||||
{
|
||||
struct usb2_callout *co;
|
||||
void (*cb) (void *);
|
||||
void *arg;
|
||||
struct mtx *mtx;
|
||||
uint32_t delta;
|
||||
|
||||
if (xfer == NULL) {
|
||||
return;
|
||||
}
|
||||
co = &xfer->timeout_handle;
|
||||
|
||||
#if __FreeBSD_version >= 800000
|
||||
mtx = (void *)(co->co.c_lock);
|
||||
#else
|
||||
mtx = co->co.c_mtx;
|
||||
#endif
|
||||
mtx_lock(mtx);
|
||||
|
||||
if (usb2_callout_pending(co)) {
|
||||
delta = ticks - co->co.c_time;
|
||||
if (!(delta & 0x80000000)) {
|
||||
|
||||
cb = co->co.c_func;
|
||||
arg = co->co.c_arg;
|
||||
|
||||
/* timed out */
|
||||
usb2_callout_stop(co);
|
||||
|
||||
(cb) (arg);
|
||||
}
|
||||
}
|
||||
mtx_unlock(mtx);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usb2_do_poll
|
||||
*
|
||||
* This function is called from keyboard driver when in polling
|
||||
* mode.
|
||||
*------------------------------------------------------------------------*/
|
||||
void
|
||||
usb2_do_poll(struct usb2_xfer **ppxfer, uint16_t max)
|
||||
{
|
||||
struct usb2_xfer *xfer;
|
||||
struct usb2_xfer_root *xroot;
|
||||
struct usb2_device *udev;
|
||||
struct usb2_proc_msg *pm;
|
||||
uint32_t to;
|
||||
uint16_t n;
|
||||
|
||||
/* compute system tick delay */
|
||||
to = ((uint32_t)(1000000)) / ((uint32_t)(hz));
|
||||
DELAY(to);
|
||||
atomic_add_int((volatile int *)&ticks, 1);
|
||||
|
||||
for (n = 0; n != max; n++) {
|
||||
xfer = ppxfer[n];
|
||||
if (xfer) {
|
||||
xroot = xfer->xroot;
|
||||
udev = xroot->udev;
|
||||
|
||||
/*
|
||||
* Poll hardware - signal that we are polling by
|
||||
* locking the private mutex:
|
||||
*/
|
||||
USB_XFER_LOCK(xfer);
|
||||
(udev->bus->methods->do_poll) (udev->bus);
|
||||
USB_XFER_UNLOCK(xfer);
|
||||
|
||||
/* poll clear stall start */
|
||||
USB_BUS_LOCK(xfer->xroot->bus);
|
||||
pm = &udev->cs_msg[0].hdr;
|
||||
(pm->pm_callback) (pm);
|
||||
USB_BUS_UNLOCK(xfer->xroot->bus);
|
||||
|
||||
if (udev->default_xfer[1]) {
|
||||
|
||||
/* poll timeout */
|
||||
usb2_callout_poll(udev->default_xfer[1]);
|
||||
|
||||
/* poll clear stall done thread */
|
||||
USB_BUS_LOCK(xfer->xroot->bus);
|
||||
pm = &udev->default_xfer[1]->
|
||||
xroot->done_m[0].hdr;
|
||||
(pm->pm_callback) (pm);
|
||||
USB_BUS_UNLOCK(xfer->xroot->bus);
|
||||
}
|
||||
/* poll timeout */
|
||||
usb2_callout_poll(xfer);
|
||||
|
||||
/* poll done thread */
|
||||
USB_BUS_LOCK(xfer->xroot->bus);
|
||||
pm = &xroot->done_m[0].hdr;
|
||||
(pm->pm_callback) (pm);
|
||||
USB_BUS_UNLOCK(xfer->xroot->bus);
|
||||
}
|
||||
static uint8_t once = 0;
|
||||
/* polling is currently not supported */
|
||||
if (!once) {
|
||||
once = 1;
|
||||
printf("usb2_do_poll: USB polling is "
|
||||
"not supported!\n");
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
usb2_do_poll(struct usb2_xfer **ppxfer, uint16_t max)
|
||||
{
|
||||
/* polling not supported */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue