summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/m3/usb-m3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iaudio/m3/usb-m3.c')
-rw-r--r--firmware/target/coldfire/iaudio/m3/usb-m3.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/m3/usb-m3.c b/firmware/target/coldfire/iaudio/m3/usb-m3.c
new file mode 100644
index 0000000000..f37c69574c
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/usb-m3.c
@@ -0,0 +1,47 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include <stdbool.h>
22#include "cpu.h"
23#include "system.h"
24#include "usb.h"
25
26void usb_init_device(void)
27{
28 and_l(~0x10000000, &GPIO_OUT); /* USB enable bit */
29 or_l(0x10000000, &GPIO_ENABLE);
30 or_l(0x10000000, &GPIO_FUNCTION);
31
32 or_l(0x00000400, &GPIO1_FUNCTION); /* USB detect */
33}
34
35int usb_detect(void)
36{
37 return (GPIO1_READ & 0x00000400) ? USB_INSERTED : USB_EXTRACTED;
38}
39
40void usb_enable(bool on)
41{
42 if(on) {
43 or_l(0x10000000, &GPIO_OUT);
44 } else {
45 and_l(~0x10000000, &GPIO_OUT);
46 }
47}