From c643b85ce4367ac7026eaf40859ac1516d9e6287 Mon Sep 17 00:00:00 2001 From: Barry Wardell Date: Tue, 19 Feb 2008 15:25:07 +0000 Subject: FS#8588: disable USB device again when USB is disconnected on PortalPlayer targets. Previously, the USB device was left on after USB disconnection causing extra battery drain. This alleviates this problem somewhat, although it seems like battery drain may still be higher after a USB disconnection, so we're still missing something. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16354 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/usb-fw-pp502x.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c index 5b71fbd..46a5b99 100644 --- a/firmware/target/arm/usb-fw-pp502x.c +++ b/firmware/target/arm/usb-fw-pp502x.c @@ -129,16 +129,6 @@ static bool usb_pin_detect(void) retval = true; #endif - /* if USB is detected, re-enable the USB-devices */ - if (retval) - { - DEV_EN |= DEV_USB0; - DEV_EN |= DEV_USB1; -#if CONFIG_CPU == PP5020 - DEV_INIT2 |= INIT_USB; -#endif - } - return retval; } @@ -185,7 +175,22 @@ int usb_detect(void) if (!usbstatus1) { /* We have just been disconnected */ status = USB_EXTRACTED; + + /* Disable USB devices */ + DEV_EN &=~ DEV_USB0; + DEV_EN &=~ DEV_USB1; +#if CONFIG_CPU == PP5020 + DEV_INIT2 &=~ INIT_USB; +#endif + return status; + } else { + /* if USB is detected, re-enable the USB-devices, otherwise make sure it's disabled */ + DEV_EN |= DEV_USB0; + DEV_EN |= DEV_USB1; +#if CONFIG_CPU == PP5020 + DEV_INIT2 |= INIT_USB; +#endif } /* Run the USB stack to request full bus power */ -- cgit v1.1