summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-09-14 14:05:07 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-09-14 14:05:07 +0000
commit207131c53b15e7b5956177e90932b7445ff5b4ce (patch)
treed9fa50afd9fac8c180dcbf82190b7c9d7d9a04aa /firmware
parent08d285b414627851ca49f89a49e085fac83f1e89 (diff)
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/config.h10
-rw-r--r--firmware/target/arm/usb-drv-arc.c93
2 files changed, 33 insertions, 70 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 8addb62e95..e6a87915fc 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -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) \
diff --git a/firmware/target/arm/usb-drv-arc.c b/firmware/target/arm/usb-drv-arc.c
index f252f11f3e..855f67e4c3 100644
--- a/firmware/target/arm/usb-drv-arc.c
+++ b/firmware/target/arm/usb-drv-arc.c
@@ -428,9 +428,31 @@ void usb_drv_startup(void)
}
}
+#ifdef LOGF_ENABLE
+#define XFER_DIR_STR(dir) ((dir) ? "IN" : "OUT")
+#define XFER_TYPE_STR(type) \
+ ((type) == USB_ENDPOINT_XFER_CONTROL ? "CTRL" : \
+ ((type) == USB_ENDPOINT_XFER_ISOC ? "ISOC" : \
+ ((type) == USB_ENDPOINT_XFER_BULK ? "BULK" : \
+ ((type) == USB_ENDPOINT_XFER_INT ? "INTR" : "INVL"))))
+
+static void log_ep(int ep_num, int ep_dir, char* prefix)
+{
+ usb_endpoint_t* endpoint = &endpoints[ep_num];
+
+ logf("%s: ep%d %s %s %d", prefix, ep_num, XFER_DIR_STR(ep_dir),
+ XFER_TYPE_STR(endpoint->type[ep_dir]),
+ endpoint->max_pkt_size[ep_dir]);
+}
+#else
+#undef log_ep
+#define log_ep(...)
+#endif
+
/* manual: 32.14.1 Device Controller Initialization */
-static void _usb_drv_init(bool attach)
+void usb_drv_init(void)
{
+ /* USB core decides */
usb_drv_reset();
REG_USBMODE = USBMODE_CTRL_MODE_DEVICE;
@@ -447,19 +469,12 @@ static void _usb_drv_init(bool attach)
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;
- }
+ /* enable USB interrupts */
+ REG_USBINTR =
+ USBINTR_INT_EN |
+ USBINTR_ERR_INT_EN |
+ USBINTR_PTC_DETECT_EN |
+ USBINTR_RESET_EN;
usb_drv_int_enable(true);
@@ -472,49 +487,12 @@ static void _usb_drv_init(bool attach)
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) \
- ((type) == USB_ENDPOINT_XFER_CONTROL ? "CTRL" : \
- ((type) == USB_ENDPOINT_XFER_ISOC ? "ISOC" : \
- ((type) == USB_ENDPOINT_XFER_BULK ? "BULK" : \
- ((type) == USB_ENDPOINT_XFER_INT ? "INTR" : "INVL"))))
-
-static void log_ep(int ep_num, int ep_dir, char* prefix)
-{
- usb_endpoint_t* endpoint = &endpoints[ep_num];
-
- logf("%s: ep%d %s %s %d", prefix, ep_num, XFER_DIR_STR(ep_dir),
- XFER_TYPE_STR(endpoint->type[ep_dir]),
- endpoint->max_pkt_size[ep_dir]);
-}
-#else
-#undef log_ep
-#define log_ep(...)
-#endif
-
-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);
-#endif
}
/* 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,17 +541,8 @@ 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 */
- }
+ bus_reset();
+ usb_core_bus_reset(); /* tell mom */
}
/* port change */