diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 7 | ||||
-rw-r--r-- | firmware/target/arm/as3525/usb-as3525.c | 69 |
2 files changed, 76 insertions, 0 deletions
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 | ||
53 | static void UIRQ (void) __attribute__((interrupt ("IRQ"))); | 54 | static void UIRQ (void) __attribute__((interrupt ("IRQ"))); |
55 | #endif | ||
54 | void irq_handler(void) __attribute__((naked, interrupt ("IRQ"))); | 56 | void irq_handler(void) __attribute__((naked, interrupt ("IRQ"))); |
55 | void fiq_handler(void) __attribute__((interrupt ("FIQ"))); | 57 | void 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 | |||
33 | const 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 | ||
31 | static int usb_status = USB_EXTRACTED; | 51 | static int usb_status = USB_EXTRACTED; |
32 | 52 | ||
@@ -68,4 +88,53 @@ int usb_detect(void) | |||
68 | 88 | ||
69 | void usb_init_device(void) | 89 | void 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 | |||
100 | void 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 | |||
116 | void 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 | |||
127 | void usb_dw_target_enable_irq() | ||
128 | { | ||
129 | VIC_INT_ENABLE = INTERRUPT_USB; | ||
130 | } | ||
131 | |||
132 | void usb_dw_target_disable_irq() | ||
133 | { | ||
134 | VIC_INT_EN_CLEAR = INTERRUPT_USB; | ||
135 | } | ||
136 | |||
137 | void usb_dw_target_clear_irq() | ||
138 | { | ||
139 | #endif /* USBOTG_DESIGNWARE */ | ||
71 | } | 140 | } |