summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-12-14 09:19:50 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-12-14 09:19:50 +0000
commitbfd69f2aa19321e7fb3dfdd0befcfc7e32eca656 (patch)
treede136173c7b46650b09b0a07c6a94cb5dd4d1679
parent7af94b442741c4bb11a3b42c7c346465bdb30479 (diff)
downloadrockbox-bfd69f2aa19321e7fb3dfdd0befcfc7e32eca656.tar.gz
rockbox-bfd69f2aa19321e7fb3dfdd0befcfc7e32eca656.zip
Fix the real issue with AMS bootloader USB mode. A call to usb_enable was missing in usb.c when using the USB stack and USB_DETECT_BY_CORE was not enabled. Try to do it in a clean-ish way.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31245 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/sansa_as3525.c2
-rw-r--r--firmware/usb.c21
2 files changed, 15 insertions, 8 deletions
diff --git a/bootloader/sansa_as3525.c b/bootloader/sansa_as3525.c
index 7b0a8b8d88..c384007898 100644
--- a/bootloader/sansa_as3525.c
+++ b/bootloader/sansa_as3525.c
@@ -63,10 +63,8 @@ static void usb_mode(void)
63 (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); 63 (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
64 lcd_update(); 64 lcd_update();
65 65
66 usb_enable(true);
67 while(usb_detect() == USB_INSERTED) 66 while(usb_detect() == USB_INSERTED)
68 sleep(HZ); 67 sleep(HZ);
69 usb_enable(false);
70 68
71 reset_screen(); 69 reset_screen();
72 lcd_update(); 70 lcd_update();
diff --git a/firmware/usb.c b/firmware/usb.c
index bb19850cae..c7326c548b 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -135,6 +135,11 @@ static inline bool usb_do_screendump(void)
135 135
136 136
137#ifdef HAVE_USBSTACK 137#ifdef HAVE_USBSTACK
138/* Enable / disable USB when the stack is enabled - otherwise a noop */
139static inline void usb_stack_enable(bool enable)
140{
141 usb_enable(enable);
142}
138 143
139#ifdef HAVE_HOTSWAP 144#ifdef HAVE_HOTSWAP
140static inline void usb_handle_hotswap(long id) 145static inline void usb_handle_hotswap(long id)
@@ -222,7 +227,6 @@ static inline void usb_slave_mode(bool on)
222 } 227 }
223 else /* usb_state == USB_INSERTED (only!) */ 228 else /* usb_state == USB_INSERTED (only!) */
224 { 229 {
225 usb_enable(false);
226#ifdef HAVE_PRIORITY_SCHEDULING 230#ifdef HAVE_PRIORITY_SCHEDULING
227 thread_set_priority(thread_self(), PRIORITY_SYSTEM); 231 thread_set_priority(thread_self(), PRIORITY_SYSTEM);
228#endif 232#endif
@@ -254,6 +258,11 @@ void usb_signal_transfer_completion(
254 258
255#else /* !HAVE_USBSTACK */ 259#else /* !HAVE_USBSTACK */
256 260
261static inline void usb_stack_enable(bool enable)
262{
263 (void)enable;
264}
265
257#ifdef HAVE_HOTSWAP 266#ifdef HAVE_HOTSWAP
258static inline void usb_handle_hotswap(long id) 267static inline void usb_handle_hotswap(long id)
259{ 268{
@@ -403,6 +412,7 @@ static void usb_thread(void)
403 break; 412 break;
404 413
405 usb_state = USB_POWERED; 414 usb_state = USB_POWERED;
415 usb_stack_enable(true);
406#endif /* USB_DETECT_BY_CORE */ 416#endif /* USB_DETECT_BY_CORE */
407 417
408 if(usb_power_button()) 418 if(usb_power_button())
@@ -467,20 +477,19 @@ static void usb_thread(void)
467 break; 477 break;
468 478
469 usb_state = USB_POWERED; 479 usb_state = USB_POWERED;
470 usb_enable(true); 480 usb_stack_enable(true);
471 break; 481 break;
472 /* USB_POWERED: */ 482 /* USB_POWERED: */
473 483
474 case USB_UNPOWERED: 484 case USB_UNPOWERED:
475 if(usb_state == USB_POWERED)
476 usb_enable(false);
477 /* Fall-through - other legal states can be USB_INSERTED or
478 USB_SCREENDUMP */
479#endif /* USB_DETECT_BY_CORE */ 485#endif /* USB_DETECT_BY_CORE */
480 case USB_EXTRACTED: 486 case USB_EXTRACTED:
481 if(usb_state == USB_EXTRACTED) 487 if(usb_state == USB_EXTRACTED)
482 break; 488 break;
483 489
490 if(usb_state == USB_POWERED || usb_state == USB_INSERTED)
491 usb_stack_enable(false);
492
484 /* Only disable the USB slave mode if we really have enabled 493 /* Only disable the USB slave mode if we really have enabled
485 it. Some expected acks may not have been received. */ 494 it. Some expected acks may not have been received. */
486 if(usb_state == USB_INSERTED) 495 if(usb_state == USB_INSERTED)