From 05f6f3419aec991307e7c81e0738e0496a21d89b Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 17 Jan 2011 12:24:41 +0000 Subject: 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 --- firmware/target/arm/system-pp502x.c | 4 +--- firmware/target/arm/usb-drv-arc.c | 8 ++++++++ firmware/target/arm/usb-fw-pp502x.c | 14 ++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index bd71d28417..0422ea7d9c 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c @@ -141,9 +141,7 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOD_INT_STAT & 0x02) button_int(); - } - else if (CPU_HI_INT_STAT & GPIO1_MASK) { - if (GPIOF_INT_STAT & 0x80) + if (GPIOB_INT_STAT & 0x40) usb_insert_int(); } /* end PHILIPS_SA9200 */ diff --git a/firmware/target/arm/usb-drv-arc.c b/firmware/target/arm/usb-drv-arc.c index 86a1637bc8..fc74ce5bf0 100644 --- a/firmware/target/arm/usb-drv-arc.c +++ b/firmware/target/arm/usb-drv-arc.c @@ -498,15 +498,23 @@ static void log_ep(int ep_num, int ep_dir, char* prefix) void usb_drv_init(void) { +#ifdef USB_DETECT_BY_CORE + /* USB core decides */ + _usb_drv_init(true); +#else + /* Use bus reset condition */ _usb_drv_init(false); +#endif } /* fully enable driver */ void usb_drv_attach(void) { logf("usb_drv_attach"); +#ifndef USB_DETECT_BY_CORE sleep(HZ/10); _usb_drv_init(true); +#endif } void usb_drv_exit(void) diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c index 8f754fd04b..536535e059 100644 --- a/firmware/target/arm/usb-fw-pp502x.c +++ b/firmware/target/arm/usb-fw-pp502x.c @@ -65,10 +65,10 @@ #define USB_GPIO_VAL 0x04 #elif defined(PHILIPS_SA9200) - /* GPIO F bit 7 (low) is usb detect */ -#define USB_GPIO GPIOF -#define USB_GPIO_MASK 0x80 -#define USB_GPIO_VAL 0x00 + /* GPIO B bit 6 (high) is usb bus power detect */ +#define USB_GPIO GPIOB +#define USB_GPIO_MASK 0x40 +#define USB_GPIO_VAL 0x40 #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) /* GPIO E bit 2 is usb detect */ @@ -225,10 +225,12 @@ void usb_insert_int(void) timeout_register(&usb_oneshot, usb_timeout_event, HZ/5, val); } -/* Called during the bus reset interrupt when in detect mode - filter for - * invalid bus reset when unplugging by checking the pin state. */ +/* USB_DETECT_BY_DRV: Called during the bus reset interrupt when in detect mode + * USB_DETECT_BY_CORE: Called when device descriptor is requested + */ void usb_drv_usb_detect_event(void) { + /* Filter for invalid bus reset when unplugging by checking the pin state. */ if(usb_plugged()) { usb_status_event(USB_INSERTED); } -- cgit v1.2.3