summaryrefslogtreecommitdiff
path: root/firmware/target/arm/usb-fw-pp502x.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/usb-fw-pp502x.c')
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c72
1 files changed, 10 insertions, 62 deletions
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c
index 92e3dee562..f687782447 100644
--- a/firmware/target/arm/usb-fw-pp502x.c
+++ b/firmware/target/arm/usb-fw-pp502x.c
@@ -22,71 +22,16 @@
22 * 22 *
23 ****************************************************************************/ 23 ****************************************************************************/
24#include "config.h" 24#include "config.h"
25#include "cpu.h"
26#include "kernel.h"
27#include "thread.h"
28#include "system.h" 25#include "system.h"
29#include "debug.h"
30#include "ata.h"
31#include "fat.h"
32#include "disk.h"
33#include "panic.h"
34#include "lcd.h"
35#include "adc.h"
36#include "usb.h" 26#include "usb.h"
37#include "button.h"
38#include "sprintf.h"
39#include "string.h"
40#include "hwcompat.h"
41
42#include "usb-target.h"
43#include "arcotg_udc.h" 27#include "arcotg_udc.h"
44 28
29#ifdef HAVE_USBSTACK
30#include "usbstack.h"
31#endif
32
45void usb_init_device(void) 33void usb_init_device(void)
46{ 34{
47 int r0;
48 outl(inl(0x70000084) | 0x200, 0x70000084);
49
50 outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
51 DEV_EN |= DEV_USB;
52
53 DEV_RS |= DEV_USB; /* reset usb start */
54 DEV_RS &=~DEV_USB;/* reset usb end */
55
56 DEV_INIT |= INIT_USB;
57 while ((inl(0x70000028) & 0x80) == 0);
58
59 UDC_PORTSC1 |= PORTSCX_PORT_RESET;
60 while ((UDC_PORTSC1 & PORTSCX_PORT_RESET) != 0);
61
62 UDC_OTGSC |= 0x5F000000;
63 if( (UDC_OTGSC & 0x100) == 0) {
64 UDC_USBMODE &=~ USB_MODE_CTRL_MODE_HOST;
65 UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE;
66 outl(inl(0x70000028) | 0x4000, 0x70000028);
67 outl(inl(0x70000028) | 0x2, 0x70000028);
68 } else {
69 UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE;
70 outl(inl(0x70000028) &~0x4000, 0x70000028);
71 outl(inl(0x70000028) | 0x2, 0x70000028);
72 }
73
74
75 UDC_USBCMD |= USB_CMD_CTRL_RESET;
76 while((UDC_USBCMD & USB_CMD_CTRL_RESET) != 0);
77
78 r0 = UDC_PORTSC1;
79
80 /* Note from IPL source (referring to next 5 lines of code:
81 THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */
82 DEV_INIT |= INIT_USB;
83 DEV_EN |= DEV_USB;
84 while ((inl(0x70000028) & 0x80) == 0);
85 outl(inl(0x70000028) | 0x2, 0x70000028);
86
87 udelay(0x186A0);
88
89 dr_controller_setup();
90 35
91#if defined(IPOD_COLOR) || defined(IPOD_4G) \ 36#if defined(IPOD_COLOR) || defined(IPOD_4G) \
92 || defined(IPOD_MINI) || defined(IPOD_MINI2G) 37 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
@@ -98,6 +43,7 @@ void usb_init_device(void)
98 43
99void usb_enable(bool on) 44void usb_enable(bool on)
100{ 45{
46#ifndef HAVE_USBSTACK
101 /* This device specific code will eventually give way to proper USB 47 /* This device specific code will eventually give way to proper USB
102 handling, which should be the same for all PP502x targets. */ 48 handling, which should be the same for all PP502x targets. */
103 if (on) 49 if (on)
@@ -125,6 +71,7 @@ void usb_enable(bool on)
125 } 71 }
126#endif 72#endif
127 } 73 }
74#endif
128} 75}
129 76
130bool usb_detect(void) 77bool usb_detect(void)
@@ -151,12 +98,13 @@ bool usb_detect(void)
151 } 98 }
152 99
153 usbstatus1 = (UDC_OTGSC & 0x800) ? true : false; 100 usbstatus1 = (UDC_OTGSC & 0x800) ? true : false;
101#ifdef HAVE_USBSTACK
154 if ((usbstatus1 == true) && (prev_usbstatus1 == false)) { 102 if ((usbstatus1 == true) && (prev_usbstatus1 == false)) {
155 dr_controller_run(); 103 usb_stack_start();
156 } else if ((usbstatus1 == false) && (prev_usbstatus1 == true)) { 104 } else if ((usbstatus1 == false) && (prev_usbstatus1 == true)) {
157 dr_controller_stop(); 105 usb_stack_stop();
158 } 106 }
159 107#endif
160 prev_usbstatus1 = usbstatus1; 108 prev_usbstatus1 = usbstatus1;
161 usbstatus2 = (UDC_PORTSC1 & PORTSCX_CURRENT_CONNECT_STATUS) ? true : false; 109 usbstatus2 = (UDC_PORTSC1 & PORTSCX_CURRENT_CONNECT_STATUS) ? true : false;
162 110