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 ****************************************************************************/
33 void usb_init_device(void)
35 /* enable usb module */
36 outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
47 DEV_INIT2
|= INIT_USB
;
49 while ((inl(0x70000028) & 0x80) == 0);
50 outl(inl(0x70000028) | 0x2, 0x70000028);
53 /* disable USB-devices until USB is detected via GPIO */
55 /* Disabling USB0 in the bootloader makes the OF not load,
56 Also something here breaks usb pin detect in bootloader.
57 leave it all enabled untill rockbox main loads */
60 DEV_INIT2
&= ~INIT_USB
;
63 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
64 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
65 /* GPIO C bit 1 is firewire detect */
67 GPIOC_OUTPUT_EN
&= ~0x02;
71 void usb_enable(bool on
)
74 /* if USB is detected, re-enable the USB-devices, otherwise make sure it's disabled */
77 DEV_INIT2
|= INIT_USB
;
82 /* Disable USB devices */
85 DEV_INIT2
&=~ INIT_USB
;
89 static bool usb_pin_detect(void)
93 #if defined(IPOD_4G) || defined(IPOD_COLOR) \
94 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
95 /* GPIO D bit 3 is usb detect */
96 if (GPIOD_INPUT_VAL
& 0x08)
99 #elif defined(IPOD_NANO) || defined(IPOD_VIDEO)
100 /* GPIO L bit 4 is usb detect */
101 if (GPIOL_INPUT_VAL
& 0x10)
104 #elif defined(SANSA_C200)
105 /* GPIO H bit 1 is usb detect */
106 if (GPIOH_INPUT_VAL
& 0x02)
109 #elif defined(SANSA_E200)
110 /* GPIO B bit 4 is usb detect */
111 if (GPIOB_INPUT_VAL
& 0x10)
114 #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(MROBE_100)
115 /* GPIO L bit 2 is usb detect */
116 if (GPIOL_INPUT_VAL
& 0x4)
123 /* detect host or charger (INSERTED or POWERED) */
126 if(usb_pin_detect()) {
130 return USB_EXTRACTED
;
134 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
135 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
136 bool firewire_detect(void)
138 /* GPIO C bit 1 is firewire detect */
139 if (!(GPIOC_INPUT_VAL
& 0x02))
140 /* no charger detection needed for firewire */