2 * linux/arch/arm/mach-omap2/usb-ehci.c
4 * This file will contain the board specific details for the
5 * Synopsys EHCI host controller on OMAP3430
7 * Copyright (C) 2007 Texas Instruments
8 * Author: Vikram Pandita <vikram.pandita@ti.com>
11 * Felipe Balbi <felipe.balbi@nokia.com>
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.
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>
23 #include <linux/dma-mapping.h>
28 #include <mach/hardware.h>
29 #include <mach/irqs.h>
34 #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
36 static struct resource ehci_resources[] = {
38 .start = OMAP34XX_EHCI_BASE,
39 .end = OMAP34XX_EHCI_BASE + SZ_1K - 1,
40 .flags = IORESOURCE_MEM,
43 .start = OMAP34XX_UHH_CONFIG_BASE,
44 .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1,
45 .flags = IORESOURCE_MEM,
48 .start = OMAP34XX_USBTLL_BASE,
49 .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1,
50 .flags = IORESOURCE_MEM,
53 .start = INT_34XX_EHCI_IRQ,
54 .flags = IORESOURCE_IRQ,
58 static u64 ehci_dmamask = ~(u32)0;
59 static struct platform_device ehci_device = {
63 .dma_mask = &ehci_dmamask,
64 .coherent_dma_mask = 0xffffffff,
65 .platform_data = NULL,
67 .num_resources = ARRAY_SIZE(ehci_resources),
68 .resource = ehci_resources,
71 /* MUX settings for EHCI pins */
73 * setup_ehci_io_mux - initialize IO pad mux for USBHOST
75 static void setup_ehci_io_mux(const enum ehci_hcd_omap_mode *port_mode)
77 switch (port_mode[0]) {
78 case EHCI_HCD_OMAP_MODE_PHY:
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);
92 case EHCI_HCD_OMAP_MODE_TLL:
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);
118 case EHCI_HCD_OMAP_MODE_UNKNOWN:
124 switch (port_mode[1]) {
125 case EHCI_HCD_OMAP_MODE_PHY:
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);
147 case EHCI_HCD_OMAP_MODE_TLL:
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);
173 case EHCI_HCD_OMAP_MODE_UNKNOWN:
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");
183 case EHCI_HCD_OMAP_MODE_TLL:
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);
209 case EHCI_HCD_OMAP_MODE_UNKNOWN:
218 void __init usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata)
220 platform_device_add_data(&ehci_device, pdata, sizeof(*pdata));
222 /* Setup Pin IO MUX for EHCI */
223 if (cpu_is_omap34xx())
224 setup_ehci_io_mux(pdata->port_mode);
226 if (platform_device_register(&ehci_device) < 0) {
227 printk(KERN_ERR "Unable to register HS-USB (EHCI) device\n");
234 void __init usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata)
239 #endif /* CONFIG_USB_EHCI_HCD */
241 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
243 static struct resource ohci_resources[] = {
245 .start = OMAP34XX_OHCI_BASE,
246 .end = OMAP34XX_OHCI_BASE + SZ_1K - 1,
247 .flags = IORESOURCE_MEM,
250 .start = OMAP34XX_UHH_CONFIG_BASE,
251 .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1,
252 .flags = IORESOURCE_MEM,
255 .start = OMAP34XX_USBTLL_BASE,
256 .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1,
257 .flags = IORESOURCE_MEM,
260 .start = INT_34XX_OHCI_IRQ,
261 .flags = IORESOURCE_IRQ,
265 static u64 ohci_dmamask = DMA_BIT_MASK(32);
267 static struct platform_device ohci_device = {
268 .name = "ohci-omap3",
271 .dma_mask = &ohci_dmamask,
272 .coherent_dma_mask = 0xffffffff,
274 .num_resources = ARRAY_SIZE(ohci_resources),
275 .resource = ohci_resources,
278 static void setup_ohci_io_mux(const enum ohci_omap3_port_mode *port_mode)
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);
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);
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);
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);
306 case OMAP_OHCI_PORT_MODE_UNUSED:
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);
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);
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);
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);
337 case OMAP_OHCI_PORT_MODE_UNUSED:
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);
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);
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);
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);
368 case OMAP_OHCI_PORT_MODE_UNUSED:
375 void __init usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata)
377 platform_device_add_data(&ohci_device, pdata, sizeof(*pdata));
379 /* Setup Pin IO MUX for OHCI */
380 if (cpu_is_omap34xx())
381 setup_ohci_io_mux(pdata->port_mode);
383 if (platform_device_register(&ohci_device) < 0) {
384 pr_err("Unable to register FS-USB (OHCI) device\n");
391 void __init usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata)
395 #endif /* CONFIG_USB_OHCI_HCD */