summaryrefslogtreecommitdiff
path: root/firmware/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usb.c')
-rw-r--r--firmware/usb.c74
1 files changed, 70 insertions, 4 deletions
diff --git a/firmware/usb.c b/firmware/usb.c
index c453cb7a2b..23e2e33737 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -9,6 +9,11 @@
9 * 9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing 10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 * 11 *
12 * iPod driver based on code from the ipodlinux project - http://ipodlinux.org
13 * Adapted for Rockbox in January 2006
14 * Original file: podzilla/usb.c
15 * Copyright (C) 2005 Adam Johnston
16 *
12 * All files in this archive are subject to the GNU General Public License. 17 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 18 * See the file COPYING in the source tree root for full license agreement.
14 * 19 *
@@ -31,6 +36,7 @@
31#include "usb.h" 36#include "usb.h"
32#include "button.h" 37#include "button.h"
33#include "sprintf.h" 38#include "sprintf.h"
39#include "string.h"
34#include "hwcompat.h" 40#include "hwcompat.h"
35#ifdef HAVE_MMC 41#ifdef HAVE_MMC
36#include "ata_mmc.h" 42#include "ata_mmc.h"
@@ -62,6 +68,9 @@ void screen_dump(void); /* Nasty again. Defined in apps/ too */
62#elif CONFIG_KEYPAD == ONDIO_PAD 68#elif CONFIG_KEYPAD == ONDIO_PAD
63#define USBPOWER_BUTTON BUTTON_MENU 69#define USBPOWER_BUTTON BUTTON_MENU
64#define USBPOWER_BTN_IGNORE BUTTON_OFF 70#define USBPOWER_BTN_IGNORE BUTTON_OFF
71#elif CONFIG_KEYPAD == IPOD_4G_PAD
72#define USBPOWER_BUTTON BUTTON_MENU
73#define USBPOWER_BTN_IGNORE BUTTON_PLAY
65#endif 74#endif
66#endif /* HAVE_USB_POWER */ 75#endif /* HAVE_USB_POWER */
67 76
@@ -155,8 +164,22 @@ void usb_enable(bool on)
155 } 164 }
156 165
157#elif defined(USB_IPODSTYLE) 166#elif defined(USB_IPODSTYLE)
158 /* TODO: Implement USB_IPODSTYLE */ 167 /* For the ipod, we can only do one thing with USB mode - reboot
159 (void) on; 168 into Apple's flash-based disk-mode. This does not return. */
169 if (on)
170 {
171 /* The following code is copied from ipodlinux - it doesn't work on the
172 iPod Video */
173 unsigned char* storage_ptr = (unsigned char *)0x40017F00;
174 char* diskmode = "diskmode\0";
175 char* hotstuff = "hotstuff\0";
176
177 memcpy(storage_ptr, diskmode, 9);
178 storage_ptr = (unsigned char *)0x40017f08;
179 memcpy(storage_ptr, hotstuff, 9);
180 outl(1, 0x40017F10);
181 outl(inl(0x60006004) | 0x4, 0x60006004);
182 }
160#else 183#else
161#ifdef HAVE_LCD_BITMAP 184#ifdef HAVE_LCD_BITMAP
162 if(read_hw_mask() & USB_ACTIVE_HIGH) 185 if(read_hw_mask() & USB_ACTIVE_HIGH)
@@ -375,8 +398,12 @@ bool usb_detect(void)
375 current_status = (GPIO1_READ & 0x80)?true:false; 398 current_status = (GPIO1_READ & 0x80)?true:false;
376#endif 399#endif
377#ifdef USB_IPODSTYLE 400#ifdef USB_IPODSTYLE
378 /* TODO: Implement USB_IPODSTYLE */ 401 /* The following check is in the ipodlinux source, with the
379 current_status = false; 402 comment "USB2D_IDENT is bad" if USB2D_IDENT != 0x22FA05 */
403 if (USB2D_IDENT != 0x22FA05) {
404 return false;
405 }
406 current_status = (USB_STATUS & 0x800)?true:false;
380#endif 407#endif
381 return current_status; 408 return current_status;
382} 409}
@@ -465,6 +492,45 @@ void usb_init(void)
465 or_l(0x01000040, &GPIO_FUNCTION); 492 or_l(0x01000040, &GPIO_FUNCTION);
466#endif 493#endif
467 494
495#elif defined(USB_IPODSTYLE)
496 int r0;
497 outl(inl(0x70000084) | 0x200, 0x70000084);
498
499 outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
500 outl(inl(0x6000600C) | 0x400000, 0x6000600C);
501
502 outl(inl(0x60006004) | 0x400000, 0x60006004); /* reset usb start */
503 outl(inl(0x60006004) & ~0x400000, 0x60006004); /* reset usb end */
504
505 outl(inl(0x70000020) | 0x80000000, 0x70000020);
506 while ((inl(0x70000028) & 0x80) == 0);
507
508 outl(inl(0xc5000184) | 0x100, 0xc5000184);
509 while ((inl(0xc5000184) & 0x100) != 0);
510
511 outl(inl(0xc50001A4) | 0x5F000000, 0xc50001A4);
512 if ((inl(0xc50001A4) & 0x100) == 0) {
513 outl(inl(0xc50001A8) & ~0x3, 0xc50001A8);
514 outl(inl(0xc50001A8) | 0x2, 0xc50001A8);
515 outl(inl(0x70000028) | 0x4000, 0x70000028);
516 outl(inl(0x70000028) | 0x2, 0x70000028);
517 } else {
518 outl(inl(0xc50001A8) | 0x3, 0xc50001A8);
519 outl(inl(0x70000028) &~0x4000, 0x70000028);
520 outl(inl(0x70000028) | 0x2, 0x70000028);
521 }
522 outl(inl(0xc5000140) | 0x2, 0xc5000140);
523 while((inl(0xc5000140) & 0x2) != 0);
524 r0 = inl(0xc5000184);
525
526 /* Note from IPL source (referring to next 5 lines of code:
527 THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */
528 outl(inl(0x70000020) | 0x80000000, 0x70000020);
529 outl(inl(0x6000600C) | 0x400000, 0x6000600C);
530 while ((inl(0x70000028) & 0x80) == 0);
531 outl(inl(0x70000028) | 0x2, 0x70000028);
532
533 udelay(0x186A0);
468#endif 534#endif
469 535
470 usb_enable(false); 536 usb_enable(false);