summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCástor Muñoz <cmvidal@gmail.com>2016-07-31 03:48:11 +0200
committerCástor Muñoz <cmvidal@gmail.com>2016-08-02 04:57:50 +0200
commitef572fec523c3064cbec8df3ef7610a2a9b5df54 (patch)
tree1b6f979c1cd8fad4f2ed6c6114763d6d7bda8156
parent3c5aa754de9c9e572232b469398a981dccfff127 (diff)
downloadrockbox-ef572fec523c3064cbec8df3ef7610a2a9b5df54.tar.gz
rockbox-ef572fec523c3064cbec8df3ef7610a2a9b5df54.zip
iPod Nano 2G: use the new USB DesignWare driver
Change-Id: I8d1561bf4e239b55617a8d5075457a668e0c312c
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/export/config/ipodnano2g.h7
-rw-r--r--firmware/export/s5l8700.h21
-rw-r--r--firmware/target/arm/s5l8700/usb-nano2g-6g.c117
-rw-r--r--firmware/target/arm/s5l8700/usb-s5l8701.c138
5 files changed, 163 insertions, 122 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 2550475e15..53c44c89b2 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1582,7 +1582,7 @@ target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
1582target/arm/s5l8700/ipodnano2g/nand-nano2g.c 1582target/arm/s5l8700/ipodnano2g/nand-nano2g.c
1583target/arm/s5l8700/ipodnano2g/pmu-nano2g.c 1583target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
1584target/arm/s5l8700/ipodnano2g/rtc-nano2g.c 1584target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
1585target/arm/s5l8700/usb-nano2g-6g.c 1585target/arm/s5l8700/usb-s5l8701.c
1586#ifdef HAVE_SERIAL 1586#ifdef HAVE_SERIAL
1587target/arm/uc870x.c 1587target/arm/uc870x.c
1588target/arm/s5l8700/uart-s5l8701.c 1588target/arm/s5l8700/uart-s5l8701.c
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h
index 8e8f40f56c..aeff6aeda1 100644
--- a/firmware/export/config/ipodnano2g.h
+++ b/firmware/export/config/ipodnano2g.h
@@ -221,12 +221,15 @@
221#define DEFAULT_BRIGHTNESS_SETTING 0x20 221#define DEFAULT_BRIGHTNESS_SETTING 0x20
222 222
223/* USB defines */ 223/* USB defines */
224#define CONFIG_USBOTG USBOTG_DESIGNWARE
225#define USB_DW_CLOCK 0
226#define USB_DW_TURNAROUND 5
227/* logf() over USB serial (http://www.rockbox.org/wiki/PortalPlayerUsb) */
228//#define USB_ENABLE_SERIAL
224#define HAVE_USBSTACK 229#define HAVE_USBSTACK
225#define HAVE_USB_HID_MOUSE 230#define HAVE_USB_HID_MOUSE
226#define CONFIG_USBOTG USBOTG_S3C6400X
227#define USB_VENDOR_ID 0x05AC 231#define USB_VENDOR_ID 0x05AC
228#define USB_PRODUCT_ID 0x1260 232#define USB_PRODUCT_ID 0x1260
229#define USB_NUM_ENDPOINTS 6
230#define USB_DEVBSS_ATTR __attribute__((aligned(16))) 233#define USB_DEVBSS_ATTR __attribute__((aligned(16)))
231 234
232/* Define this if you can switch on/off the accessory power supply */ 235/* Define this if you can switch on/off the accessory power supply */
diff --git a/firmware/export/s5l8700.h b/firmware/export/s5l8700.h
index 3444919bc3..b559992c6a 100644
--- a/firmware/export/s5l8700.h
+++ b/firmware/export/s5l8700.h
@@ -788,7 +788,24 @@
788/* Synopsys OTG - S5L8701 only */ 788/* Synopsys OTG - S5L8701 only */
789#define OTGBASE 0x38800000 789#define OTGBASE 0x38800000
790#define PHYBASE 0x3C400000 790#define PHYBASE 0x3C400000
791#define SYNOPSYSOTG_CLOCK 0 791
792#define SYNOPSYSOTG_AHBCFG (GAHBCFG_dma_enable | (GAHBCFG_INT_DMA_BURST_INCR4 << GAHBCFG_hburstlen_bitp) | GAHBCFG_glblintrmsk) 792/* OTG PHY control registers */
793#define OPHYPWR (*((uint32_t volatile*)(PHYBASE + 0x000)))
794#define OPHYCLK (*((uint32_t volatile*)(PHYBASE + 0x004)))
795#define ORSTCON (*((uint32_t volatile*)(PHYBASE + 0x008)))
796#define OPHYUNK3 (*((uint32_t volatile*)(PHYBASE + 0x018)))
797#define OPHYUNK1 (*((uint32_t volatile*)(PHYBASE + 0x01c)))
798#define OPHYUNK2 (*((uint32_t volatile*)(PHYBASE + 0x044)))
799
800/* 7 available EPs (0b00000000011101010000000001101011), 6 used */
801#define USB_NUM_ENDPOINTS 6
802
803/* Define this if the DWC implemented on this SoC does not support
804 dedicated FIFOs. */
805#define USB_DW_SHARED_FIFO
806
807/* Define this if the DWC implemented on this SoC does not support
808 DMA or you want to disable it. */
809// #define USB_DW_ARCH_SLAVE
793 810
794#endif /* CONFIG_CPU==S5L8701 */ 811#endif /* CONFIG_CPU==S5L8701 */
diff --git a/firmware/target/arm/s5l8700/usb-nano2g-6g.c b/firmware/target/arm/s5l8700/usb-nano2g-6g.c
deleted file mode 100644
index 6ae9f9b96b..0000000000
--- a/firmware/target/arm/s5l8700/usb-nano2g-6g.c
+++ /dev/null
@@ -1,117 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by 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
22#include "config.h"
23#include "usb.h"
24#include "usb-s3c6400x.h"
25#include "cpu.h"
26
27#ifdef HAVE_USBSTACK
28#include "usb_core.h"
29#include "usb_drv.h"
30
31void usb_enable(bool on)
32{
33 if (on) usb_core_init();
34 else usb_core_exit();
35}
36
37#if CONFIG_CPU==S5L8701
38#include "power.h"
39
40int usb_detect(void)
41{
42 if (power_input_status() & POWER_INPUT_USB)
43 return USB_INSERTED;
44 return USB_EXTRACTED;
45}
46
47#elif CONFIG_CPU==S5L8702
48static int usb_status = USB_EXTRACTED;
49
50int usb_detect(void)
51{
52 return usb_status;
53}
54
55void usb_insert_int(void)
56{
57 usb_status = USB_INSERTED;
58#ifdef USB_STATUS_BY_EVENT
59 usb_status_event(USB_INSERTED);
60#endif
61}
62
63void usb_remove_int(void)
64{
65 usb_status = USB_EXTRACTED;
66#ifdef USB_STATUS_BY_EVENT
67 usb_status_event(USB_EXTRACTED);
68#endif
69}
70#endif /* S5L8702 */
71
72void usb_init_device(void)
73{
74 /* Power up the core clocks to allow writing
75 to some registers needed to power it down */
76 PCGCCTL = 0;
77#if CONFIG_CPU==S5L8701
78 PWRCON &= ~0x4000;
79 PWRCONEXT &= ~0x800;
80 INTMSK |= INTMSK_USB_OTG;
81#elif CONFIG_CPU==S5L8702
82 PWRCON(0) &= ~0x4;
83 PWRCON(1) &= ~0x8;
84 VIC0INTENABLE |= 1 << 19;
85#endif
86
87 usb_drv_exit();
88}
89
90#else /* !HAVE_USBSTACK */
91void usb_enable(bool on)
92{
93 (void)on;
94}
95
96int usb_detect(void)
97{
98 return USB_EXTRACTED;
99}
100
101void usb_init_device(void)
102{
103 DCTL = DCTL_pwronprgdone | DCTL_sftdiscon;
104
105 ORSTCON = 1; /* Put the PHY into reset (needed to get current down) */
106 PCGCCTL = 1; /* Shut down PHY clock */
107 OPHYPWR = 0xF; /* PHY: Power down */
108
109#if CONFIG_CPU==S5L8701
110 PWRCON |= 0x4000;
111 PWRCONEXT |= 0x800;
112#elif CONFIG_CPU==S5L8702
113 PWRCON(0) |= 0x4;
114 PWRCON(1) |= 0x8;
115#endif
116}
117#endif
diff --git a/firmware/target/arm/s5l8700/usb-s5l8701.c b/firmware/target/arm/s5l8700/usb-s5l8701.c
new file mode 100644
index 0000000000..860f54b2d8
--- /dev/null
+++ b/firmware/target/arm/s5l8700/usb-s5l8701.c
@@ -0,0 +1,138 @@
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#include "power.h"
29#endif
30
31#include "s5l8700.h"
32#include "usb-designware.h"
33
34
35const struct usb_dw_config usb_dw_config =
36{
37 /* PHY must run at 60MHz, otherwise there are spurious -EPROTO
38 errors, probably related with GHWCFG4_MIN_AHB_FREQ. */
39 .phytype = DWC_PHYTYPE_UTMI_8,
40
41 /*
42 * Total available FIFO memory: 0x500 words.
43 */
44 .rx_fifosz = 0x220,
45 /* nptx_fifosz seems limited to 0x200 due to some internal counter
46 misbehaviour (TBC). */
47 .nptx_fifosz = 0x200,
48 /* ptx_fifosz is not writeable (fixed to 0x300), anyway it seems
49 internally limited to a small number, aroung 0x10..0x20 (TBC),
50 we use_ptxfifo_as_plain_buffer to deal with this issue. */
51 .ptx_fifosz = 0x80,
52 .use_ptxfifo_as_plain_buffer = true,
53
54#ifdef USB_DW_ARCH_SLAVE
55 .disable_double_buffering = false,
56#else
57 .ahb_burst_len = HBSTLEN_INCR4,
58#endif
59};
60
61void usb_dw_target_enable_clocks()
62{
63 PWRCON &= ~0x4000;
64 PWRCONEXT &= ~0x800;
65
66 OPHYPWR = 0; /* PHY: Power up */
67 udelay(10);
68 OPHYUNK1 = 1;
69 OPHYUNK2 = 0xe3f;
70 ORSTCON = 1; /* PHY: Assert Software Reset */
71 udelay(10);
72 ORSTCON = 0; /* PHY: Deassert Software Reset */
73 udelay(10);
74 OPHYUNK3 = 0x600;
75 OPHYCLK = USB_DW_CLOCK;
76 udelay(400);
77}
78
79void usb_dw_target_disable_clocks()
80{
81 OPHYPWR = 0xf; /* PHY: Power down */
82 udelay(10);
83 ORSTCON = 7; /* PHY: Assert Software Reset */
84 udelay(10);
85
86 PWRCON |= 0x4000;
87 PWRCONEXT |= 0x800;
88}
89
90void usb_dw_target_enable_irq()
91{
92 INTMSK |= INTMSK_USB_OTG;
93}
94
95void usb_dw_target_disable_irq()
96{
97 INTMSK &= ~INTMSK_USB_OTG;
98}
99
100void usb_dw_target_clear_irq()
101{
102 SRCPND |= INTMSK_USB_OTG;
103}
104
105/* RB API fuctions */
106void usb_enable(bool on)
107{
108#ifdef HAVE_USBSTACK
109 if (on){
110 cpu_boost(1);
111 usb_core_init();
112 } else {
113 usb_core_exit();
114 cpu_boost(0);
115 }
116#else
117 (void)on;
118#endif
119}
120
121int usb_detect(void)
122{
123#ifdef HAVE_USBSTACK
124 if (power_input_status() & POWER_INPUT_USB)
125 return USB_INSERTED;
126#endif
127 return USB_EXTRACTED;
128}
129
130void usb_init_device(void)
131{
132 /* Power up the core clocks to allow writing
133 to some registers needed to power it down */
134 usb_dw_target_disable_irq();
135 usb_dw_target_enable_clocks();
136
137 usb_drv_exit();
138}