summaryrefslogtreecommitdiffstats
path: root/firmware/usb.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-17 12:24:41 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-17 12:24:41 +0000
commit05f6f3419aec991307e7c81e0738e0496a21d89b (patch)
tree4bad4a187bc2a2bdd714e086ac9910a9b3de6357 /firmware/usb.c
parentbcc0f88372fd2be986a5e279dd7e3bd556d6c984 (diff)
downloadrockbox-05f6f3419aec991307e7c81e0738e0496a21d89b.tar.gz
rockbox-05f6f3419aec991307e7c81e0738e0496a21d89b.tar.bz2
rockbox-05f6f3419aec991307e7c81e0738e0496a21d89b.zip
Add a higher level USB detection that prevents fraudulent bus resets from causing USB mode to be entered. Enable for SA9200 only at this time. Also, for SA9200, use the bus power GPIO rather than the 'connector inserted' GPIO to detect the cable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29068 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usb.c')
-rw-r--r--firmware/usb.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/firmware/usb.c b/firmware/usb.c
index c8f0118730..ca0e86b478 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -136,7 +136,7 @@ static inline void usb_slave_mode(bool on)
}
else /* usb_state == USB_INSERTED (only!) */
{
-#ifndef USB_DETECT_BY_DRV
+#if !defined(USB_DETECT_BY_DRV) && !defined(USB_DETECT_BY_CORE)
usb_enable(false);
#endif
#ifdef HAVE_PRIORITY_SCHEDULING
@@ -244,7 +244,7 @@ static void usb_thread(void)
(struct usb_transfer_completion_event_data*)ev.data);
break;
#endif
-#ifdef USB_DETECT_BY_DRV
+#if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE)
/* In this case, these events the handle cable insertion USB
* driver determines INSERTED/EXTRACTED state. */
case USB_POWERED:
@@ -263,7 +263,7 @@ static void usb_thread(void)
* available. */
queue_post(&usb_queue, USB_EXTRACTED, 0);
break;
-#endif /* USB_DETECT_BY_DRV */
+#endif /* USB_DETECT_BY_DRV || USB_DETECT_BY_CORE */
case USB_INSERTED:
#ifdef HAVE_LCD_BITMAP
if(do_screendump_instead_of_usb)
@@ -379,7 +379,8 @@ static void usb_thread(void)
#ifdef HAVE_USBSTACK
if(!exclusive_storage_access)
{
-#ifndef USB_DETECT_BY_DRV /* Disabled handling USB_UNPOWERED */
+#if !defined(USB_DETECT_BY_DRV) && !defined(USB_DETECT_BY_CORE)
+ /* Disabled handling USB_UNPOWERED */
usb_enable(false);
#endif
break;
@@ -457,7 +458,8 @@ void usb_status_event(int current_status)
{
/* Caller isn't expected to filter for changes in status.
* current_status:
- * USB_DETECT_BY_DRV: USB_POWERED, USB_UNPOWERED, USB_INSERTED (driver)
+ * USB_DETECT_BY_DRV/CORE: USB_POWERED, USB_UNPOWERED,
+ USB_INSERTED (driver/core)
* else: USB_INSERTED, USB_EXTRACTED
*/
if(usb_monitor_enabled)
@@ -481,7 +483,10 @@ void usb_start_monitoring(void)
usb_monitor_enabled = true;
-#ifdef USB_DETECT_BY_DRV
+#ifdef USB_STATUS_BY_EVENT
+ /* Filter the status - an event may have been missed because it was
+ * sent before monitoring was enabled due to the connector already
+ * having been inserted before before or during boot. */
status = (status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED;
#endif
usb_status_event(status);
@@ -577,7 +582,7 @@ void usb_init(void)
{
/* We assume that the USB cable is extracted */
usb_state = USB_EXTRACTED;
-#ifdef USB_DETECT_BY_DRV
+#if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE)
last_usb_status = USB_UNPOWERED;
#else
last_usb_status = USB_EXTRACTED;