1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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
17 * All files in this archive are subject to the GNU General Public License.
18 * See the file COPYING in the source tree root for full license agreement.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
34 void usb_init_device(void)
36 /* enable usb module */
37 GPO32_ENABLE
|= 0x200;
39 outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
42 DEV_RS
|= DEV_USB
; /* reset usb start */
43 DEV_RS
&=~DEV_USB
;/* reset usb end */
45 DEV_INIT2
|= INIT_USB
;
46 while ((inl(0x70000028) & 0x80) == 0);
47 outl(inl(0x70000028) | 0x2, 0x70000028);
50 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
51 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
52 /* GPIO C bit 1 is firewire detect */
54 GPIOC_OUTPUT_EN
&= ~0x02;
58 void usb_enable(bool on
)
66 /* This device specific code will eventually give way to proper USB
67 handling, which should be the same for all PP502x targets. */
70 #if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined (IRIVER_H10_5GB) ||\
72 /* For the H10 and iPod, we can only do one thing with USB mode - reboot
73 into the flash-based disk-mode. This does not return. */
75 #if defined(IRIVER_H10) || defined (IRIVER_H10_5GB)
76 if(button_status()==BUTTON_RIGHT
)
77 #endif /* defined(IRIVER_H10) || defined (IRIVER_H10_5GB) */
79 #ifndef HAVE_FLASH_STORAGE
80 ata_sleepnow(); /* Immediately spindown the disk. */
84 #ifdef IPOD_ARCH /* The following code is based on ipodlinux */
85 #if CONFIG_CPU == PP5020
86 memcpy((void *)0x40017f00, "diskmode\0\0hotstuff\0\0\1", 21);
87 #elif CONFIG_CPU == PP5022
88 memcpy((void *)0x4001ff00, "diskmode\0\0hotstuff\0\0\1", 21);
89 #endif /* CONFIG_CPU */
90 #endif /* IPOD_ARCH */
92 system_reboot(); /* Reboot */
94 #endif /*defined(IPOD_ARCH) || defined(IRIVER_H10) || defined (IRIVER_H10_5GB)*/
96 #endif /* !HAVE_USBSTACK */
101 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
102 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
103 /* GPIO C bit 1 is firewire detect */
104 if (!(GPIOC_INPUT_VAL
& 0x02))
108 #if defined(SANSA_C200)
109 /* GPIO H bit 1 is usb detect */
110 if (GPIOH_INPUT_VAL
& 0x02)
112 #elif defined(SANSA_E200)
113 /* GPIO B bit 4 is usb detect */
114 if (GPIOB_INPUT_VAL
& 0x10)
116 #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
117 /* GPIO L bit 2 is usb detect */
118 if (GPIOL_INPUT_VAL
& 0x4)
122 return USB_EXTRACTED
;