summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/mpio/usb-mpio.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2010-11-12 21:52:29 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2010-11-12 21:52:29 +0000
commit123bebeada5dce220d8ce96d31ed711cb13d8d05 (patch)
treee1d45698eb457c142916271529ca28834708937c /firmware/target/coldfire/mpio/usb-mpio.c
parent6c8267a42cffd711dcd4230415f7e0ab15b855b3 (diff)
downloadrockbox-123bebeada5dce220d8ce96d31ed711cb13d8d05.tar.gz
rockbox-123bebeada5dce220d8ce96d31ed711cb13d8d05.zip
MPIO: move files a bit in preparation for HD300 port
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28567 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/mpio/usb-mpio.c')
-rw-r--r--firmware/target/coldfire/mpio/usb-mpio.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/firmware/target/coldfire/mpio/usb-mpio.c b/firmware/target/coldfire/mpio/usb-mpio.c
new file mode 100644
index 0000000000..a8c3db85bd
--- /dev/null
+++ b/firmware/target/coldfire/mpio/usb-mpio.c
@@ -0,0 +1,75 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include <stdbool.h>
23#include "cpu.h"
24#include "system.h"
25#include "kernel.h"
26#include "usb.h"
27
28void usb_init_device(void)
29{
30 /* GPIO42 is USB detect input
31 * but it also serves as MCLK2 for DAC
32 */
33 and_l(~(1<<4), &GPIO1_OUT); /* GPIO36 low */
34 or_l((1<<4), &GPIO1_ENABLE); /* GPIO36 */
35 or_l((1<<4)|(1<<5), &GPIO1_FUNCTION); /* GPIO36 GPIO37 */
36
37 /* GPIO22 GPIO30 high */
38 or_l((1<<22)|(1<<30), &GPIO_OUT);
39 or_l((1<<22)|(1<<30), &GPIO_ENABLE);
40 or_l((1<<22)|(1<<30), &GPIO_FUNCTION);
41}
42
43int usb_detect(void)
44{
45 /* GPIO42 active low*/
46 return (GPIO1_READ & (1<<10)) ? USB_EXTRACTED : USB_INSERTED;
47}
48
49void usb_enable(bool on)
50{
51 /* one second timeout */
52 unsigned char timeout = 10;
53
54 if(on)
55 {
56 and_l(~(1<<30),&GPIO_OUT); /* GPIO30 low */
57 and_l(~(1<<22),&GPIO_OUT); /* GPIO22 low */
58
59 or_l((1<<4),&GPIO1_OUT); /* GPIO36 high */
60
61 }
62 else
63 {
64 or_l((1<<22),&GPIO_OUT); /* GPIO22 high */
65 or_l((1<<30),&GPIO_OUT); /* GPIO30 high */
66
67 and_l(~(1<<4),&GPIO1_OUT); /* GPIO36 low */
68
69 while ( !(GPIO1_READ & (1<<5)) && timeout--)
70 {
71 sleep(HZ/10);
72 }
73 sleep(HZ);
74 }
75}