Convert ARC USB driver code to always use setup packet detection and remove the bus-reset-based detection method for it. This prevents false USB detection from chargers or other accesories that aren't actually a host but can trigger the bus reset condition.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30546 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2011-09-14 14:05:07 +00:00
parent 08d285b414
commit 207131c53b
2 changed files with 38 additions and 75 deletions

View file

@ -736,7 +736,7 @@ Lyre prototype 1 */
/* Priority in bootloader is wanted */
#define HAVE_PRIORITY_SCHEDULING
#define USB_STATUS_BY_EVENT
#define USB_DETECT_BY_DRV
#define USB_DETECT_BY_CORE
#if defined(HAVE_USBSTACK) && CONFIG_USBOTG == USBOTG_ARC
#define INCLUDE_TIMEOUT_API
#endif
@ -763,7 +763,7 @@ Lyre prototype 1 */
#ifdef HAVE_USBSTACK
#if CONFIG_USBOTG == USBOTG_ARC
#define USB_STATUS_BY_EVENT
#define USB_DETECT_BY_DRV
#define USB_DETECT_BY_CORE
#define INCLUDE_TIMEOUT_API
#elif CONFIG_USBOTG == USBOTG_AS3525
#define USB_STATUS_BY_EVENT
@ -779,12 +779,6 @@ Lyre prototype 1 */
#endif /* BOOTLOADER */
#ifdef PHILIPS_SA9200
/* Instead use the request for a device descriptor to detect a host */
#undef USB_DETECT_BY_DRV
#define USB_DETECT_BY_CORE
#endif
#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \
|| (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \
|| defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) \

View file

@ -428,53 +428,6 @@ void usb_drv_startup(void)
}
}
/* manual: 32.14.1 Device Controller Initialization */
static void _usb_drv_init(bool attach)
{
usb_drv_reset();
REG_USBMODE = USBMODE_CTRL_MODE_DEVICE;
#ifdef USB_NO_HIGH_SPEED
/* Force device to full speed */
/* See 32.9.5.9.2 */
REG_PORTSC1 |= PORTSCX_PORT_FORCE_FULL_SPEED;
#endif
init_control_queue_heads();
memset(td_array, 0, sizeof td_array);
REG_ENDPOINTLISTADDR = (unsigned int)qh_array;
REG_DEVICEADDR = 0;
if (!attach) {
/* enable RESET interrupt */
REG_USBINTR = USBINTR_RESET_EN;
}
else
{
/* enable USB interrupts */
REG_USBINTR =
USBINTR_INT_EN |
USBINTR_ERR_INT_EN |
USBINTR_PTC_DETECT_EN |
USBINTR_RESET_EN;
}
usb_drv_int_enable(true);
/* go go go */
REG_USBCMD |= USBCMD_RUN;
logf("usb_drv_init() finished");
logf("usb id %x", REG_ID);
logf("usb dciversion %x", REG_DCIVERSION);
logf("usb dccparams %x", REG_DCCPARAMS);
/* now a bus reset will occur. see bus_reset() */
(void)attach;
}
#ifdef LOGF_ENABLE
#define XFER_DIR_STR(dir) ((dir) ? "IN" : "OUT")
#define XFER_TYPE_STR(type) \
@ -496,25 +449,50 @@ static void log_ep(int ep_num, int ep_dir, char* prefix)
#define log_ep(...)
#endif
/* manual: 32.14.1 Device Controller Initialization */
void usb_drv_init(void)
{
#ifdef USB_DETECT_BY_CORE
/* USB core decides */
_usb_drv_init(true);
#else
/* Use bus reset condition */
_usb_drv_init(false);
usb_drv_reset();
REG_USBMODE = USBMODE_CTRL_MODE_DEVICE;
#ifdef USB_NO_HIGH_SPEED
/* Force device to full speed */
/* See 32.9.5.9.2 */
REG_PORTSC1 |= PORTSCX_PORT_FORCE_FULL_SPEED;
#endif
init_control_queue_heads();
memset(td_array, 0, sizeof td_array);
REG_ENDPOINTLISTADDR = (unsigned int)qh_array;
REG_DEVICEADDR = 0;
/* enable USB interrupts */
REG_USBINTR =
USBINTR_INT_EN |
USBINTR_ERR_INT_EN |
USBINTR_PTC_DETECT_EN |
USBINTR_RESET_EN;
usb_drv_int_enable(true);
/* go go go */
REG_USBCMD |= USBCMD_RUN;
logf("usb_drv_init() finished");
logf("usb id %x", REG_ID);
logf("usb dciversion %x", REG_DCIVERSION);
logf("usb dccparams %x", REG_DCCPARAMS);
/* now a bus reset will occur. see bus_reset() */
}
/* fully enable driver */
void usb_drv_attach(void)
{
logf("usb_drv_attach");
#ifndef USB_DETECT_BY_CORE
sleep(HZ/10);
_usb_drv_init(true);
#endif
}
void usb_drv_exit(void)
@ -563,18 +541,9 @@ void usb_drv_int(void)
/* reset interrupt */
if (status & USBSTS_RESET) {
REG_USBSTS = USBSTS_RESET;
if (UNLIKELY(usbintr == USBINTR_RESET_EN)) {
/* USB detected - detach and inform */
usb_drv_stop();
usb_drv_usb_detect_event();
}
else
{
bus_reset();
usb_core_bus_reset(); /* tell mom */
}
}
/* port change */
if (status & USBSTS_PORT_CHANGE) {