From da76a3469437261bd8857c6eddeaafcc601f373e Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 22 Jan 2009 22:05:04 +0000 Subject: Use bus reset detection for all ARC OTG devices. Remove conflict from LV24020LP driver with some GPIO-by-number macros for PP502x. Start monitoring for USB stack once all core threads and queues are created otherwise queues will likely be registered after USB acks. Putting PP502x system_reboot in IRAM (unmapped, uncached) memory seems to help it work more consistently. Hopefully I got all the PP USB connect handlers in the right spot in irq_handler. If device seems unresponsive to cable, check there first. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19819 a1c6a512-1295-4272-9138-f99709370657 --- firmware/usb.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'firmware/usb.c') diff --git a/firmware/usb.c b/firmware/usb.c index 10a7ae1bff..a1e552a321 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -416,9 +416,11 @@ static void usb_thread(void) #ifdef USB_STATUS_BY_EVENT void usb_status_event(int current_status) { - /* Status should be USB_POWERED, USB_UNPOWERED, USB_INSERTED or - * USB_EXTRACTED. - * Caller isn't expected to filter for changes in status. */ + /* Caller isn't expected to filter for changes in status. + * current_status: + * USB_DETECT_BY_DRV: USB_POWERED, USB_UNPOWERED, USB_INSERTED (driver) + * else: USB_INSERTED, USB_EXTRACTED + */ if(usb_monitor_enabled) { int oldstatus = disable_irq_save(); /* Dual-use function */ @@ -435,16 +437,30 @@ void usb_status_event(int current_status) void usb_start_monitoring(void) { + int oldstatus = disable_irq_save(); /* Sync to event */ int status = usb_detect(); + + usb_monitor_enabled = true; + #ifdef USB_DETECT_BY_DRV - /* USB detection begins by USB_POWERED, not USB_INSERTED. If it is - * USB_EXTRACTED, then nothing changes and post will be skipped. */ - if(USB_INSERTED == status) - status = USB_POWERED; + status = (status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED; #endif - usb_monitor_enabled = true; usb_status_event(status); + +#ifdef USB_FIREWIRE_HANDLING + if (firewire_detect()) + usb_firewire_connect_event(); +#endif + + restore_irq(oldstatus); } + +#ifdef USB_FIREWIRE_HANDLING +void usb_firewire_connect_event(void) +{ + queue_post(&usb_queue, USB_REQUEST_REBOOT, 0); +} +#endif /* USB_FIREWIRE_HANDLING */ #else /* !USB_STATUS_BY_EVENT */ static void usb_tick(void) { @@ -522,7 +538,11 @@ void usb_init(void) { /* We assume that the USB cable is extracted */ usb_state = USB_EXTRACTED; +#ifdef USB_DETECT_BY_DRV + last_usb_status = USB_UNPOWERED; +#else last_usb_status = USB_EXTRACTED; +#endif usb_monitor_enabled = false; #ifdef HAVE_USBSTACK -- cgit v1.2.3