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 /* Do one-time inits */
76 void usb_enable(bool on
)
79 /* if USB is detected, re-enable the USB-devices, otherwise make sure it's disabled */
82 DEV_INIT2
|= INIT_USB
;
87 /* Disable USB devices */
90 DEV_INIT2
&=~ INIT_USB
;
94 static bool usb_pin_detect(void)
98 #if defined(IPOD_4G) || defined(IPOD_COLOR) \
99 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
100 /* GPIO D bit 3 is usb detect */
101 if (GPIOD_INPUT_VAL
& 0x08)
104 #elif defined(IPOD_NANO) || defined(IPOD_VIDEO)
105 /* GPIO L bit 4 is usb detect */
106 if (GPIOL_INPUT_VAL
& 0x10)
109 #elif defined(SANSA_C200)
110 /* GPIO H bit 1 is usb detect */
111 if (GPIOH_INPUT_VAL
& 0x02)
114 #elif defined(SANSA_E200)
115 /* GPIO B bit 4 is usb detect */
116 if (GPIOB_INPUT_VAL
& 0x10)
119 #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(MROBE_100)
120 /* GPIO L bit 2 is usb detect */
121 if (GPIOL_INPUT_VAL
& 0x4)
128 /* detect host or charger (INSERTED or POWERED) */
131 if(usb_pin_detect()) {
135 return USB_EXTRACTED
;
139 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
140 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
141 bool firewire_detect(void)
143 /* GPIO C bit 1 is firewire detect */
144 if (!(GPIOC_INPUT_VAL
& 0x02))
145 /* no charger detection needed for firewire */