diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 4 | ||||
-rw-r--r-- | firmware/drivers/usb/arcotg_udc.c | 7 | ||||
-rw-r--r-- | firmware/target/arm/usb-fw-pp502x.c | 54 |
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; |