1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
12 * 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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 #include "clkctl-imx31.h"
29 static int usb_status
= USB_EXTRACTED
;
31 static void enable_transceiver(bool enable
)
35 if (GPIO1_DR
& (1 << 30))
37 GPIO3_DR
&= ~(1 << 16); /* Reset ISP1504 */
38 GPIO3_DR
|= (1 << 16);
39 GPIO1_DR
&= ~(1 << 30); /* Select ISP1504 */
44 GPIO1_DR
|= (1 << 30); /* Deselect ISP1504 */
48 void usb_set_status(bool plugged
)
50 usb_status
= plugged
? USB_INSERTED
: USB_EXTRACTED
;
58 /* Read the immediate state of the cable from the PMIC */
59 bool usb_plugged(void)
61 return mc13783_read(MC13783_INTERRUPT_SENSE0
) & MC13783_USB4V4
;
64 extern void usb_drv_startup(void);
66 void usb_init_device(void)
68 imx31_clkctl_module_clock_gating(CG_USBOTG
, CGM_ON_ALL
);
70 enable_transceiver(true);
72 /* Module will be turned off later after firmware init */
75 mc13783_clear(MC13783_INTERRUPT_MASK0
, MC13783_USB4V4
);
78 void usb_enable(bool on
)
82 imx31_clkctl_module_clock_gating(CG_USBOTG
, CGM_ON_ALL
);
83 enable_transceiver(true);
88 /* Module clock should be on since this could be called first */
89 imx31_clkctl_module_clock_gating(CG_USBOTG
, CGM_ON_ALL
);
90 enable_transceiver(true);
92 enable_transceiver(false);
93 imx31_clkctl_module_clock_gating(CG_USBOTG
, CGM_OFF
);