summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorCástor Muñoz <cmvidal@gmail.com>2016-07-31 03:52:22 +0200
committerGerrit Rockbox <gerrit@rockbox.org>2016-08-15 02:56:23 +0200
commit6a1644c52ac8af4696356db04894245f5a0e3dc3 (patch)
tree74813c30762ec62cc0df74e9ff28d9f1d7083d2a /firmware
parent9868da4978922f016f3853da28621e17d088a18e (diff)
downloadrockbox-6a1644c52ac8af4696356db04894245f5a0e3dc3.tar.gz
rockbox-6a1644c52ac8af4696356db04894245f5a0e3dc3.zip
as3525v2: use the new USB DesignWare driver
Targets: sansaclipplus, samsaclipv2, sansaclipzip, sansafuzev2. Change-Id: I7773528a4e26707dd33fe9cb8948750d49570701
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/as3525v2.h6
-rw-r--r--firmware/export/config/sansaclipplus.h4
-rw-r--r--firmware/export/config/sansaclipv2.h4
-rw-r--r--firmware/export/config/sansaclipzip.h4
-rw-r--r--firmware/export/config/sansafuzev2.h4
-rw-r--r--firmware/target/arm/as3525/system-as3525.c7
-rw-r--r--firmware/target/arm/as3525/usb-as3525.c69
7 files changed, 93 insertions, 5 deletions
diff --git a/firmware/export/as3525v2.h b/firmware/export/as3525v2.h
index 4c571f2a22..f68a07a2fb 100644
--- a/firmware/export/as3525v2.h
+++ b/firmware/export/as3525v2.h
@@ -37,7 +37,7 @@
37#define CGU_SDSLOT (*(volatile unsigned long *)(CGU_BASE + 0x3C)) 37#define CGU_SDSLOT (*(volatile unsigned long *)(CGU_BASE + 0x3C))
38 38
39#undef USB_NUM_ENDPOINTS 39#undef USB_NUM_ENDPOINTS
40 40/* 7 available EPs (0b00000000010101010000000000101011), 6 used */
41#define USB_NUM_ENDPOINTS 6 41#define USB_NUM_ENDPOINTS 6
42 42
43#define CCU_USB (*(volatile unsigned long *)(CCU_BASE + 0x20)) 43#define CCU_USB (*(volatile unsigned long *)(CCU_BASE + 0x20))
@@ -45,4 +45,8 @@
45#undef USB_DEVBSS_ATTR 45#undef USB_DEVBSS_ATTR
46#define USB_DEVBSS_ATTR __attribute__((aligned(32))) 46#define USB_DEVBSS_ATTR __attribute__((aligned(32)))
47 47
48/* Define this if the DWC implemented on this SoC does not support
49 DMA or you want to disable it. */
50// #define USB_DW_ARCH_SLAVE
51
48#endif /* __AS3525V2_H__ */ 52#endif /* __AS3525V2_H__ */
diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
index 6eb8bbcf6e..07cf03280a 100644
--- a/firmware/export/config/sansaclipplus.h
+++ b/firmware/export/config/sansaclipplus.h
@@ -183,7 +183,9 @@
183#define CONFIG_LCD LCD_SSD1303 183#define CONFIG_LCD LCD_SSD1303
184 184
185/* USB On-the-go */ 185/* USB On-the-go */
186#define CONFIG_USBOTG USBOTG_S3C6400X 186#define CONFIG_USBOTG USBOTG_DESIGNWARE
187/* logf() over USB serial (http://www.rockbox.org/wiki/PortalPlayerUsb) */
188//#define USB_ENABLE_SERIAL
187 189
188/* enable these for the experimental usb stack */ 190/* enable these for the experimental usb stack */
189#define HAVE_USBSTACK 191#define HAVE_USBSTACK
diff --git a/firmware/export/config/sansaclipv2.h b/firmware/export/config/sansaclipv2.h
index 0aa05975df..c7833189b6 100644
--- a/firmware/export/config/sansaclipv2.h
+++ b/firmware/export/config/sansaclipv2.h
@@ -179,7 +179,9 @@
179#define CONFIG_LCD LCD_SSD1303 179#define CONFIG_LCD LCD_SSD1303
180 180
181/* USB On-the-go */ 181/* USB On-the-go */
182#define CONFIG_USBOTG USBOTG_S3C6400X 182#define CONFIG_USBOTG USBOTG_DESIGNWARE
183/* logf() over USB serial (http://www.rockbox.org/wiki/PortalPlayerUsb) */
184//#define USB_ENABLE_SERIAL
183 185
184/* enable these for the experimental usb stack */ 186/* enable these for the experimental usb stack */
185#define HAVE_USBSTACK 187#define HAVE_USBSTACK
diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
index c31e08f846..9adf7023a9 100644
--- a/firmware/export/config/sansaclipzip.h
+++ b/firmware/export/config/sansaclipzip.h
@@ -182,7 +182,9 @@
182#define CONFIG_LCD LCD_CLIPZIP 182#define CONFIG_LCD LCD_CLIPZIP
183 183
184/* USB On-the-go */ 184/* USB On-the-go */
185#define CONFIG_USBOTG USBOTG_S3C6400X 185#define CONFIG_USBOTG USBOTG_DESIGNWARE
186/* logf() over USB serial (http://www.rockbox.org/wiki/PortalPlayerUsb) */
187//#define USB_ENABLE_SERIAL
186 188
187/* enable these for the experimental usb stack */ 189/* enable these for the experimental usb stack */
188#define HAVE_USBSTACK 190#define HAVE_USBSTACK
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index 6bdfd58339..595106eecf 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -203,7 +203,9 @@
203#endif 203#endif
204 204
205/* USB On-the-go */ 205/* USB On-the-go */
206#define CONFIG_USBOTG USBOTG_S3C6400X 206#define CONFIG_USBOTG USBOTG_DESIGNWARE
207/* logf() over USB serial (http://www.rockbox.org/wiki/PortalPlayerUsb) */
208//#define USB_ENABLE_SERIAL
207 209
208/* enable these for the experimental usb stack */ 210/* enable these for the experimental usb stack */
209#define HAVE_USBSTACK 211#define HAVE_USBSTACK
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index af11d7d842..8aa2d02ab7 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -50,7 +50,9 @@
50#define default_interrupt(name) \ 50#define default_interrupt(name) \
51 extern __attribute__((weak,alias("UIRQ"))) void name (void) 51 extern __attribute__((weak,alias("UIRQ"))) void name (void)
52 52
53#if CONFIG_USBOTG != USBOTG_DESIGNWARE
53static void UIRQ (void) __attribute__((interrupt ("IRQ"))); 54static void UIRQ (void) __attribute__((interrupt ("IRQ")));
55#endif
54void irq_handler(void) __attribute__((naked, interrupt ("IRQ"))); 56void irq_handler(void) __attribute__((naked, interrupt ("IRQ")));
55void fiq_handler(void) __attribute__((interrupt ("FIQ"))); 57void fiq_handler(void) __attribute__((interrupt ("FIQ")));
56 58
@@ -105,6 +107,11 @@ static void UIRQ(void)
105 if(status == 0) 107 if(status == 0)
106 { 108 {
107 status = VIC_RAW_INTR; /* masked interrupts */ 109 status = VIC_RAW_INTR; /* masked interrupts */
110#if CONFIG_USBOTG == USBOTG_DESIGNWARE
111 /* spurious interrupts from USB are expected */
112 if (status & INTERRUPT_USB)
113 return;
114#endif
108 masked = true; 115 masked = true;
109 } 116 }
110 117
diff --git a/firmware/target/arm/as3525/usb-as3525.c b/firmware/target/arm/as3525/usb-as3525.c
index 4e63054f46..d798d4da83 100644
--- a/firmware/target/arm/as3525/usb-as3525.c
+++ b/firmware/target/arm/as3525/usb-as3525.c
@@ -27,6 +27,26 @@
27#include "power.h" 27#include "power.h"
28#include "as3525.h" 28#include "as3525.h"
29#include "usb_drv.h" 29#include "usb_drv.h"
30#if CONFIG_USBOTG == USBOTG_DESIGNWARE
31#include "usb-designware.h"
32
33const struct usb_dw_config usb_dw_config =
34{
35 .phytype = DWC_PHYTYPE_UTMI_16,
36
37 /* Available FIFO memory: 0x535 words */
38 .rx_fifosz = 0x215,
39 .nptx_fifosz = 0x20, /* 1 dedicated FIFO for IN0 */
40 .ptx_fifosz = 0x100, /* 3 dedicated FIFOs for IN1,IN3,IN5 */
41
42#ifdef USB_DW_ARCH_SLAVE
43 .disable_double_buffering = false,
44#else
45 .ahb_burst_len = HBSTLEN_INCR8,
46 .ahb_threshold = 8,
47#endif
48};
49#endif /* USBOTG_DESIGNWARE */
30 50
31static int usb_status = USB_EXTRACTED; 51static int usb_status = USB_EXTRACTED;
32 52
@@ -68,4 +88,53 @@ int usb_detect(void)
68 88
69void usb_init_device(void) 89void usb_init_device(void)
70{ 90{
91#if CONFIG_USBOTG == USBOTG_DESIGNWARE
92 /* Power up the core clocks to allow writing
93 to some registers needed to power it down */
94 usb_dw_target_disable_irq();
95 usb_dw_target_enable_clocks();
96
97 usb_drv_exit();
98}
99
100void usb_dw_target_enable_clocks()
101{
102 bitset32(&CGU_PERI, CGU_USB_CLOCK_ENABLE);
103 CCU_USB = (CCU_USB & ~(3<<24)) | (1 << 24); /* ?? */
104 /* PHY clock */
105 CGU_USB = 1<<5 /* enable */
106 | 0 << 2
107 | 0; /* source = ? (24MHz crystal?) */
108
109 /* Do something that is probably CCU related but undocumented*/
110 CCU_USB |= 0x1000;
111 CCU_USB &= ~0x300000;
112
113 udelay(400);
114}
115
116void usb_dw_target_disable_clocks()
117{
118 CGU_USB = 0;
119 bitclr32(&CGU_PERI, CGU_USB_CLOCK_ENABLE);
120
121 /* reset USB_PHY to prevent power consumption */
122 CCU_SRC = CCU_SRC_USB_PHY_EN;
123 CCU_SRL = CCU_SRL_MAGIC_NUMBER;
124 CCU_SRL = 0;
125}
126
127void usb_dw_target_enable_irq()
128{
129 VIC_INT_ENABLE = INTERRUPT_USB;
130}
131
132void usb_dw_target_disable_irq()
133{
134 VIC_INT_EN_CLEAR = INTERRUPT_USB;
135}
136
137void usb_dw_target_clear_irq()
138{
139#endif /* USBOTG_DESIGNWARE */
71} 140}