]>
Commit | Line | Data |
---|---|---|
58a5491c FB |
1 | /* |
2 | * linux/arch/arm/mach-omap2/usb-ehci.c | |
3 | * | |
4 | * This file will contain the board specific details for the | |
5 | * Synopsys EHCI host controller on OMAP3430 | |
6 | * | |
7 | * Copyright (C) 2007 Texas Instruments | |
8 | * Author: Vikram Pandita <vikram.pandita@ti.com> | |
9 | * | |
10 | * Generalization by: | |
11 | * Felipe Balbi <felipe.balbi@nokia.com> | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or modify | |
14 | * it under the terms of the GNU General Public License version 2 as | |
15 | * published by the Free Software Foundation. | |
16 | */ | |
17 | ||
18 | #include <linux/types.h> | |
19 | #include <linux/errno.h> | |
20 | #include <linux/delay.h> | |
21 | #include <linux/platform_device.h> | |
22 | #include <linux/clk.h> | |
bfb01197 AK |
23 | #include <linux/dma-mapping.h> |
24 | ||
58a5491c FB |
25 | #include <asm/io.h> |
26 | #include <plat/mux.h> | |
27 | ||
28 | #include <mach/hardware.h> | |
29 | #include <mach/irqs.h> | |
30 | #include <plat/usb.h> | |
31 | ||
4896e394 TL |
32 | #include "mux.h" |
33 | ||
58a5491c FB |
34 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE) |
35 | ||
36 | static struct resource ehci_resources[] = { | |
37 | { | |
38 | .start = OMAP34XX_EHCI_BASE, | |
39 | .end = OMAP34XX_EHCI_BASE + SZ_1K - 1, | |
40 | .flags = IORESOURCE_MEM, | |
41 | }, | |
42 | { | |
43 | .start = OMAP34XX_UHH_CONFIG_BASE, | |
44 | .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1, | |
45 | .flags = IORESOURCE_MEM, | |
46 | }, | |
47 | { | |
48 | .start = OMAP34XX_USBTLL_BASE, | |
49 | .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1, | |
50 | .flags = IORESOURCE_MEM, | |
51 | }, | |
52 | { /* general IRQ */ | |
53 | .start = INT_34XX_EHCI_IRQ, | |
54 | .flags = IORESOURCE_IRQ, | |
55 | } | |
56 | }; | |
57 | ||
58 | static u64 ehci_dmamask = ~(u32)0; | |
59 | static struct platform_device ehci_device = { | |
60 | .name = "ehci-omap", | |
61 | .id = 0, | |
62 | .dev = { | |
63 | .dma_mask = &ehci_dmamask, | |
64 | .coherent_dma_mask = 0xffffffff, | |
65 | .platform_data = NULL, | |
66 | }, | |
67 | .num_resources = ARRAY_SIZE(ehci_resources), | |
68 | .resource = ehci_resources, | |
69 | }; | |
70 | ||
71 | /* MUX settings for EHCI pins */ | |
72 | /* | |
73 | * setup_ehci_io_mux - initialize IO pad mux for USBHOST | |
74 | */ | |
6f69a181 | 75 | static void setup_ehci_io_mux(const enum ehci_hcd_omap_mode *port_mode) |
58a5491c FB |
76 | { |
77 | switch (port_mode[0]) { | |
78 | case EHCI_HCD_OMAP_MODE_PHY: | |
4896e394 TL |
79 | omap_mux_init_signal("hsusb1_stp", OMAP_PIN_OUTPUT); |
80 | omap_mux_init_signal("hsusb1_clk", OMAP_PIN_OUTPUT); | |
81 | omap_mux_init_signal("hsusb1_dir", OMAP_PIN_INPUT_PULLDOWN); | |
82 | omap_mux_init_signal("hsusb1_nxt", OMAP_PIN_INPUT_PULLDOWN); | |
83 | omap_mux_init_signal("hsusb1_data0", OMAP_PIN_INPUT_PULLDOWN); | |
84 | omap_mux_init_signal("hsusb1_data1", OMAP_PIN_INPUT_PULLDOWN); | |
85 | omap_mux_init_signal("hsusb1_data2", OMAP_PIN_INPUT_PULLDOWN); | |
86 | omap_mux_init_signal("hsusb1_data3", OMAP_PIN_INPUT_PULLDOWN); | |
87 | omap_mux_init_signal("hsusb1_data4", OMAP_PIN_INPUT_PULLDOWN); | |
88 | omap_mux_init_signal("hsusb1_data5", OMAP_PIN_INPUT_PULLDOWN); | |
89 | omap_mux_init_signal("hsusb1_data6", OMAP_PIN_INPUT_PULLDOWN); | |
90 | omap_mux_init_signal("hsusb1_data7", OMAP_PIN_INPUT_PULLDOWN); | |
58a5491c FB |
91 | break; |
92 | case EHCI_HCD_OMAP_MODE_TLL: | |
4896e394 TL |
93 | omap_mux_init_signal("hsusb1_tll_stp", |
94 | OMAP_PIN_INPUT_PULLUP); | |
95 | omap_mux_init_signal("hsusb1_tll_clk", | |
96 | OMAP_PIN_INPUT_PULLDOWN); | |
97 | omap_mux_init_signal("hsusb1_tll_dir", | |
98 | OMAP_PIN_INPUT_PULLDOWN); | |
99 | omap_mux_init_signal("hsusb1_tll_nxt", | |
100 | OMAP_PIN_INPUT_PULLDOWN); | |
101 | omap_mux_init_signal("hsusb1_tll_data0", | |
102 | OMAP_PIN_INPUT_PULLDOWN); | |
103 | omap_mux_init_signal("hsusb1_tll_data1", | |
104 | OMAP_PIN_INPUT_PULLDOWN); | |
105 | omap_mux_init_signal("hsusb1_tll_data2", | |
106 | OMAP_PIN_INPUT_PULLDOWN); | |
107 | omap_mux_init_signal("hsusb1_tll_data3", | |
108 | OMAP_PIN_INPUT_PULLDOWN); | |
109 | omap_mux_init_signal("hsusb1_tll_data4", | |
110 | OMAP_PIN_INPUT_PULLDOWN); | |
111 | omap_mux_init_signal("hsusb1_tll_data5", | |
112 | OMAP_PIN_INPUT_PULLDOWN); | |
113 | omap_mux_init_signal("hsusb1_tll_data6", | |
114 | OMAP_PIN_INPUT_PULLDOWN); | |
115 | omap_mux_init_signal("hsusb1_tll_data7", | |
116 | OMAP_PIN_INPUT_PULLDOWN); | |
58a5491c FB |
117 | break; |
118 | case EHCI_HCD_OMAP_MODE_UNKNOWN: | |
119 | /* FALLTHROUGH */ | |
120 | default: | |
121 | break; | |
122 | } | |
123 | ||
124 | switch (port_mode[1]) { | |
125 | case EHCI_HCD_OMAP_MODE_PHY: | |
4896e394 TL |
126 | omap_mux_init_signal("hsusb2_stp", OMAP_PIN_OUTPUT); |
127 | omap_mux_init_signal("hsusb2_clk", OMAP_PIN_OUTPUT); | |
128 | omap_mux_init_signal("hsusb2_dir", OMAP_PIN_INPUT_PULLDOWN); | |
129 | omap_mux_init_signal("hsusb2_nxt", OMAP_PIN_INPUT_PULLDOWN); | |
130 | omap_mux_init_signal("hsusb2_data0", | |
131 | OMAP_PIN_INPUT_PULLDOWN); | |
132 | omap_mux_init_signal("hsusb2_data1", | |
133 | OMAP_PIN_INPUT_PULLDOWN); | |
134 | omap_mux_init_signal("hsusb2_data2", | |
135 | OMAP_PIN_INPUT_PULLDOWN); | |
136 | omap_mux_init_signal("hsusb2_data3", | |
137 | OMAP_PIN_INPUT_PULLDOWN); | |
138 | omap_mux_init_signal("hsusb2_data4", | |
139 | OMAP_PIN_INPUT_PULLDOWN); | |
140 | omap_mux_init_signal("hsusb2_data5", | |
141 | OMAP_PIN_INPUT_PULLDOWN); | |
142 | omap_mux_init_signal("hsusb2_data6", | |
143 | OMAP_PIN_INPUT_PULLDOWN); | |
144 | omap_mux_init_signal("hsusb2_data7", | |
145 | OMAP_PIN_INPUT_PULLDOWN); | |
58a5491c FB |
146 | break; |
147 | case EHCI_HCD_OMAP_MODE_TLL: | |
4896e394 TL |
148 | omap_mux_init_signal("hsusb2_tll_stp", |
149 | OMAP_PIN_INPUT_PULLUP); | |
150 | omap_mux_init_signal("hsusb2_tll_clk", | |
151 | OMAP_PIN_INPUT_PULLDOWN); | |
152 | omap_mux_init_signal("hsusb2_tll_dir", | |
153 | OMAP_PIN_INPUT_PULLDOWN); | |
154 | omap_mux_init_signal("hsusb2_tll_nxt", | |
155 | OMAP_PIN_INPUT_PULLDOWN); | |
156 | omap_mux_init_signal("hsusb2_tll_data0", | |
157 | OMAP_PIN_INPUT_PULLDOWN); | |
158 | omap_mux_init_signal("hsusb2_tll_data1", | |
159 | OMAP_PIN_INPUT_PULLDOWN); | |
160 | omap_mux_init_signal("hsusb2_tll_data2", | |
161 | OMAP_PIN_INPUT_PULLDOWN); | |
162 | omap_mux_init_signal("hsusb2_tll_data3", | |
163 | OMAP_PIN_INPUT_PULLDOWN); | |
164 | omap_mux_init_signal("hsusb2_tll_data4", | |
165 | OMAP_PIN_INPUT_PULLDOWN); | |
166 | omap_mux_init_signal("hsusb2_tll_data5", | |
167 | OMAP_PIN_INPUT_PULLDOWN); | |
168 | omap_mux_init_signal("hsusb2_tll_data6", | |
169 | OMAP_PIN_INPUT_PULLDOWN); | |
170 | omap_mux_init_signal("hsusb2_tll_data7", | |
171 | OMAP_PIN_INPUT_PULLDOWN); | |
58a5491c FB |
172 | break; |
173 | case EHCI_HCD_OMAP_MODE_UNKNOWN: | |
174 | /* FALLTHROUGH */ | |
175 | default: | |
176 | break; | |
177 | } | |
178 | ||
179 | switch (port_mode[2]) { | |
180 | case EHCI_HCD_OMAP_MODE_PHY: | |
181 | printk(KERN_WARNING "Port3 can't be used in PHY mode\n"); | |
182 | break; | |
183 | case EHCI_HCD_OMAP_MODE_TLL: | |
4896e394 TL |
184 | omap_mux_init_signal("hsusb3_tll_stp", |
185 | OMAP_PIN_INPUT_PULLUP); | |
186 | omap_mux_init_signal("hsusb3_tll_clk", | |
187 | OMAP_PIN_INPUT_PULLDOWN); | |
188 | omap_mux_init_signal("hsusb3_tll_dir", | |
189 | OMAP_PIN_INPUT_PULLDOWN); | |
190 | omap_mux_init_signal("hsusb3_tll_nxt", | |
191 | OMAP_PIN_INPUT_PULLDOWN); | |
192 | omap_mux_init_signal("hsusb3_tll_data0", | |
193 | OMAP_PIN_INPUT_PULLDOWN); | |
194 | omap_mux_init_signal("hsusb3_tll_data1", | |
195 | OMAP_PIN_INPUT_PULLDOWN); | |
196 | omap_mux_init_signal("hsusb3_tll_data2", | |
197 | OMAP_PIN_INPUT_PULLDOWN); | |
198 | omap_mux_init_signal("hsusb3_tll_data3", | |
199 | OMAP_PIN_INPUT_PULLDOWN); | |
200 | omap_mux_init_signal("hsusb3_tll_data4", | |
201 | OMAP_PIN_INPUT_PULLDOWN); | |
202 | omap_mux_init_signal("hsusb3_tll_data5", | |
203 | OMAP_PIN_INPUT_PULLDOWN); | |
204 | omap_mux_init_signal("hsusb3_tll_data6", | |
205 | OMAP_PIN_INPUT_PULLDOWN); | |
206 | omap_mux_init_signal("hsusb3_tll_data7", | |
207 | OMAP_PIN_INPUT_PULLDOWN); | |
58a5491c FB |
208 | break; |
209 | case EHCI_HCD_OMAP_MODE_UNKNOWN: | |
210 | /* FALLTHROUGH */ | |
211 | default: | |
212 | break; | |
213 | } | |
214 | ||
215 | return; | |
216 | } | |
217 | ||
6f69a181 | 218 | void __init usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata) |
58a5491c FB |
219 | { |
220 | platform_device_add_data(&ehci_device, pdata, sizeof(*pdata)); | |
221 | ||
222 | /* Setup Pin IO MUX for EHCI */ | |
223 | if (cpu_is_omap34xx()) | |
224 | setup_ehci_io_mux(pdata->port_mode); | |
225 | ||
226 | if (platform_device_register(&ehci_device) < 0) { | |
227 | printk(KERN_ERR "Unable to register HS-USB (EHCI) device\n"); | |
228 | return; | |
229 | } | |
230 | } | |
231 | ||
232 | #else | |
233 | ||
6f69a181 | 234 | void __init usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata) |
58a5491c FB |
235 | |
236 | { | |
237 | } | |
238 | ||
239 | #endif /* CONFIG_USB_EHCI_HCD */ | |
240 | ||
95344fcc AG |
241 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
242 | ||
243 | static struct resource ohci_resources[] = { | |
244 | { | |
245 | .start = OMAP34XX_OHCI_BASE, | |
246 | .end = OMAP34XX_OHCI_BASE + SZ_1K - 1, | |
247 | .flags = IORESOURCE_MEM, | |
248 | }, | |
249 | { | |
250 | .start = OMAP34XX_UHH_CONFIG_BASE, | |
251 | .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1, | |
252 | .flags = IORESOURCE_MEM, | |
253 | }, | |
254 | { | |
255 | .start = OMAP34XX_USBTLL_BASE, | |
256 | .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1, | |
257 | .flags = IORESOURCE_MEM, | |
258 | }, | |
259 | { /* general IRQ */ | |
260 | .start = INT_34XX_OHCI_IRQ, | |
261 | .flags = IORESOURCE_IRQ, | |
262 | } | |
263 | }; | |
264 | ||
265 | static u64 ohci_dmamask = DMA_BIT_MASK(32); | |
266 | ||
267 | static struct platform_device ohci_device = { | |
268 | .name = "ohci-omap3", | |
269 | .id = 0, | |
270 | .dev = { | |
271 | .dma_mask = &ohci_dmamask, | |
272 | .coherent_dma_mask = 0xffffffff, | |
273 | }, | |
274 | .num_resources = ARRAY_SIZE(ohci_resources), | |
275 | .resource = ohci_resources, | |
276 | }; | |
277 | ||
278 | static void setup_ohci_io_mux(const enum ohci_omap3_port_mode *port_mode) | |
279 | { | |
280 | switch (port_mode[0]) { | |
281 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: | |
282 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: | |
283 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: | |
284 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: | |
285 | omap_mux_init_signal("mm1_rxdp", | |
286 | OMAP_PIN_INPUT_PULLDOWN); | |
287 | omap_mux_init_signal("mm1_rxdm", | |
288 | OMAP_PIN_INPUT_PULLDOWN); | |
289 | /* FALLTHROUGH */ | |
290 | case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: | |
291 | case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: | |
292 | omap_mux_init_signal("mm1_rxrcv", | |
293 | OMAP_PIN_INPUT_PULLDOWN); | |
294 | /* FALLTHROUGH */ | |
295 | case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: | |
296 | case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: | |
297 | omap_mux_init_signal("mm1_txen_n", OMAP_PIN_OUTPUT); | |
298 | /* FALLTHROUGH */ | |
299 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: | |
300 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: | |
301 | omap_mux_init_signal("mm1_txse0", | |
302 | OMAP_PIN_INPUT_PULLDOWN); | |
303 | omap_mux_init_signal("mm1_txdat", | |
304 | OMAP_PIN_INPUT_PULLDOWN); | |
305 | break; | |
306 | case OMAP_OHCI_PORT_MODE_UNUSED: | |
307 | /* FALLTHROUGH */ | |
308 | default: | |
309 | break; | |
310 | } | |
311 | switch (port_mode[1]) { | |
312 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: | |
313 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: | |
314 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: | |
315 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: | |
316 | omap_mux_init_signal("mm2_rxdp", | |
317 | OMAP_PIN_INPUT_PULLDOWN); | |
318 | omap_mux_init_signal("mm2_rxdm", | |
319 | OMAP_PIN_INPUT_PULLDOWN); | |
320 | /* FALLTHROUGH */ | |
321 | case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: | |
322 | case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: | |
323 | omap_mux_init_signal("mm2_rxrcv", | |
324 | OMAP_PIN_INPUT_PULLDOWN); | |
325 | /* FALLTHROUGH */ | |
326 | case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: | |
327 | case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: | |
328 | omap_mux_init_signal("mm2_txen_n", OMAP_PIN_OUTPUT); | |
329 | /* FALLTHROUGH */ | |
330 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: | |
331 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: | |
332 | omap_mux_init_signal("mm2_txse0", | |
333 | OMAP_PIN_INPUT_PULLDOWN); | |
334 | omap_mux_init_signal("mm2_txdat", | |
335 | OMAP_PIN_INPUT_PULLDOWN); | |
336 | break; | |
337 | case OMAP_OHCI_PORT_MODE_UNUSED: | |
338 | /* FALLTHROUGH */ | |
339 | default: | |
340 | break; | |
341 | } | |
342 | switch (port_mode[2]) { | |
343 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: | |
344 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: | |
345 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: | |
346 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: | |
347 | omap_mux_init_signal("mm3_rxdp", | |
348 | OMAP_PIN_INPUT_PULLDOWN); | |
349 | omap_mux_init_signal("mm3_rxdm", | |
350 | OMAP_PIN_INPUT_PULLDOWN); | |
351 | /* FALLTHROUGH */ | |
352 | case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: | |
353 | case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: | |
354 | omap_mux_init_signal("mm3_rxrcv", | |
355 | OMAP_PIN_INPUT_PULLDOWN); | |
356 | /* FALLTHROUGH */ | |
357 | case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: | |
358 | case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: | |
359 | omap_mux_init_signal("mm3_txen_n", OMAP_PIN_OUTPUT); | |
360 | /* FALLTHROUGH */ | |
361 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: | |
362 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: | |
363 | omap_mux_init_signal("mm3_txse0", | |
364 | OMAP_PIN_INPUT_PULLDOWN); | |
365 | omap_mux_init_signal("mm3_txdat", | |
366 | OMAP_PIN_INPUT_PULLDOWN); | |
367 | break; | |
368 | case OMAP_OHCI_PORT_MODE_UNUSED: | |
369 | /* FALLTHROUGH */ | |
370 | default: | |
371 | break; | |
372 | } | |
373 | } | |
374 | ||
375 | void __init usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata) | |
376 | { | |
377 | platform_device_add_data(&ohci_device, pdata, sizeof(*pdata)); | |
378 | ||
379 | /* Setup Pin IO MUX for OHCI */ | |
380 | if (cpu_is_omap34xx()) | |
381 | setup_ohci_io_mux(pdata->port_mode); | |
382 | ||
383 | if (platform_device_register(&ohci_device) < 0) { | |
384 | pr_err("Unable to register FS-USB (OHCI) device\n"); | |
385 | return; | |
386 | } | |
387 | } | |
388 | ||
389 | #else | |
390 | ||
391 | void __init usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata) | |
392 | { | |
393 | } | |
394 | ||
395 | #endif /* CONFIG_USB_OHCI_HCD */ |