Move AMSv1 (AMSv2 had been done already) to using setup packet request to detect a host.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30547 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2011-09-14 15:26:57 +00:00
parent 207131c53b
commit 82259b7af5
3 changed files with 14 additions and 51 deletions

View file

@ -767,7 +767,7 @@ Lyre prototype 1 */
#define INCLUDE_TIMEOUT_API
#elif CONFIG_USBOTG == USBOTG_AS3525
#define USB_STATUS_BY_EVENT
#define USB_DETECT_BY_DRV
#define USB_DETECT_BY_CORE
#elif CONFIG_USBOTG == USBOTG_AS3525v2
#define USB_STATUS_BY_EVENT
#define USB_DETECT_BY_CORE

View file

@ -30,39 +30,6 @@
static int usb_status = USB_EXTRACTED;
#if CONFIG_CPU == AS3525v2 && !defined(USE_ROCKBOX_USB)
/* Rebooting on USB plug can crash these players in a state where
* hardware power off (pressing the power button) doesn't work anymore
* TODO: Implement USB in rockbox for these players */
#define USB_INSERT_INT_STATUS USB_EXTRACTED
#undef USB_DETECT_BY_DRV
#undef USB_DETECT_BY_CORE
#undef USB_STATUS_BY_EVENT
#else /* !AS3525v2 */
#if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE)
#ifdef USB_STATUS_BY_EVENT
#define USB_INSERT_INT_STATUS USB_INSERTED
#define USB_INSERT_INT_EVENT USB_POWERED
#define USB_REMOVE_INT_EVENT USB_UNPOWERED
#else
#define USB_INSERT_INT_STATUS USB_POWERED
#endif /* USB_STATUS_BY_EVENT */
#else /* !USB_DETECT_BY_* */
#define USB_INSERT_INT_STATUS USB_INSERTED
#ifdef USB_STATUS_BY_EVENT
#define USB_INSERT_INT_EVENT USB_INSERTED
#define USB_REMOVE_INT_EVENT USB_EXTRACTED
#endif /* USB_STATUS_BY_EVENT */
#endif /* USB_DETECT_BY_* */
#endif /* AS3525v2 */
void usb_enable(bool on)
{
#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
@ -77,33 +44,29 @@ void usb_enable(bool on)
void usb_insert_int(void)
{
usb_status = USB_INSERT_INT_STATUS;
#ifdef USB_STATUS_BY_EVENT
usb_status_event(USB_INSERT_INT_EVENT);
#endif
usb_status = USB_INSERTED;
usb_status_event(USB_POWERED);
}
void usb_remove_int(void)
{
usb_status = USB_EXTRACTED;
#ifdef USB_STATUS_BY_EVENT
usb_status_event(USB_REMOVE_INT_EVENT);
#endif
usb_status_event(USB_UNPOWERED);
}
void usb_drv_usb_detect_event(void)
{
#if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE)
#if CONFIG_CPU != AS3525v2 || defined(USE_ROCKBOX_USB)
/* Rebooting on USB plug can crash these players in a state where
* hardware power off (pressing the power button) doesn't work anymore
* TODO: Implement USB in rockbox for these players */
int oldstatus = disable_irq_save(); /* May come via USB thread */
if (usb_status == USB_INSERT_INT_STATUS)
{
usb_status = USB_INSERTED;
#ifdef USB_STATUS_BY_EVENT
if (usb_status == USB_INSERTED)
usb_status_event(USB_INSERTED);
#endif
}
restore_irq(oldstatus);
#endif /* USB_DETECT_BY_* */
#endif
}
int usb_detect(void)

View file

@ -76,7 +76,8 @@ static inline void usb_disable_pll(void)
void usb_attach(void)
{
usb_enable(true);
logf("usb-drv: attach");
/* Nothing to do */
}
static void usb_tick(void);
@ -768,7 +769,6 @@ void INT_USB(void)
}
if (intr & USB_DEV_INTR_USB_RESET) {/* usb reset from host? */
logf("usb reset\n");
usb_drv_usb_detect_event();
reset_endpoints(1);
usb_core_bus_reset();
intr &= ~USB_DEV_INTR_USB_RESET;