summaryrefslogtreecommitdiff
path: root/firmware/usb.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-12-07 13:37:26 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-12-07 13:37:26 +0100
commit775ab07d5e710c4811a66b246f8f8708a09eba28 (patch)
treedf725ba1aea0bccbfb64e29d49fa04bfc671ec11 /firmware/usb.c
parentfb43a137e72d1f428efef00047a416497463edfb (diff)
downloadrockbox-775ab07d5e710c4811a66b246f8f8708a09eba28.tar.gz
rockbox-775ab07d5e710c4811a66b246f8f8708a09eba28.zip
usb: add support for hardware handled SET ADDR/CONFIG
Some USB controllers like the one of the Rockchip 27xx handle some requests in pure hardware. This is especially a problem for two of them: - SET ADDR which is used by our core to track the DEFAULT/ADDRESS state and is required for the drivers to work properly - SET CONFIG which is used by our core to initialise the drivers by calling init_connection() In these cases we need a way to notify the core that such requests happened. We do this by exporting two functions which directly notify the core about these requests and perform the necessary init steps required without doing the actual USB transfers. Special care is needed because these functions could be called from an interrupt handler. For this reason we still use the usb_queue and introduce new IDs so that they are processed in order and safely. No functional change is intended, both in the usbstack and on targets without such quirks. Change-Id: Ie42feffd4584e88bf37cff018b627f333dca1140
Diffstat (limited to 'firmware/usb.c')
-rw-r--r--firmware/usb.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/firmware/usb.c b/firmware/usb.c
index 6823851e08..b8c9822ff6 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -270,6 +270,11 @@ void usb_signal_transfer_completion(
270 queue_post(&usb_queue, USB_TRANSFER_COMPLETION, (intptr_t)event_data); 270 queue_post(&usb_queue, USB_TRANSFER_COMPLETION, (intptr_t)event_data);
271} 271}
272 272
273void usb_signal_notify(long id, intptr_t data)
274{
275 queue_post(&usb_queue, id, data);
276}
277
273#else /* !HAVE_USBSTACK */ 278#else /* !HAVE_USBSTACK */
274 279
275static inline void usb_stack_enable(bool enable) 280static inline void usb_stack_enable(bool enable)
@@ -431,6 +436,12 @@ static void NORETURN_ATTR usb_thread(void)
431 /*** Main USB thread duties ***/ 436 /*** Main USB thread duties ***/
432 437
433#ifdef HAVE_USBSTACK 438#ifdef HAVE_USBSTACK
439 case USB_NOTIFY_SET_ADDR:
440 case USB_NOTIFY_SET_CONFIG:
441 if(usb_state <= USB_EXTRACTED)
442 break;
443 usb_core_handle_notify(ev.id, ev.data);
444 break;
434 case USB_TRANSFER_COMPLETION: 445 case USB_TRANSFER_COMPLETION:
435 if(usb_state <= USB_EXTRACTED) 446 if(usb_state <= USB_EXTRACTED)
436 break; 447 break;