mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Make several timing parameters of the USB enumeration sequence tuneable.
Also update the port reset time from 250ms to 50ms. Some USB devices have a hard limit in hardware at 222ms for the port reset time and will not enumerate unless this delay is closer to the usb.org defined value. This patch can fix enumeration with some USB devices. Tested by: Guido van Rooij Submitted by: Nick Hibma MFC after: 1 week
This commit is contained in:
parent
e1fd361700
commit
3750641271
8 changed files with 195 additions and 106 deletions
|
|
@ -3369,7 +3369,7 @@ ehci_roothub_exec(struct usb_device *udev,
|
|||
|
||||
/* Wait for reset to complete. */
|
||||
usb_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
USB_MS_TO_TICKS(usb_port_root_reset_delay));
|
||||
|
||||
/* Terminate reset sequence. */
|
||||
if (!(sc->sc_flags & EHCI_SCFLG_NORESTERM))
|
||||
|
|
|
|||
|
|
@ -2345,7 +2345,7 @@ ohci_roothub_exec(struct usb_device *udev,
|
|||
for (v = 0;; v++) {
|
||||
if (v < 12) {
|
||||
usb_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
USB_MS_TO_TICKS(usb_port_root_reset_delay));
|
||||
|
||||
if ((OREAD4(sc, port) & UPS_RESET) == 0) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -2393,7 +2393,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index)
|
|||
UWRITE2(sc, port, x | UHCI_PORTSC_PR);
|
||||
|
||||
usb_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
|
||||
USB_MS_TO_TICKS(usb_port_root_reset_delay));
|
||||
|
||||
DPRINTFN(4, "uhci port %d reset, status0 = 0x%04x\n",
|
||||
index, UREAD2(sc, port));
|
||||
|
|
@ -2421,7 +2421,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index)
|
|||
for (lim = 0; lim < 12; lim++) {
|
||||
|
||||
usb_pause_mtx(&sc->sc_bus.bus_mtx,
|
||||
USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
|
||||
USB_MS_TO_TICKS(usb_port_reset_delay));
|
||||
|
||||
x = UREAD2(sc, port);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,31 +93,29 @@ MALLOC_DECLARE(M_USBHC);
|
|||
#define USB_POWER_MODE_SUSPEND 3 /* force suspend */
|
||||
#define USB_POWER_MODE_RESUME 4 /* force resume */
|
||||
|
||||
#if 0
|
||||
/* These are the values from the USB specification. */
|
||||
#define USB_PORT_RESET_DELAY 10 /* ms */
|
||||
#define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
|
||||
#define USB_PORT_RESET_RECOVERY 10 /* ms */
|
||||
#define USB_PORT_POWERUP_DELAY 100 /* ms */
|
||||
#define USB_PORT_RESUME_DELAY 20 /* ms */
|
||||
#define USB_SET_ADDRESS_SETTLE 2 /* ms */
|
||||
#define USB_RESUME_DELAY (20*5) /* ms */
|
||||
#define USB_RESUME_WAIT 10 /* ms */
|
||||
#define USB_RESUME_RECOVERY 10 /* ms */
|
||||
#define USB_EXTRA_POWER_UP_TIME 0 /* ms */
|
||||
#else
|
||||
#define USB_PORT_RESET_DELAY_SPEC 10 /* ms */
|
||||
#define USB_PORT_ROOT_RESET_DELAY_SPEC 50 /* ms */
|
||||
#define USB_PORT_RESET_RECOVERY_SPEC 10 /* ms */
|
||||
#define USB_PORT_POWERUP_DELAY_SPEC 100 /* ms */
|
||||
#define USB_PORT_RESUME_DELAY_SPEC 20 /* ms */
|
||||
#define USB_SET_ADDRESS_SETTLE_SPEC 2 /* ms */
|
||||
#define USB_RESUME_DELAY_SPEC (20*5) /* ms */
|
||||
#define USB_RESUME_WAIT_SPEC 10 /* ms */
|
||||
#define USB_RESUME_RECOVERY_SPEC 10 /* ms */
|
||||
#define USB_EXTRA_POWER_UP_TIME_SPEC 0 /* ms */
|
||||
|
||||
/* Allow for marginal and non-conforming devices. */
|
||||
#define USB_PORT_RESET_DELAY 50 /* ms */
|
||||
#define USB_PORT_ROOT_RESET_DELAY 250 /* ms */
|
||||
#define USB_PORT_RESET_RECOVERY 250 /* ms */
|
||||
#define USB_PORT_POWERUP_DELAY 300 /* ms */
|
||||
#define USB_PORT_RESUME_DELAY (20*2) /* ms */
|
||||
#define USB_SET_ADDRESS_SETTLE 10 /* ms */
|
||||
#define USB_RESUME_DELAY (50*5) /* ms */
|
||||
#define USB_RESUME_WAIT 50 /* ms */
|
||||
#define USB_RESUME_RECOVERY 50 /* ms */
|
||||
#define USB_EXTRA_POWER_UP_TIME 20 /* ms */
|
||||
#endif
|
||||
#define USB_PORT_RESET_DELAY 50 /* ms */
|
||||
#define USB_PORT_ROOT_RESET_DELAY 250 /* ms */
|
||||
#define USB_PORT_RESET_RECOVERY 250 /* ms */
|
||||
#define USB_PORT_POWERUP_DELAY 300 /* ms */
|
||||
#define USB_PORT_RESUME_DELAY (20*2) /* ms */
|
||||
#define USB_SET_ADDRESS_SETTLE 10 /* ms */
|
||||
#define USB_RESUME_DELAY (50*5) /* ms */
|
||||
#define USB_RESUME_WAIT 50 /* ms */
|
||||
#define USB_RESUME_RECOVERY 50 /* ms */
|
||||
#define USB_EXTRA_POWER_UP_TIME 20 /* ms */
|
||||
|
||||
#define USB_MIN_POWER 100 /* mA */
|
||||
#define USB_MAX_POWER 500 /* mA */
|
||||
|
|
|
|||
|
|
@ -68,6 +68,55 @@ SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RW,
|
|||
|
||||
TUNABLE_INT("hw.usb.debug", &usb_debug);
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
/*
|
||||
* Sysctls to modify timings/delays
|
||||
*/
|
||||
static SYSCTL_NODE(_hw_usb, OID_AUTO, timings, CTLFLAG_RW, 0, "Timings");
|
||||
static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
TUNABLE_INT("hw.usb.timings.port_reset_delay", (int *)&usb_port_reset_delay);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_port_reset_delay, sizeof(usb_port_reset_delay),
|
||||
usb_timings_sysctl_handler, "IU", "Port Reset Delay");
|
||||
TUNABLE_INT("hw.usb.timings.port_root_reset_delay", (int *)&usb_port_root_reset_delay);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_port_root_reset_delay, sizeof(usb_port_root_reset_delay),
|
||||
usb_timings_sysctl_handler, "IU", "Root Port Reset Delay");
|
||||
TUNABLE_INT("hw.usb.timings.port_reset_recovery", (int *)&usb_port_reset_recovery);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_port_reset_recovery, sizeof(usb_port_reset_recovery),
|
||||
usb_timings_sysctl_handler, "IU", "Port Reset Recovery");
|
||||
TUNABLE_INT("hw.usb.timings.port_powerup_delay", (int *)&usb_port_powerup_delay);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_port_powerup_delay, sizeof(usb_port_powerup_delay),
|
||||
usb_timings_sysctl_handler, "IU", "Port PowerUp Delay");
|
||||
TUNABLE_INT("hw.usb.timings.port_resume_delay", (int *)&usb_port_resume_delay);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_port_resume_delay, sizeof(usb_port_resume_delay),
|
||||
usb_timings_sysctl_handler, "IU", "Port Resume Delay");
|
||||
TUNABLE_INT("hw.usb.timings.set_address_settle", (int *)&usb_set_address_settle);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_set_address_settle, sizeof(usb_set_address_settle),
|
||||
usb_timings_sysctl_handler, "IU", "Set Address Settle");
|
||||
TUNABLE_INT("hw.usb.timings.resume_delay", (int *)&usb_resume_delay);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_resume_delay, sizeof(usb_resume_delay),
|
||||
usb_timings_sysctl_handler, "IU", "Resume Delay");
|
||||
TUNABLE_INT("hw.usb.timings.resume_wait", (int *)&usb_resume_wait);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_resume_wait, sizeof(usb_resume_wait),
|
||||
usb_timings_sysctl_handler, "IU", "Resume Wait");
|
||||
TUNABLE_INT("hw.usb.timings.resume_recovery", (int *)&usb_resume_recovery);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_resume_recovery, sizeof(usb_resume_recovery),
|
||||
usb_timings_sysctl_handler, "IU", "Resume Recovery");
|
||||
TUNABLE_INT("hw.usb.timings.extra_power_up_time", (int *)&usb_extra_power_up_time);
|
||||
SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RW,
|
||||
&usb_extra_power_up_time, sizeof(usb_extra_power_up_time),
|
||||
usb_timings_sysctl_handler, "IU", "Extra PowerUp Time");
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usb_dump_iface
|
||||
*
|
||||
|
|
@ -176,3 +225,87 @@ usb_dump_xfer(struct usb_xfer *xfer)
|
|||
xfer->endpoint->edesc->bEndpointAddress,
|
||||
xfer->endpoint->edesc->bmAttributes);
|
||||
}
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
unsigned int usb_port_reset_delay = USB_PORT_RESET_DELAY;
|
||||
unsigned int usb_port_root_reset_delay = USB_PORT_ROOT_RESET_DELAY;
|
||||
unsigned int usb_port_reset_recovery = USB_PORT_RESET_RECOVERY;
|
||||
unsigned int usb_port_powerup_delay = USB_PORT_POWERUP_DELAY;
|
||||
unsigned int usb_port_resume_delay = USB_PORT_RESUME_DELAY;
|
||||
unsigned int usb_set_address_settle = USB_SET_ADDRESS_SETTLE;
|
||||
unsigned int usb_resume_delay = USB_RESUME_DELAY;
|
||||
unsigned int usb_resume_wait = USB_RESUME_WAIT;
|
||||
unsigned int usb_resume_recovery = USB_RESUME_RECOVERY;
|
||||
unsigned int usb_extra_power_up_time = USB_EXTRA_POWER_UP_TIME;
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usb_timings_sysctl_handler
|
||||
*
|
||||
* This function updates timings variables, adjusting them where necessary.
|
||||
*------------------------------------------------------------------------*/
|
||||
static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
int error = 0;
|
||||
unsigned int val;
|
||||
|
||||
/*
|
||||
* Attempt to get a coherent snapshot by making a copy of the data.
|
||||
*/
|
||||
if (arg1)
|
||||
val = *(unsigned int *)arg1;
|
||||
else
|
||||
val = arg2;
|
||||
error = SYSCTL_OUT(req, &val, sizeof(int));
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
|
||||
if (!arg1)
|
||||
return EPERM;
|
||||
|
||||
error = SYSCTL_IN(req, &val, sizeof(unsigned int));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* Now make sure the values are decent, and certainly no lower than
|
||||
* what the USB spec prescribes.
|
||||
*/
|
||||
unsigned int *p = (unsigned int *)arg1;
|
||||
if (p == &usb_port_reset_delay) {
|
||||
if (val < USB_PORT_RESET_DELAY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_port_root_reset_delay) {
|
||||
if (val < USB_PORT_ROOT_RESET_DELAY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_port_reset_recovery) {
|
||||
if (val < USB_PORT_RESET_RECOVERY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_port_powerup_delay) {
|
||||
if (val < USB_PORT_POWERUP_DELAY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_port_resume_delay) {
|
||||
if (val < USB_PORT_RESUME_DELAY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_set_address_settle) {
|
||||
if (val < USB_SET_ADDRESS_SETTLE_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_resume_delay) {
|
||||
if (val < USB_RESUME_DELAY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_resume_wait) {
|
||||
if (val < USB_RESUME_WAIT_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_resume_recovery) {
|
||||
if (val < USB_RESUME_RECOVERY_SPEC)
|
||||
return (EINVAL);
|
||||
} else if (p == &usb_extra_power_up_time) {
|
||||
if (val < USB_EXTRA_POWER_UP_TIME_SPEC)
|
||||
return (EINVAL);
|
||||
} else {
|
||||
/* noop */
|
||||
}
|
||||
|
||||
*p = val;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -59,4 +59,28 @@ void usb_dump_queue(struct usb_endpoint *ep);
|
|||
void usb_dump_endpoint(struct usb_endpoint *ep);
|
||||
void usb_dump_xfer(struct usb_xfer *xfer);
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
extern unsigned int usb_port_reset_delay;
|
||||
extern unsigned int usb_port_root_reset_delay;
|
||||
extern unsigned int usb_port_reset_recovery;
|
||||
extern unsigned int usb_port_powerup_delay;
|
||||
extern unsigned int usb_port_resume_delay;
|
||||
extern unsigned int usb_set_address_settle;
|
||||
extern unsigned int usb_resume_delay;
|
||||
extern unsigned int usb_resume_wait;
|
||||
extern unsigned int usb_resume_recovery;
|
||||
extern unsigned int usb_extra_power_up_time;
|
||||
#else
|
||||
#define usb_port_reset_delay USB_PORT_RESET_DELAY
|
||||
#define usb_port_root_reset_delay USB_PORT_ROOT_RESET_DELAY
|
||||
#define usb_port_reset_recovery USB_PORT_RESET_RECOVERY
|
||||
#define usb_port_powerup_delay USB_PORT_POWERUP_DELAY
|
||||
#define usb_port_resume_delay USB_PORT_RESUME_DELAY
|
||||
#define usb_set_address_settle USB_SET_ADDRESS_SETTLE
|
||||
#define usb_resume_delay USB_RESUME_DELAY
|
||||
#define usb_resume_wait USB_RESUME_WAIT
|
||||
#define usb_resume_recovery USB_RESUME_RECOVERY
|
||||
#define usb_extra_power_up_time USB_EXTRA_POWER_UP_TIME
|
||||
#endif
|
||||
|
||||
#endif /* _USB_DEBUG_H_ */
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ repeat:
|
|||
/* wait for maximum device power up time */
|
||||
|
||||
usb_pause_mtx(NULL,
|
||||
USB_MS_TO_TICKS(USB_PORT_POWERUP_DELAY));
|
||||
USB_MS_TO_TICKS(usb_port_powerup_delay));
|
||||
|
||||
/* reset port, which implies enabling it */
|
||||
|
||||
|
|
@ -978,7 +978,7 @@ uhub_attach(device_t dev)
|
|||
|
||||
/* get power delay */
|
||||
pwrdly = ((hubdesc20.bPwrOn2PwrGood * UHD_PWRON_FACTOR) +
|
||||
USB_EXTRA_POWER_UP_TIME);
|
||||
usb_extra_power_up_time);
|
||||
|
||||
/* get complete HUB descriptor */
|
||||
if (nports >= 8) {
|
||||
|
|
@ -1023,7 +1023,7 @@ uhub_attach(device_t dev)
|
|||
|
||||
/* get power delay */
|
||||
pwrdly = ((hubdesc30.bPwrOn2PwrGood * UHD_PWRON_FACTOR) +
|
||||
USB_EXTRA_POWER_UP_TIME);
|
||||
usb_extra_power_up_time);
|
||||
|
||||
/* get complete HUB descriptor */
|
||||
if (nports >= 8) {
|
||||
|
|
@ -1052,7 +1052,7 @@ uhub_attach(device_t dev)
|
|||
/* default number of ports */
|
||||
nports = 1;
|
||||
/* default power delay */
|
||||
pwrdly = ((10 * UHD_PWRON_FACTOR) + USB_EXTRA_POWER_UP_TIME);
|
||||
pwrdly = ((10 * UHD_PWRON_FACTOR) + usb_extra_power_up_time);
|
||||
break;
|
||||
}
|
||||
if (nports == 0) {
|
||||
|
|
@ -2262,7 +2262,7 @@ usb_dev_resume_peer(struct usb_device *udev)
|
|||
}
|
||||
|
||||
/* resume settle time */
|
||||
usb_pause_mtx(NULL, USB_MS_TO_TICKS(USB_PORT_RESUME_DELAY));
|
||||
usb_pause_mtx(NULL, USB_MS_TO_TICKS(usb_port_resume_delay));
|
||||
|
||||
if (bus->methods->device_resume != NULL) {
|
||||
/* resume USB device on the USB controller */
|
||||
|
|
@ -2415,7 +2415,7 @@ repeat:
|
|||
NULL, udev->port_no, UHF_PORT_SUSPEND);
|
||||
|
||||
/* resume settle time */
|
||||
usb_pause_mtx(NULL, USB_MS_TO_TICKS(USB_PORT_RESUME_DELAY));
|
||||
usb_pause_mtx(NULL, USB_MS_TO_TICKS(usb_port_resume_delay));
|
||||
}
|
||||
DPRINTF("Suspend was cancelled!\n");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -73,14 +73,6 @@ SYSCTL_INT(_hw_usb, OID_AUTO, no_cs_fail, CTLFLAG_RW,
|
|||
&usb_no_cs_fail, 0, "USB clear stall failures are ignored, if set");
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
static int usb_pr_poll_delay = USB_PORT_RESET_DELAY;
|
||||
static int usb_pr_recovery_delay = USB_PORT_RESET_RECOVERY;
|
||||
|
||||
SYSCTL_INT(_hw_usb, OID_AUTO, pr_poll_delay, CTLFLAG_RW,
|
||||
&usb_pr_poll_delay, 0, "USB port reset poll delay in ms");
|
||||
SYSCTL_INT(_hw_usb, OID_AUTO, pr_recovery_delay, CTLFLAG_RW,
|
||||
&usb_pr_recovery_delay, 0, "USB port reset recovery delay in ms");
|
||||
|
||||
#ifdef USB_REQ_DEBUG
|
||||
/* The following structures are used in connection to fault injection. */
|
||||
struct usb_ctrl_debug {
|
||||
|
|
@ -791,12 +783,6 @@ usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
|
|||
uint16_t status;
|
||||
uint16_t change;
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
uint16_t pr_poll_delay;
|
||||
uint16_t pr_recovery_delay;
|
||||
|
||||
#endif
|
||||
|
||||
DPRINTF("\n");
|
||||
|
||||
/* clear any leftover port reset changes first */
|
||||
|
|
@ -811,29 +797,12 @@ usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
|
|||
if (err)
|
||||
goto done;
|
||||
#ifdef USB_DEBUG
|
||||
/* range check input parameters */
|
||||
pr_poll_delay = usb_pr_poll_delay;
|
||||
if (pr_poll_delay < 1) {
|
||||
pr_poll_delay = 1;
|
||||
} else if (pr_poll_delay > 1000) {
|
||||
pr_poll_delay = 1000;
|
||||
}
|
||||
pr_recovery_delay = usb_pr_recovery_delay;
|
||||
if (pr_recovery_delay > 1000) {
|
||||
pr_recovery_delay = 1000;
|
||||
}
|
||||
#endif
|
||||
n = 0;
|
||||
while (1) {
|
||||
#ifdef USB_DEBUG
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(pr_poll_delay));
|
||||
n += pr_poll_delay;
|
||||
#else
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
|
||||
n += USB_PORT_RESET_DELAY;
|
||||
#endif
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(usb_port_reset_delay));
|
||||
n += usb_port_reset_delay;
|
||||
err = usbd_req_get_port_status(udev, mtx, &ps, port);
|
||||
if (err)
|
||||
goto done;
|
||||
|
|
@ -875,13 +844,8 @@ usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
|
|||
err = USB_ERR_TIMEOUT;
|
||||
goto done;
|
||||
}
|
||||
#ifdef USB_DEBUG
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(pr_recovery_delay));
|
||||
#else
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_RECOVERY));
|
||||
#endif
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(usb_port_reset_recovery));
|
||||
|
||||
done:
|
||||
DPRINTFN(2, "port %d reset returning error=%s\n",
|
||||
|
|
@ -912,12 +876,6 @@ usbd_req_warm_reset_port(struct usb_device *udev, struct mtx *mtx,
|
|||
uint16_t status;
|
||||
uint16_t change;
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
uint16_t pr_poll_delay;
|
||||
uint16_t pr_recovery_delay;
|
||||
|
||||
#endif
|
||||
|
||||
DPRINTF("\n");
|
||||
|
||||
err = usbd_req_get_port_status(udev, mtx, &ps, port);
|
||||
|
|
@ -947,30 +905,11 @@ usbd_req_warm_reset_port(struct usb_device *udev, struct mtx *mtx,
|
|||
if (err)
|
||||
goto done;
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
/* range check input parameters */
|
||||
pr_poll_delay = usb_pr_poll_delay;
|
||||
if (pr_poll_delay < 1) {
|
||||
pr_poll_delay = 1;
|
||||
} else if (pr_poll_delay > 1000) {
|
||||
pr_poll_delay = 1000;
|
||||
}
|
||||
pr_recovery_delay = usb_pr_recovery_delay;
|
||||
if (pr_recovery_delay > 1000) {
|
||||
pr_recovery_delay = 1000;
|
||||
}
|
||||
#endif
|
||||
n = 0;
|
||||
while (1) {
|
||||
#ifdef USB_DEBUG
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(pr_poll_delay));
|
||||
n += pr_poll_delay;
|
||||
#else
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
|
||||
n += USB_PORT_RESET_DELAY;
|
||||
#endif
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(usb_port_reset_delay));
|
||||
n += usb_port_reset_delay;
|
||||
err = usbd_req_get_port_status(udev, mtx, &ps, port);
|
||||
if (err)
|
||||
goto done;
|
||||
|
|
@ -1004,13 +943,8 @@ usbd_req_warm_reset_port(struct usb_device *udev, struct mtx *mtx,
|
|||
err = USB_ERR_TIMEOUT;
|
||||
goto done;
|
||||
}
|
||||
#ifdef USB_DEBUG
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(pr_recovery_delay));
|
||||
#else
|
||||
/* wait for the device to recover from reset */
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_RECOVERY));
|
||||
#endif
|
||||
usb_pause_mtx(mtx, USB_MS_TO_TICKS(usb_port_reset_recovery));
|
||||
|
||||
done:
|
||||
DPRINTFN(2, "port %d warm reset returning error=%s\n",
|
||||
|
|
@ -1569,7 +1503,7 @@ usbd_req_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t addr)
|
|||
done:
|
||||
/* allow device time to set new address */
|
||||
usb_pause_mtx(mtx,
|
||||
USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
|
||||
USB_MS_TO_TICKS(usb_set_address_settle));
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue