diff options
Diffstat (limited to 'firmware/target/arm/as3525/usb-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/usb-as3525.c | 69 |
1 files changed, 69 insertions, 0 deletions
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 | } |