diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-09-05 15:52:49 +0000 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-09-05 15:52:49 +0000 |
commit | 1a8f7c51b3abd5d60d3306ab65f63bd5084d4d24 (patch) | |
tree | c3ed2f90251a6aa02d3e38cf8eb7d8e1ba2039b5 /firmware/target/arm/usb-fw-pp502x.c | |
parent | bc35acffd92a5f3a25047a09360c5d6519031911 (diff) | |
download | rockbox-1a8f7c51b3abd5d60d3306ab65f63bd5084d4d24.tar.gz rockbox-1a8f7c51b3abd5d60d3306ab65f63bd5084d4d24.zip |
fix usb detection for usb stack
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14621 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/usb-fw-pp502x.c')
-rw-r--r-- | firmware/target/arm/usb-fw-pp502x.c | 90 |
1 files changed, 41 insertions, 49 deletions
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c index 0d162b4e6d..240548bf61 100644 --- a/firmware/target/arm/usb-fw-pp502x.c +++ b/firmware/target/arm/usb-fw-pp502x.c | |||
@@ -35,49 +35,49 @@ | |||
35 | 35 | ||
36 | void usb_init_device(void) | 36 | void usb_init_device(void) |
37 | { | 37 | { |
38 | int r0; | 38 | int r0; |
39 | outl(inl(0x70000084) | 0x200, 0x70000084); | 39 | outl(inl(0x70000084) | 0x200, 0x70000084); |
40 | 40 | ||
41 | outl(inl(0x7000002C) | 0x3000000, 0x7000002C); | 41 | outl(inl(0x7000002C) | 0x3000000, 0x7000002C); |
42 | DEV_EN |= DEV_USB; | 42 | DEV_EN |= DEV_USB; |
43 | 43 | ||
44 | DEV_RS |= DEV_USB; /* reset usb start */ | 44 | DEV_RS |= DEV_USB; /* reset usb start */ |
45 | DEV_RS &=~DEV_USB;/* reset usb end */ | 45 | DEV_RS &=~DEV_USB;/* reset usb end */ |
46 | 46 | ||
47 | DEV_INIT |= INIT_USB; | 47 | DEV_INIT |= INIT_USB; |
48 | while ((inl(0x70000028) & 0x80) == 0); | 48 | while ((inl(0x70000028) & 0x80) == 0); |
49 | 49 | ||
50 | UDC_PORTSC1 |= PORTSCX_PORT_RESET; | 50 | UDC_PORTSC1 |= PORTSCX_PORT_RESET; |
51 | while ((UDC_PORTSC1 & PORTSCX_PORT_RESET) != 0); | 51 | while ((UDC_PORTSC1 & PORTSCX_PORT_RESET) != 0); |
52 | 52 | ||
53 | UDC_OTGSC |= 0x5F000000; | 53 | UDC_OTGSC |= 0x5F000000; |
54 | if( (UDC_OTGSC & 0x100) == 0) { | 54 | if( (UDC_OTGSC & 0x100) == 0) { |
55 | UDC_USBMODE &=~ USB_MODE_CTRL_MODE_HOST; | 55 | UDC_USBMODE &=~ USB_MODE_CTRL_MODE_HOST; |
56 | UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; | 56 | UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; |
57 | outl(inl(0x70000028) | 0x4000, 0x70000028); | 57 | outl(inl(0x70000028) | 0x4000, 0x70000028); |
58 | outl(inl(0x70000028) | 0x2, 0x70000028); | 58 | outl(inl(0x70000028) | 0x2, 0x70000028); |
59 | } else { | 59 | } else { |
60 | UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; | 60 | UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; |
61 | outl(inl(0x70000028) &~0x4000, 0x70000028); | 61 | outl(inl(0x70000028) &~0x4000, 0x70000028); |
62 | outl(inl(0x70000028) | 0x2, 0x70000028); | 62 | outl(inl(0x70000028) | 0x2, 0x70000028); |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | UDC_USBCMD |= USB_CMD_CTRL_RESET; | 66 | UDC_USBCMD |= USB_CMD_CTRL_RESET; |
67 | while((UDC_USBCMD & USB_CMD_CTRL_RESET) != 0); | 67 | while((UDC_USBCMD & USB_CMD_CTRL_RESET) != 0); |
68 | 68 | ||
69 | r0 = UDC_PORTSC1; | 69 | r0 = UDC_PORTSC1; |
70 | 70 | ||
71 | /* Note from IPL source (referring to next 5 lines of code: | 71 | /* Note from IPL source (referring to next 5 lines of code: |
72 | THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */ | 72 | THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */ |
73 | DEV_INIT |= INIT_USB; | 73 | DEV_INIT |= INIT_USB; |
74 | DEV_EN |= DEV_USB; | 74 | DEV_EN |= DEV_USB; |
75 | while ((inl(0x70000028) & 0x80) == 0); | 75 | while ((inl(0x70000028) & 0x80) == 0); |
76 | outl(inl(0x70000028) | 0x2, 0x70000028); | 76 | outl(inl(0x70000028) | 0x2, 0x70000028); |
77 | 77 | ||
78 | udelay(0x186A0); | 78 | udelay(0x186A0); |
79 | 79 | ||
80 | #ifndef HAVE_USBSTACK | 80 | #ifndef HAVE_USBSTACK |
81 | dr_controller_setup(); | 81 | dr_controller_setup(); |
82 | #endif | 82 | #endif |
83 | 83 | ||
@@ -93,7 +93,7 @@ void usb_enable(bool on) | |||
93 | { | 93 | { |
94 | #ifdef HAVE_USBSTACK | 94 | #ifdef HAVE_USBSTACK |
95 | (void)on; | 95 | (void)on; |
96 | #else | 96 | #else |
97 | /* This device specific code will eventually give way to proper USB | 97 | /* This device specific code will eventually give way to proper USB |
98 | handling, which should be the same for all PP502x targets. */ | 98 | handling, which should be the same for all PP502x targets. */ |
99 | if (on) | 99 | if (on) |
@@ -149,14 +149,8 @@ int usb_detect(void) | |||
149 | status = usbstatus2 ? USB_INSERTED : USB_POWERED; | 149 | status = usbstatus2 ? USB_INSERTED : USB_POWERED; |
150 | #ifndef HAVE_USBSTACK | 150 | #ifndef HAVE_USBSTACK |
151 | dr_controller_stop(); | 151 | dr_controller_stop(); |
152 | #endif | 152 | #else |
153 | 153 | usb_stack_stop(); | |
154 | #ifdef HAVE_USBSTACK | ||
155 | /* TODO: Move this call - it shouldn't be done in this function */ | ||
156 | if (status == USB_INSERTED) | ||
157 | { | ||
158 | usb_stack_start(); | ||
159 | } | ||
160 | #endif | 154 | #endif |
161 | } | 155 | } |
162 | return status; | 156 | return status; |
@@ -186,10 +180,6 @@ int usb_detect(void) | |||
186 | if (!usbstatus1) | 180 | if (!usbstatus1) |
187 | { /* We have just been disconnected */ | 181 | { /* We have just been disconnected */ |
188 | status = USB_EXTRACTED; | 182 | status = USB_EXTRACTED; |
189 | #ifdef HAVE_USBSTACK | ||
190 | /* TODO: Move this call - it shouldn't be done in this function */ | ||
191 | usb_stack_stop(); | ||
192 | #endif | ||
193 | return status; | 183 | return status; |
194 | } | 184 | } |
195 | 185 | ||
@@ -208,8 +198,10 @@ int usb_detect(void) | |||
208 | /* Run the USB controller for long enough to detect if we're connected | 198 | /* Run the USB controller for long enough to detect if we're connected |
209 | to a computer, then stop it again. */ | 199 | to a computer, then stop it again. */ |
210 | 200 | ||
211 | #ifndef HAVE_USBSTACK | 201 | #ifndef HAVE_USBSTACK |
212 | dr_controller_run(); | 202 | dr_controller_run(); |
203 | #else | ||
204 | usb_stack_start(); | ||
213 | #endif | 205 | #endif |
214 | 206 | ||
215 | /* Wait for 50 ticks (500ms) before deciding there is no computer | 207 | /* Wait for 50 ticks (500ms) before deciding there is no computer |