summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-08-27 18:21:05 +0000
committerDave Chapman <dave@dchapman.com>2007-08-27 18:21:05 +0000
commit9551ae92a5d1e44825e435a0b2cfce1b5d7bfa34 (patch)
tree9795d2276bb813af4fdb1689b7a5eaf6fe93a1b6 /firmware
parent3075e3bafd63480c5ca1476c1150e5da7c77a756 (diff)
downloadrockbox-9551ae92a5d1e44825e435a0b2cfce1b5d7bfa34.tar.gz
rockbox-9551ae92a5d1e44825e435a0b2cfce1b5d7bfa34.zip
Repair the USB detection on ipods and H10s which was broken by commit 14470. The intention is that when the experimental HAVE_USBSTACK is not defined, the old (pre-14470) code is run.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14481 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES4
-rw-r--r--firmware/drivers/usb/arcotg_udc.c7
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c54
3 files changed, 61 insertions, 4 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index c704bee0e7..b8ef111e09 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -243,7 +243,11 @@ drivers/isp1362.c
#if CONFIG_USBOTG == USBOTG_M5636
drivers/m5636.c
#elif CONFIG_USBOTG == USBOTG_ARC
+#ifdef HAVE_USBSTACK
drivers/usb/arcotg_dcd.c
+#else
+drivers/usb/arcotg_udc.c
+#endif
#endif /* CONFIG_USBOTG */
#endif /* !defined(BOOTLOADER) */
#endif /* !defined(SIMULATOR) */
diff --git a/firmware/drivers/usb/arcotg_udc.c b/firmware/drivers/usb/arcotg_udc.c
index d39dbc39df..c4ae6f8d64 100644
--- a/firmware/drivers/usb/arcotg_udc.c
+++ b/firmware/drivers/usb/arcotg_udc.c
@@ -33,6 +33,7 @@
****************************************************************************/
#include "arcotg_udc.h"
#include "logf.h"
+#include "errno.h"
static int timeout;
@@ -52,7 +53,7 @@ int dr_controller_setup(void)
#endif
/* Stop and reset the usb controller */
- UDC_USBCMD &= ~USB_CMD_RUN_STOP;
+ UDC_USBCMD &= ~USB_CMD_RUN;
UDC_USBCMD |= USB_CMD_CTRL_RESET;
@@ -102,7 +103,7 @@ void dr_controller_run(void)
UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE;
/* Set controller to Run */
- UDC_USBCMD |= USB_CMD_RUN_STOP;
+ UDC_USBCMD |= USB_CMD_RUN;
return;
}
@@ -131,5 +132,5 @@ void dr_controller_stop(void)
udc->stopped = 1;
#endif
/* Set controller to Stop */
- UDC_USBCMD &= ~USB_CMD_RUN_STOP;
+ UDC_USBCMD &= ~USB_CMD_RUN;
}
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c
index b4c262757d..d4ab1d954e 100644
--- a/firmware/target/arm/usb-fw-pp502x.c
+++ b/firmware/target/arm/usb-fw-pp502x.c
@@ -27,14 +27,60 @@
#include "button.h"
#include "ata.h"
#include "string.h"
-#include "arcotg_udc.h"
#ifdef HAVE_USBSTACK
#include "usbstack.h"
+#else
+#include "arcotg_udc.h"
#endif
void usb_init_device(void)
{
+ int r0;
+ outl(inl(0x70000084) | 0x200, 0x70000084);
+
+ outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
+ DEV_EN |= DEV_USB;
+
+ DEV_RS |= DEV_USB; /* reset usb start */
+ DEV_RS &=~DEV_USB;/* reset usb end */
+
+ DEV_INIT |= INIT_USB;
+ while ((inl(0x70000028) & 0x80) == 0);
+
+ UDC_PORTSC1 |= PORTSCX_PORT_RESET;
+ while ((UDC_PORTSC1 & PORTSCX_PORT_RESET) != 0);
+
+ UDC_OTGSC |= 0x5F000000;
+ if( (UDC_OTGSC & 0x100) == 0) {
+ UDC_USBMODE &=~ USB_MODE_CTRL_MODE_HOST;
+ UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE;
+ outl(inl(0x70000028) | 0x4000, 0x70000028);
+ outl(inl(0x70000028) | 0x2, 0x70000028);
+ } else {
+ UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE;
+ outl(inl(0x70000028) &~0x4000, 0x70000028);
+ outl(inl(0x70000028) | 0x2, 0x70000028);
+ }
+
+
+ UDC_USBCMD |= USB_CMD_CTRL_RESET;
+ while((UDC_USBCMD & USB_CMD_CTRL_RESET) != 0);
+
+ r0 = UDC_PORTSC1;
+
+ /* Note from IPL source (referring to next 5 lines of code:
+ THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */
+ DEV_INIT |= INIT_USB;
+ DEV_EN |= DEV_USB;
+ while ((inl(0x70000028) & 0x80) == 0);
+ outl(inl(0x70000028) | 0x2, 0x70000028);
+
+ udelay(0x186A0);
+
+#ifndef HAVE_USBSTACK
+ dr_controller_setup();
+#endif
#if defined(IPOD_COLOR) || defined(IPOD_4G) \
|| defined(IPOD_MINI) || defined(IPOD_MINI2G)
@@ -107,6 +153,12 @@ bool usb_detect(void)
} else if ((usbstatus1 == false) && (prev_usbstatus1 == true)) {
usb_stack_stop();
}
+#else
+ if ((usbstatus1 == true) && (prev_usbstatus1 == false)) {
+ dr_controller_run();
+ } else if ((usbstatus1 == false) && (prev_usbstatus1 == true)) {
+ dr_controller_stop();
+ }
#endif
prev_usbstatus1 = usbstatus1;
usbstatus2 = (UDC_PORTSC1 & PORTSCX_CURRENT_CONNECT_STATUS) ? true : false;