blob: 4fe67129643d31e51354edf006ff1a1302f8628f [file] [log] [blame]
Felipe Balbi58a54912009-11-22 10:11:01 -08001/*
Felipe Balbia8480ea2011-03-01 20:08:15 +05302 * usb-host.c - OMAP USB Host
Felipe Balbi58a54912009-11-22 10:11:01 -08003 *
4 * This file will contain the board specific details for the
Felipe Balbia8480ea2011-03-01 20:08:15 +05305 * Synopsys EHCI/OHCI host controller on OMAP3430 and onwards
Felipe Balbi58a54912009-11-22 10:11:01 -08006 *
Felipe Balbia8480ea2011-03-01 20:08:15 +05307 * Copyright (C) 2007-2011 Texas Instruments
Felipe Balbi58a54912009-11-22 10:11:01 -08008 * Author: Vikram Pandita <vikram.pandita@ti.com>
Keshava Munegowda22363962011-03-01 20:08:18 +05309 * Author: Keshava Munegowda <keshava_mgowda@ti.com>
Felipe Balbi58a54912009-11-22 10:11:01 -080010 *
11 * Generalization by:
Felipe Balbia8480ea2011-03-01 20:08:15 +053012 * Felipe Balbi <balbi@ti.com>
Felipe Balbi58a54912009-11-22 10:11:01 -080013 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 */
18
19#include <linux/types.h>
20#include <linux/errno.h>
21#include <linux/delay.h>
22#include <linux/platform_device.h>
Keshava Munegowda22363962011-03-01 20:08:18 +053023#include <linux/slab.h>
Amit Kucheriabfb01192010-06-09 13:53:05 +030024#include <linux/dma-mapping.h>
25
Felipe Balbi58a54912009-11-22 10:11:01 -080026#include <asm/io.h>
Felipe Balbi58a54912009-11-22 10:11:01 -080027
Felipe Balbi58a54912009-11-22 10:11:01 -080028#include <plat/usb.h>
Tony Lindgrene4c060d2012-10-05 13:25:59 -070029#include "soc.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070030#include "omap_device.h"
Felipe Balbi58a54912009-11-22 10:11:01 -080031
Tony Lindgren4896e392009-12-11 16:16:32 -080032#include "mux.h"
33
Keshava Munegowda22363962011-03-01 20:08:18 +053034#ifdef CONFIG_MFD_OMAP_USB_HOST
Felipe Balbi58a54912009-11-22 10:11:01 -080035
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +053036#define OMAP_USBHS_DEVICE "usbhs_omap"
Keshava Munegowda760189b2012-07-16 19:01:10 +053037#define OMAP_USBTLL_DEVICE "usbhs_tll"
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +053038#define USBHS_UHH_HWMODNAME "usb_host_hs"
39#define USBHS_TLL_HWMODNAME "usb_tll_hs"
Felipe Balbi58a54912009-11-22 10:11:01 -080040
Keshava Munegowda3b68ae72011-03-01 20:08:20 +053041static struct usbhs_omap_platform_data usbhs_data;
Keshava Munegowda760189b2012-07-16 19:01:10 +053042static struct usbtll_omap_platform_data usbtll_data;
Keshava Munegowda3b68ae72011-03-01 20:08:20 +053043static struct ehci_hcd_omap_platform_data ehci_data;
44static struct ohci_hcd_omap_platform_data ohci_data;
45
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +053046static struct omap_device_pm_latency omap_uhhtll_latency[] = {
47 {
48 .deactivate_func = omap_device_idle_hwmods,
49 .activate_func = omap_device_enable_hwmods,
50 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
51 },
52};
53
Felipe Balbi58a54912009-11-22 10:11:01 -080054/* MUX settings for EHCI pins */
55/*
56 * setup_ehci_io_mux - initialize IO pad mux for USBHOST
57 */
Igor Grinberg1512f0d2012-03-26 16:51:10 +020058static void __init setup_ehci_io_mux(const enum usbhs_omap_port_mode *port_mode)
Felipe Balbi58a54912009-11-22 10:11:01 -080059{
60 switch (port_mode[0]) {
Keshava Munegowda181b2502011-03-01 20:08:16 +053061 case OMAP_EHCI_PORT_MODE_PHY:
Tony Lindgren4896e392009-12-11 16:16:32 -080062 omap_mux_init_signal("hsusb1_stp", OMAP_PIN_OUTPUT);
63 omap_mux_init_signal("hsusb1_clk", OMAP_PIN_OUTPUT);
64 omap_mux_init_signal("hsusb1_dir", OMAP_PIN_INPUT_PULLDOWN);
65 omap_mux_init_signal("hsusb1_nxt", OMAP_PIN_INPUT_PULLDOWN);
66 omap_mux_init_signal("hsusb1_data0", OMAP_PIN_INPUT_PULLDOWN);
67 omap_mux_init_signal("hsusb1_data1", OMAP_PIN_INPUT_PULLDOWN);
68 omap_mux_init_signal("hsusb1_data2", OMAP_PIN_INPUT_PULLDOWN);
69 omap_mux_init_signal("hsusb1_data3", OMAP_PIN_INPUT_PULLDOWN);
70 omap_mux_init_signal("hsusb1_data4", OMAP_PIN_INPUT_PULLDOWN);
71 omap_mux_init_signal("hsusb1_data5", OMAP_PIN_INPUT_PULLDOWN);
72 omap_mux_init_signal("hsusb1_data6", OMAP_PIN_INPUT_PULLDOWN);
73 omap_mux_init_signal("hsusb1_data7", OMAP_PIN_INPUT_PULLDOWN);
Felipe Balbi58a54912009-11-22 10:11:01 -080074 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +053075 case OMAP_EHCI_PORT_MODE_TLL:
Tony Lindgren4896e392009-12-11 16:16:32 -080076 omap_mux_init_signal("hsusb1_tll_stp",
77 OMAP_PIN_INPUT_PULLUP);
78 omap_mux_init_signal("hsusb1_tll_clk",
79 OMAP_PIN_INPUT_PULLDOWN);
80 omap_mux_init_signal("hsusb1_tll_dir",
81 OMAP_PIN_INPUT_PULLDOWN);
82 omap_mux_init_signal("hsusb1_tll_nxt",
83 OMAP_PIN_INPUT_PULLDOWN);
84 omap_mux_init_signal("hsusb1_tll_data0",
85 OMAP_PIN_INPUT_PULLDOWN);
86 omap_mux_init_signal("hsusb1_tll_data1",
87 OMAP_PIN_INPUT_PULLDOWN);
88 omap_mux_init_signal("hsusb1_tll_data2",
89 OMAP_PIN_INPUT_PULLDOWN);
90 omap_mux_init_signal("hsusb1_tll_data3",
91 OMAP_PIN_INPUT_PULLDOWN);
92 omap_mux_init_signal("hsusb1_tll_data4",
93 OMAP_PIN_INPUT_PULLDOWN);
94 omap_mux_init_signal("hsusb1_tll_data5",
95 OMAP_PIN_INPUT_PULLDOWN);
96 omap_mux_init_signal("hsusb1_tll_data6",
97 OMAP_PIN_INPUT_PULLDOWN);
98 omap_mux_init_signal("hsusb1_tll_data7",
99 OMAP_PIN_INPUT_PULLDOWN);
Felipe Balbi58a54912009-11-22 10:11:01 -0800100 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530101 case OMAP_USBHS_PORT_MODE_UNUSED:
Felipe Balbi58a54912009-11-22 10:11:01 -0800102 /* FALLTHROUGH */
103 default:
104 break;
105 }
106
107 switch (port_mode[1]) {
Keshava Munegowda181b2502011-03-01 20:08:16 +0530108 case OMAP_EHCI_PORT_MODE_PHY:
Tony Lindgren4896e392009-12-11 16:16:32 -0800109 omap_mux_init_signal("hsusb2_stp", OMAP_PIN_OUTPUT);
110 omap_mux_init_signal("hsusb2_clk", OMAP_PIN_OUTPUT);
111 omap_mux_init_signal("hsusb2_dir", OMAP_PIN_INPUT_PULLDOWN);
112 omap_mux_init_signal("hsusb2_nxt", OMAP_PIN_INPUT_PULLDOWN);
113 omap_mux_init_signal("hsusb2_data0",
114 OMAP_PIN_INPUT_PULLDOWN);
115 omap_mux_init_signal("hsusb2_data1",
116 OMAP_PIN_INPUT_PULLDOWN);
117 omap_mux_init_signal("hsusb2_data2",
118 OMAP_PIN_INPUT_PULLDOWN);
119 omap_mux_init_signal("hsusb2_data3",
120 OMAP_PIN_INPUT_PULLDOWN);
121 omap_mux_init_signal("hsusb2_data4",
122 OMAP_PIN_INPUT_PULLDOWN);
123 omap_mux_init_signal("hsusb2_data5",
124 OMAP_PIN_INPUT_PULLDOWN);
125 omap_mux_init_signal("hsusb2_data6",
126 OMAP_PIN_INPUT_PULLDOWN);
127 omap_mux_init_signal("hsusb2_data7",
128 OMAP_PIN_INPUT_PULLDOWN);
Felipe Balbi58a54912009-11-22 10:11:01 -0800129 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530130 case OMAP_EHCI_PORT_MODE_TLL:
Tony Lindgren4896e392009-12-11 16:16:32 -0800131 omap_mux_init_signal("hsusb2_tll_stp",
132 OMAP_PIN_INPUT_PULLUP);
133 omap_mux_init_signal("hsusb2_tll_clk",
134 OMAP_PIN_INPUT_PULLDOWN);
135 omap_mux_init_signal("hsusb2_tll_dir",
136 OMAP_PIN_INPUT_PULLDOWN);
137 omap_mux_init_signal("hsusb2_tll_nxt",
138 OMAP_PIN_INPUT_PULLDOWN);
139 omap_mux_init_signal("hsusb2_tll_data0",
140 OMAP_PIN_INPUT_PULLDOWN);
141 omap_mux_init_signal("hsusb2_tll_data1",
142 OMAP_PIN_INPUT_PULLDOWN);
143 omap_mux_init_signal("hsusb2_tll_data2",
144 OMAP_PIN_INPUT_PULLDOWN);
145 omap_mux_init_signal("hsusb2_tll_data3",
146 OMAP_PIN_INPUT_PULLDOWN);
147 omap_mux_init_signal("hsusb2_tll_data4",
148 OMAP_PIN_INPUT_PULLDOWN);
149 omap_mux_init_signal("hsusb2_tll_data5",
150 OMAP_PIN_INPUT_PULLDOWN);
151 omap_mux_init_signal("hsusb2_tll_data6",
152 OMAP_PIN_INPUT_PULLDOWN);
153 omap_mux_init_signal("hsusb2_tll_data7",
154 OMAP_PIN_INPUT_PULLDOWN);
Felipe Balbi58a54912009-11-22 10:11:01 -0800155 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530156 case OMAP_USBHS_PORT_MODE_UNUSED:
Felipe Balbi58a54912009-11-22 10:11:01 -0800157 /* FALLTHROUGH */
158 default:
159 break;
160 }
161
162 switch (port_mode[2]) {
Keshava Munegowda181b2502011-03-01 20:08:16 +0530163 case OMAP_EHCI_PORT_MODE_PHY:
Felipe Balbi58a54912009-11-22 10:11:01 -0800164 printk(KERN_WARNING "Port3 can't be used in PHY mode\n");
165 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530166 case OMAP_EHCI_PORT_MODE_TLL:
Tony Lindgren4896e392009-12-11 16:16:32 -0800167 omap_mux_init_signal("hsusb3_tll_stp",
168 OMAP_PIN_INPUT_PULLUP);
169 omap_mux_init_signal("hsusb3_tll_clk",
170 OMAP_PIN_INPUT_PULLDOWN);
171 omap_mux_init_signal("hsusb3_tll_dir",
172 OMAP_PIN_INPUT_PULLDOWN);
173 omap_mux_init_signal("hsusb3_tll_nxt",
174 OMAP_PIN_INPUT_PULLDOWN);
175 omap_mux_init_signal("hsusb3_tll_data0",
176 OMAP_PIN_INPUT_PULLDOWN);
177 omap_mux_init_signal("hsusb3_tll_data1",
178 OMAP_PIN_INPUT_PULLDOWN);
179 omap_mux_init_signal("hsusb3_tll_data2",
180 OMAP_PIN_INPUT_PULLDOWN);
181 omap_mux_init_signal("hsusb3_tll_data3",
182 OMAP_PIN_INPUT_PULLDOWN);
183 omap_mux_init_signal("hsusb3_tll_data4",
184 OMAP_PIN_INPUT_PULLDOWN);
185 omap_mux_init_signal("hsusb3_tll_data5",
186 OMAP_PIN_INPUT_PULLDOWN);
187 omap_mux_init_signal("hsusb3_tll_data6",
188 OMAP_PIN_INPUT_PULLDOWN);
189 omap_mux_init_signal("hsusb3_tll_data7",
190 OMAP_PIN_INPUT_PULLDOWN);
Felipe Balbi58a54912009-11-22 10:11:01 -0800191 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530192 case OMAP_USBHS_PORT_MODE_UNUSED:
Felipe Balbi58a54912009-11-22 10:11:01 -0800193 /* FALLTHROUGH */
194 default:
195 break;
196 }
197
198 return;
199}
200
Igor Grinberg1512f0d2012-03-26 16:51:10 +0200201static
202void __init setup_4430ehci_io_mux(const enum usbhs_omap_port_mode *port_mode)
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530203{
204 switch (port_mode[0]) {
Keshava Munegowda181b2502011-03-01 20:08:16 +0530205 case OMAP_EHCI_PORT_MODE_PHY:
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530206 omap_mux_init_signal("usbb1_ulpiphy_stp",
207 OMAP_PIN_OUTPUT);
208 omap_mux_init_signal("usbb1_ulpiphy_clk",
209 OMAP_PIN_INPUT_PULLDOWN);
210 omap_mux_init_signal("usbb1_ulpiphy_dir",
211 OMAP_PIN_INPUT_PULLDOWN);
212 omap_mux_init_signal("usbb1_ulpiphy_nxt",
213 OMAP_PIN_INPUT_PULLDOWN);
214 omap_mux_init_signal("usbb1_ulpiphy_dat0",
215 OMAP_PIN_INPUT_PULLDOWN);
216 omap_mux_init_signal("usbb1_ulpiphy_dat1",
217 OMAP_PIN_INPUT_PULLDOWN);
218 omap_mux_init_signal("usbb1_ulpiphy_dat2",
219 OMAP_PIN_INPUT_PULLDOWN);
220 omap_mux_init_signal("usbb1_ulpiphy_dat3",
221 OMAP_PIN_INPUT_PULLDOWN);
222 omap_mux_init_signal("usbb1_ulpiphy_dat4",
223 OMAP_PIN_INPUT_PULLDOWN);
224 omap_mux_init_signal("usbb1_ulpiphy_dat5",
225 OMAP_PIN_INPUT_PULLDOWN);
226 omap_mux_init_signal("usbb1_ulpiphy_dat6",
227 OMAP_PIN_INPUT_PULLDOWN);
228 omap_mux_init_signal("usbb1_ulpiphy_dat7",
229 OMAP_PIN_INPUT_PULLDOWN);
230 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530231 case OMAP_EHCI_PORT_MODE_TLL:
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530232 omap_mux_init_signal("usbb1_ulpitll_stp",
233 OMAP_PIN_INPUT_PULLUP);
234 omap_mux_init_signal("usbb1_ulpitll_clk",
235 OMAP_PIN_INPUT_PULLDOWN);
236 omap_mux_init_signal("usbb1_ulpitll_dir",
237 OMAP_PIN_INPUT_PULLDOWN);
238 omap_mux_init_signal("usbb1_ulpitll_nxt",
239 OMAP_PIN_INPUT_PULLDOWN);
240 omap_mux_init_signal("usbb1_ulpitll_dat0",
241 OMAP_PIN_INPUT_PULLDOWN);
242 omap_mux_init_signal("usbb1_ulpitll_dat1",
243 OMAP_PIN_INPUT_PULLDOWN);
244 omap_mux_init_signal("usbb1_ulpitll_dat2",
245 OMAP_PIN_INPUT_PULLDOWN);
246 omap_mux_init_signal("usbb1_ulpitll_dat3",
247 OMAP_PIN_INPUT_PULLDOWN);
248 omap_mux_init_signal("usbb1_ulpitll_dat4",
249 OMAP_PIN_INPUT_PULLDOWN);
250 omap_mux_init_signal("usbb1_ulpitll_dat5",
251 OMAP_PIN_INPUT_PULLDOWN);
252 omap_mux_init_signal("usbb1_ulpitll_dat6",
253 OMAP_PIN_INPUT_PULLDOWN);
254 omap_mux_init_signal("usbb1_ulpitll_dat7",
255 OMAP_PIN_INPUT_PULLDOWN);
256 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530257 case OMAP_USBHS_PORT_MODE_UNUSED:
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530258 default:
259 break;
260 }
261 switch (port_mode[1]) {
Keshava Munegowda181b2502011-03-01 20:08:16 +0530262 case OMAP_EHCI_PORT_MODE_PHY:
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530263 omap_mux_init_signal("usbb2_ulpiphy_stp",
264 OMAP_PIN_OUTPUT);
265 omap_mux_init_signal("usbb2_ulpiphy_clk",
266 OMAP_PIN_INPUT_PULLDOWN);
267 omap_mux_init_signal("usbb2_ulpiphy_dir",
268 OMAP_PIN_INPUT_PULLDOWN);
269 omap_mux_init_signal("usbb2_ulpiphy_nxt",
270 OMAP_PIN_INPUT_PULLDOWN);
271 omap_mux_init_signal("usbb2_ulpiphy_dat0",
272 OMAP_PIN_INPUT_PULLDOWN);
273 omap_mux_init_signal("usbb2_ulpiphy_dat1",
274 OMAP_PIN_INPUT_PULLDOWN);
275 omap_mux_init_signal("usbb2_ulpiphy_dat2",
276 OMAP_PIN_INPUT_PULLDOWN);
277 omap_mux_init_signal("usbb2_ulpiphy_dat3",
278 OMAP_PIN_INPUT_PULLDOWN);
279 omap_mux_init_signal("usbb2_ulpiphy_dat4",
280 OMAP_PIN_INPUT_PULLDOWN);
281 omap_mux_init_signal("usbb2_ulpiphy_dat5",
282 OMAP_PIN_INPUT_PULLDOWN);
283 omap_mux_init_signal("usbb2_ulpiphy_dat6",
284 OMAP_PIN_INPUT_PULLDOWN);
285 omap_mux_init_signal("usbb2_ulpiphy_dat7",
286 OMAP_PIN_INPUT_PULLDOWN);
287 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530288 case OMAP_EHCI_PORT_MODE_TLL:
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530289 omap_mux_init_signal("usbb2_ulpitll_stp",
290 OMAP_PIN_INPUT_PULLUP);
291 omap_mux_init_signal("usbb2_ulpitll_clk",
292 OMAP_PIN_INPUT_PULLDOWN);
293 omap_mux_init_signal("usbb2_ulpitll_dir",
294 OMAP_PIN_INPUT_PULLDOWN);
295 omap_mux_init_signal("usbb2_ulpitll_nxt",
296 OMAP_PIN_INPUT_PULLDOWN);
297 omap_mux_init_signal("usbb2_ulpitll_dat0",
298 OMAP_PIN_INPUT_PULLDOWN);
299 omap_mux_init_signal("usbb2_ulpitll_dat1",
300 OMAP_PIN_INPUT_PULLDOWN);
301 omap_mux_init_signal("usbb2_ulpitll_dat2",
302 OMAP_PIN_INPUT_PULLDOWN);
303 omap_mux_init_signal("usbb2_ulpitll_dat3",
304 OMAP_PIN_INPUT_PULLDOWN);
305 omap_mux_init_signal("usbb2_ulpitll_dat4",
306 OMAP_PIN_INPUT_PULLDOWN);
307 omap_mux_init_signal("usbb2_ulpitll_dat5",
308 OMAP_PIN_INPUT_PULLDOWN);
309 omap_mux_init_signal("usbb2_ulpitll_dat6",
310 OMAP_PIN_INPUT_PULLDOWN);
311 omap_mux_init_signal("usbb2_ulpitll_dat7",
312 OMAP_PIN_INPUT_PULLDOWN);
313 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530314 case OMAP_USBHS_PORT_MODE_UNUSED:
Anand Gadiyarbecf0732010-11-21 23:23:41 +0530315 default:
316 break;
317 }
318}
319
Igor Grinberg1512f0d2012-03-26 16:51:10 +0200320static void __init setup_ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
Anand Gadiyar95344fc2010-05-10 21:56:10 +0530321{
322 switch (port_mode[0]) {
323 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
324 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
325 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
326 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
327 omap_mux_init_signal("mm1_rxdp",
328 OMAP_PIN_INPUT_PULLDOWN);
329 omap_mux_init_signal("mm1_rxdm",
330 OMAP_PIN_INPUT_PULLDOWN);
331 /* FALLTHROUGH */
332 case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
333 case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
334 omap_mux_init_signal("mm1_rxrcv",
335 OMAP_PIN_INPUT_PULLDOWN);
336 /* FALLTHROUGH */
337 case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
338 case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
339 omap_mux_init_signal("mm1_txen_n", OMAP_PIN_OUTPUT);
340 /* FALLTHROUGH */
341 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
342 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
343 omap_mux_init_signal("mm1_txse0",
344 OMAP_PIN_INPUT_PULLDOWN);
345 omap_mux_init_signal("mm1_txdat",
346 OMAP_PIN_INPUT_PULLDOWN);
347 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530348 case OMAP_USBHS_PORT_MODE_UNUSED:
Anand Gadiyar95344fc2010-05-10 21:56:10 +0530349 /* FALLTHROUGH */
350 default:
351 break;
352 }
353 switch (port_mode[1]) {
354 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
355 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
356 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
357 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
358 omap_mux_init_signal("mm2_rxdp",
359 OMAP_PIN_INPUT_PULLDOWN);
360 omap_mux_init_signal("mm2_rxdm",
361 OMAP_PIN_INPUT_PULLDOWN);
362 /* FALLTHROUGH */
363 case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
364 case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
365 omap_mux_init_signal("mm2_rxrcv",
366 OMAP_PIN_INPUT_PULLDOWN);
367 /* FALLTHROUGH */
368 case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
369 case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
370 omap_mux_init_signal("mm2_txen_n", OMAP_PIN_OUTPUT);
371 /* FALLTHROUGH */
372 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
373 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
374 omap_mux_init_signal("mm2_txse0",
375 OMAP_PIN_INPUT_PULLDOWN);
376 omap_mux_init_signal("mm2_txdat",
377 OMAP_PIN_INPUT_PULLDOWN);
378 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530379 case OMAP_USBHS_PORT_MODE_UNUSED:
Anand Gadiyar95344fc2010-05-10 21:56:10 +0530380 /* FALLTHROUGH */
381 default:
382 break;
383 }
384 switch (port_mode[2]) {
385 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
386 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
387 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
388 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
389 omap_mux_init_signal("mm3_rxdp",
390 OMAP_PIN_INPUT_PULLDOWN);
391 omap_mux_init_signal("mm3_rxdm",
392 OMAP_PIN_INPUT_PULLDOWN);
393 /* FALLTHROUGH */
394 case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
395 case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
396 omap_mux_init_signal("mm3_rxrcv",
397 OMAP_PIN_INPUT_PULLDOWN);
398 /* FALLTHROUGH */
399 case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
400 case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
401 omap_mux_init_signal("mm3_txen_n", OMAP_PIN_OUTPUT);
402 /* FALLTHROUGH */
403 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
404 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
405 omap_mux_init_signal("mm3_txse0",
406 OMAP_PIN_INPUT_PULLDOWN);
407 omap_mux_init_signal("mm3_txdat",
408 OMAP_PIN_INPUT_PULLDOWN);
409 break;
Keshava Munegowda181b2502011-03-01 20:08:16 +0530410 case OMAP_USBHS_PORT_MODE_UNUSED:
Anand Gadiyar95344fc2010-05-10 21:56:10 +0530411 /* FALLTHROUGH */
412 default:
413 break;
414 }
415}
416
Igor Grinberg1512f0d2012-03-26 16:51:10 +0200417static
418void __init setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
Keshava Munegowda22363962011-03-01 20:08:18 +0530419{
420 switch (port_mode[0]) {
421 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
422 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
423 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
424 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
425 omap_mux_init_signal("usbb1_mm_rxdp",
426 OMAP_PIN_INPUT_PULLDOWN);
427 omap_mux_init_signal("usbb1_mm_rxdm",
428 OMAP_PIN_INPUT_PULLDOWN);
429
430 case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
431 case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
432 omap_mux_init_signal("usbb1_mm_rxrcv",
433 OMAP_PIN_INPUT_PULLDOWN);
434
435 case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
436 case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
437 omap_mux_init_signal("usbb1_mm_txen",
438 OMAP_PIN_INPUT_PULLDOWN);
439
440
441 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
442 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
443 omap_mux_init_signal("usbb1_mm_txdat",
444 OMAP_PIN_INPUT_PULLDOWN);
445 omap_mux_init_signal("usbb1_mm_txse0",
446 OMAP_PIN_INPUT_PULLDOWN);
447 break;
448
449 case OMAP_USBHS_PORT_MODE_UNUSED:
450 default:
451 break;
452 }
453
454 switch (port_mode[1]) {
455 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
456 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
457 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
458 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
459 omap_mux_init_signal("usbb2_mm_rxdp",
460 OMAP_PIN_INPUT_PULLDOWN);
461 omap_mux_init_signal("usbb2_mm_rxdm",
462 OMAP_PIN_INPUT_PULLDOWN);
463
464 case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
465 case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
466 omap_mux_init_signal("usbb2_mm_rxrcv",
467 OMAP_PIN_INPUT_PULLDOWN);
468
469 case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
470 case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
471 omap_mux_init_signal("usbb2_mm_txen",
472 OMAP_PIN_INPUT_PULLDOWN);
473
474
475 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
476 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
477 omap_mux_init_signal("usbb2_mm_txdat",
478 OMAP_PIN_INPUT_PULLDOWN);
479 omap_mux_init_signal("usbb2_mm_txse0",
480 OMAP_PIN_INPUT_PULLDOWN);
481 break;
482
483 case OMAP_USBHS_PORT_MODE_UNUSED:
484 default:
485 break;
486 }
487}
488
Keshava Munegowda22363962011-03-01 20:08:18 +0530489void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
490{
Keshava Munegowda760189b2012-07-16 19:01:10 +0530491 struct omap_hwmod *uhh_hwm, *tll_hwm;
Felipe Balbiabe763f2012-02-14 10:54:46 +0200492 struct platform_device *pdev;
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +0530493 int bus_id = -1;
494 int i;
Keshava Munegowda22363962011-03-01 20:08:18 +0530495
496 for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
497 usbhs_data.port_mode[i] = pdata->port_mode[i];
Keshava Munegowda760189b2012-07-16 19:01:10 +0530498 usbtll_data.port_mode[i] = pdata->port_mode[i];
Keshava Munegowda22363962011-03-01 20:08:18 +0530499 ohci_data.port_mode[i] = pdata->port_mode[i];
500 ehci_data.port_mode[i] = pdata->port_mode[i];
501 ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i];
502 ehci_data.regulator[i] = pdata->regulator[i];
503 }
504 ehci_data.phy_reset = pdata->phy_reset;
505 ohci_data.es2_compatibility = pdata->es2_compatibility;
506 usbhs_data.ehci_data = &ehci_data;
507 usbhs_data.ohci_data = &ohci_data;
508
509 if (cpu_is_omap34xx()) {
Keshava Munegowda22363962011-03-01 20:08:18 +0530510 setup_ehci_io_mux(pdata->port_mode);
511 setup_ohci_io_mux(pdata->port_mode);
512 } else if (cpu_is_omap44xx()) {
Keshava Munegowda22363962011-03-01 20:08:18 +0530513 setup_4430ehci_io_mux(pdata->port_mode);
514 setup_4430ohci_io_mux(pdata->port_mode);
515 }
516
Keshava Munegowda760189b2012-07-16 19:01:10 +0530517 uhh_hwm = omap_hwmod_lookup(USBHS_UHH_HWMODNAME);
518 if (!uhh_hwm) {
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +0530519 pr_err("Could not look up %s\n", USBHS_UHH_HWMODNAME);
520 return;
Keshava Munegowda22363962011-03-01 20:08:18 +0530521 }
522
Keshava Munegowda760189b2012-07-16 19:01:10 +0530523 tll_hwm = omap_hwmod_lookup(USBHS_TLL_HWMODNAME);
524 if (!tll_hwm) {
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +0530525 pr_err("Could not look up %s\n", USBHS_TLL_HWMODNAME);
526 return;
527 }
Keshava Munegowda22363962011-03-01 20:08:18 +0530528
Keshava Munegowda760189b2012-07-16 19:01:10 +0530529 pdev = omap_device_build(OMAP_USBTLL_DEVICE, bus_id, tll_hwm,
530 &usbtll_data, sizeof(usbtll_data),
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +0530531 omap_uhhtll_latency,
532 ARRAY_SIZE(omap_uhhtll_latency), false);
Felipe Balbiabe763f2012-02-14 10:54:46 +0200533 if (IS_ERR(pdev)) {
Keshava Munegowda760189b2012-07-16 19:01:10 +0530534 pr_err("Could not build hwmod device %s\n",
535 USBHS_TLL_HWMODNAME);
536 return;
537 }
538
539 pdev = omap_device_build(OMAP_USBHS_DEVICE, bus_id, uhh_hwm,
540 &usbhs_data, sizeof(usbhs_data),
541 omap_uhhtll_latency,
542 ARRAY_SIZE(omap_uhhtll_latency), false);
543 if (IS_ERR(pdev)) {
544 pr_err("Could not build hwmod devices %s\n",
545 USBHS_UHH_HWMODNAME);
Keshava Munegowda50b2a9b2011-10-11 13:21:37 +0530546 return;
547 }
Keshava Munegowda22363962011-03-01 20:08:18 +0530548}
549
Anand Gadiyar95344fc2010-05-10 21:56:10 +0530550#else
551
Keshava Munegowda22363962011-03-01 20:08:18 +0530552void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
553{
554}
555
Keshava Munegowda22363962011-03-01 20:08:18 +0530556#endif