summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorCástor Muñoz <cmvidal@gmail.com>2016-07-31 03:40:32 +0200
committerCástor Muñoz <cmvidal@gmail.com>2016-08-02 04:57:50 +0200
commit3c5aa754de9c9e572232b469398a981dccfff127 (patch)
treef67d41afeb7df68b91753bb2d66d3c8ce945207f /firmware/target
parent5e305d35c94199241f71a994cf6a691aec49688c (diff)
downloadrockbox-3c5aa754de9c9e572232b469398a981dccfff127.tar.gz
rockbox-3c5aa754de9c9e572232b469398a981dccfff127.zip
iPod Classic: use the new USB DesignWare driver
Change-Id: I36aabb5cb9cfe2d8c4f8fbcea944efec58ef9671
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/s5l8702/usb-s5l8702.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8702/usb-s5l8702.c b/firmware/target/arm/s5l8702/usb-s5l8702.c
new file mode 100644
index 0000000000..7a349f74f4
--- /dev/null
+++ b/firmware/target/arm/s5l8702/usb-s5l8702.c
@@ -0,0 +1,137 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2014 Michael Sparmann
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 <inttypes.h>
22
23#include "config.h"
24#include "usb.h"
25#include "usb_drv.h"
26#ifdef HAVE_USBSTACK
27#include "usb_core.h"
28#endif
29
30#include "s5l8702.h"
31#include "clocking-s5l8702.h"
32#include "usb-designware.h"
33
34
35const struct usb_dw_config usb_dw_config =
36{
37 .phytype = DWC_PHYTYPE_UTMI_16,
38
39 /* Available FIFO memory: 0x820 words */
40 .rx_fifosz = 0x360,
41 .nptx_fifosz = 0x40, /* 1 dedicated FIFO for IN0 */
42 .ptx_fifosz = 0x180, /* 3 dedicated FIFOs for IN1,IN3,IN5 */
43
44#ifdef USB_DW_ARCH_SLAVE
45 .disable_double_buffering = false,
46#else
47 .ahb_burst_len = HBSTLEN_INCR8,
48 .ahb_threshold = 8,
49#endif
50};
51
52void usb_dw_target_enable_clocks()
53{
54 clockgate_enable(CLOCKGATE_USBOTG, true);
55 clockgate_enable(CLOCKGATE_USBPHY, true);
56
57 OPHYPWR = 0; /* PHY: Power up */
58 udelay(10);
59 OPHYUNK1 = 1;
60 OPHYUNK2 = 0xe3f;
61 ORSTCON = 1; /* PHY: Assert Software Reset */
62 udelay(10);
63 ORSTCON = 0; /* PHY: Deassert Software Reset */
64 udelay(10);
65 OPHYUNK3 = 0x600;
66 OPHYCLK = USB_DW_CLOCK;
67 udelay(400);
68}
69
70void usb_dw_target_disable_clocks()
71{
72 OPHYPWR = 0xf; /* PHY: Power down */
73 udelay(10);
74 ORSTCON = 7; /* PHY: Assert Software Reset */
75 udelay(10);
76
77 clockgate_enable(CLOCKGATE_USBOTG, false);
78 clockgate_enable(CLOCKGATE_USBPHY, false);
79}
80
81void usb_dw_target_enable_irq()
82{
83 VICINTENABLE(IRQ_USB_FUNC >> 5) = 1 << (IRQ_USB_FUNC & 0x1f);
84}
85
86void usb_dw_target_disable_irq()
87{
88 VICINTENCLEAR(IRQ_USB_FUNC >> 5) = 1 << (IRQ_USB_FUNC & 0x1f);
89}
90
91void usb_dw_target_clear_irq()
92{
93}
94
95/* RB API */
96static int usb_status = USB_EXTRACTED;
97
98void usb_enable(bool on)
99{
100#ifdef HAVE_USBSTACK
101 if (on) usb_core_init();
102 else usb_core_exit();
103#else
104 (void)on;
105#endif
106}
107
108int usb_detect(void)
109{
110 return usb_status;
111}
112
113void usb_insert_int(void)
114{
115 usb_status = USB_INSERTED;
116#ifdef USB_STATUS_BY_EVENT
117 usb_status_event(USB_INSERTED);
118#endif
119}
120
121void usb_remove_int(void)
122{
123 usb_status = USB_EXTRACTED;
124#ifdef USB_STATUS_BY_EVENT
125 usb_status_event(USB_EXTRACTED);
126#endif
127}
128
129void usb_init_device(void)
130{
131 /* Power up the core clocks to allow writing
132 to some registers needed to power it down */
133 usb_dw_target_disable_irq();
134 usb_dw_target_enable_clocks();
135
136 usb_drv_exit();
137}