blob: d3b6e9491b624a1b7860dc84392ed8b3f72e8105 [file] [log] [blame]
Keshava Munegowda17cdd292011-03-01 20:08:17 +05301/**
2 * omap-usb-host.c - The USBHS core driver for OMAP EHCI & OHCI
3 *
Roger Quadros03a8f432013-04-09 11:39:18 +03004 * Copyright (C) 2011-2013 Texas Instruments Incorporated - http://www.ti.com
Keshava Munegowda17cdd292011-03-01 20:08:17 +05305 * Author: Keshava Munegowda <keshava_mgowda@ti.com>
Roger Quadros03a8f432013-04-09 11:39:18 +03006 * Author: Roger Quadros <rogerq@ti.com>
Keshava Munegowda17cdd292011-03-01 20:08:17 +05307 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20#include <linux/kernel.h>
Ming Lei417e2062011-08-19 16:57:54 +080021#include <linux/module.h>
Keshava Munegowda17cdd292011-03-01 20:08:17 +053022#include <linux/types.h>
23#include <linux/slab.h>
24#include <linux/delay.h>
Keshava Munegowda17cdd292011-03-01 20:08:17 +053025#include <linux/clk.h>
26#include <linux/dma-mapping.h>
Russ Dillc05995c2012-06-14 09:24:21 -070027#include <linux/gpio.h>
Felipe Balbie8c4a7a2012-10-24 14:26:19 -070028#include <linux/platform_device.h>
29#include <linux/platform_data/usb-omap.h>
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +053030#include <linux/pm_runtime.h>
Roger Quadros03a8f432013-04-09 11:39:18 +030031#include <linux/of.h>
32#include <linux/of_platform.h>
Keshava Munegowda17cdd292011-03-01 20:08:17 +053033
Felipe Balbie8c4a7a2012-10-24 14:26:19 -070034#include "omap-usb.h"
35
Keshava Munegowdaa6d3a662011-10-11 13:21:51 +053036#define USBHS_DRIVER_NAME "usbhs_omap"
Keshava Munegowda17cdd292011-03-01 20:08:17 +053037#define OMAP_EHCI_DEVICE "ehci-omap"
38#define OMAP_OHCI_DEVICE "ohci-omap3"
39
40/* OMAP USBHOST Register addresses */
41
Keshava Munegowda17cdd292011-03-01 20:08:17 +053042/* UHH Register Set */
43#define OMAP_UHH_REVISION (0x00)
44#define OMAP_UHH_SYSCONFIG (0x10)
45#define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
46#define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
47#define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
48#define OMAP_UHH_SYSCONFIG_ENAWAKEUP (1 << 2)
49#define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
50#define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
51
52#define OMAP_UHH_SYSSTATUS (0x14)
53#define OMAP_UHH_HOSTCONFIG (0x40)
54#define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
55#define OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS (1 << 0)
56#define OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS (1 << 11)
57#define OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS (1 << 12)
58#define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
59#define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
60#define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
61#define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
62#define OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS (1 << 8)
63#define OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS (1 << 9)
64#define OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS (1 << 10)
65#define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1 << 31)
66
67/* OMAP4-specific defines */
68#define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3 << 2)
69#define OMAP4_UHH_SYSCONFIG_NOIDLE (1 << 2)
70#define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR (3 << 4)
71#define OMAP4_UHH_SYSCONFIG_NOSTDBY (1 << 4)
72#define OMAP4_UHH_SYSCONFIG_SOFTRESET (1 << 0)
73
74#define OMAP4_P1_MODE_CLEAR (3 << 16)
75#define OMAP4_P1_MODE_TLL (1 << 16)
76#define OMAP4_P1_MODE_HSIC (3 << 16)
77#define OMAP4_P2_MODE_CLEAR (3 << 18)
78#define OMAP4_P2_MODE_TLL (1 << 18)
79#define OMAP4_P2_MODE_HSIC (3 << 18)
80
Keshava Munegowda17cdd292011-03-01 20:08:17 +053081#define OMAP_UHH_DEBUG_CSR (0x44)
82
83/* Values of UHH_REVISION - Note: these are not given in the TRM */
84#define OMAP_USBHS_REV1 0x00000010 /* OMAP3 */
85#define OMAP_USBHS_REV2 0x50700100 /* OMAP4 */
86
87#define is_omap_usbhs_rev1(x) (x->usbhs_rev == OMAP_USBHS_REV1)
88#define is_omap_usbhs_rev2(x) (x->usbhs_rev == OMAP_USBHS_REV2)
89
90#define is_ehci_phy_mode(x) (x == OMAP_EHCI_PORT_MODE_PHY)
91#define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL)
92#define is_ehci_hsic_mode(x) (x == OMAP_EHCI_PORT_MODE_HSIC)
93
94
95struct usbhs_hcd_omap {
Roger Quadrosd7eaf862012-11-08 18:04:26 +020096 int nports;
Roger Quadros06ba7dc2012-11-08 17:40:25 +020097 struct clk **utmi_clk;
Roger Quadros340c64e2012-11-12 16:53:16 +020098 struct clk **hsic60m_clk;
99 struct clk **hsic480m_clk;
Roger Quadrosd7eaf862012-11-08 18:04:26 +0200100
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530101 struct clk *xclk60mhsp1_ck;
102 struct clk *xclk60mhsp2_ck;
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200103 struct clk *utmi_p1_gfclk;
104 struct clk *utmi_p2_gfclk;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530105 struct clk *init_60m_fclk;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530106 struct clk *ehci_logic_fck;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530107
108 void __iomem *uhh_base;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530109
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200110 struct usbhs_omap_platform_data *pdata;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530111
112 u32 usbhs_rev;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530113};
114/*-------------------------------------------------------------------------*/
115
116const char usbhs_driver_name[] = USBHS_DRIVER_NAME;
Govindraj.Rcbb8c222012-02-15 12:27:50 +0530117static u64 usbhs_dmamask = DMA_BIT_MASK(32);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530118
119/*-------------------------------------------------------------------------*/
120
121static inline void usbhs_write(void __iomem *base, u32 reg, u32 val)
122{
123 __raw_writel(val, base + reg);
124}
125
126static inline u32 usbhs_read(void __iomem *base, u32 reg)
127{
128 return __raw_readl(base + reg);
129}
130
131static inline void usbhs_writeb(void __iomem *base, u8 reg, u8 val)
132{
133 __raw_writeb(val, base + reg);
134}
135
136static inline u8 usbhs_readb(void __iomem *base, u8 reg)
137{
138 return __raw_readb(base + reg);
139}
140
141/*-------------------------------------------------------------------------*/
142
Roger Quadros03a8f432013-04-09 11:39:18 +0300143/**
144 * Map 'enum usbhs_omap_port_mode' found in <linux/platform_data/usb-omap.h>
145 * to the device tree binding portN-mode found in
146 * 'Documentation/devicetree/bindings/mfd/omap-usb-host.txt'
147 */
148static const char * const port_modes[] = {
149 [OMAP_USBHS_PORT_MODE_UNUSED] = "",
150 [OMAP_EHCI_PORT_MODE_PHY] = "ehci-phy",
151 [OMAP_EHCI_PORT_MODE_TLL] = "ehci-tll",
152 [OMAP_EHCI_PORT_MODE_HSIC] = "ehci-hsic",
153 [OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0] = "ohci-phy-6pin-datse0",
154 [OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM] = "ohci-phy-6pin-dpdm",
155 [OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0] = "ohci-phy-3pin-datse0",
156 [OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM] = "ohci-phy-4pin-dpdm",
157 [OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0] = "ohci-tll-6pin-datse0",
158 [OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM] = "ohci-tll-6pin-dpdm",
159 [OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0] = "ohci-tll-3pin-datse0",
160 [OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM] = "ohci-tll-4pin-dpdm",
161 [OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0] = "ohci-tll-2pin-datse0",
162 [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM] = "ohci-tll-2pin-dpdm",
163};
164
165/**
166 * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode'
167 * from the port mode string.
168 * @mode: The port mode string, usually obtained from device tree.
169 *
170 * The function returns the 'enum usbhs_omap_port_mode' that matches the
171 * provided port mode string as per the port_modes table.
172 * If no match is found it returns -ENODEV
173 */
174static const int omap_usbhs_get_dt_port_mode(const char *mode)
175{
176 int i;
177
178 for (i = 0; i < ARRAY_SIZE(port_modes); i++) {
179 if (!strcmp(mode, port_modes[i]))
180 return i;
181 }
182
183 return -ENODEV;
184}
185
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530186static struct platform_device *omap_usbhs_alloc_child(const char *name,
187 struct resource *res, int num_resources, void *pdata,
188 size_t pdata_size, struct device *dev)
189{
190 struct platform_device *child;
191 int ret;
192
193 child = platform_device_alloc(name, 0);
194
195 if (!child) {
196 dev_err(dev, "platform_device_alloc %s failed\n", name);
197 goto err_end;
198 }
199
200 ret = platform_device_add_resources(child, res, num_resources);
201 if (ret) {
202 dev_err(dev, "platform_device_add_resources failed\n");
203 goto err_alloc;
204 }
205
206 ret = platform_device_add_data(child, pdata, pdata_size);
207 if (ret) {
208 dev_err(dev, "platform_device_add_data failed\n");
209 goto err_alloc;
210 }
211
212 child->dev.dma_mask = &usbhs_dmamask;
Govindraj.Rcbb8c222012-02-15 12:27:50 +0530213 dma_set_coherent_mask(&child->dev, DMA_BIT_MASK(32));
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530214 child->dev.parent = dev;
215
216 ret = platform_device_add(child);
217 if (ret) {
218 dev_err(dev, "platform_device_add failed\n");
219 goto err_alloc;
220 }
221
222 return child;
223
224err_alloc:
225 platform_device_put(child);
226
227err_end:
228 return NULL;
229}
230
231static int omap_usbhs_alloc_children(struct platform_device *pdev)
232{
233 struct device *dev = &pdev->dev;
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200234 struct usbhs_omap_platform_data *pdata = dev->platform_data;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530235 struct platform_device *ehci;
236 struct platform_device *ohci;
237 struct resource *res;
238 struct resource resources[2];
239 int ret;
240
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530241 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci");
242 if (!res) {
243 dev_err(dev, "EHCI get resource IORESOURCE_MEM failed\n");
244 ret = -ENODEV;
245 goto err_end;
246 }
247 resources[0] = *res;
248
249 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "ehci-irq");
250 if (!res) {
251 dev_err(dev, " EHCI get resource IORESOURCE_IRQ failed\n");
252 ret = -ENODEV;
253 goto err_end;
254 }
255 resources[1] = *res;
256
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200257 ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, pdata,
258 sizeof(*pdata), dev);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530259
260 if (!ehci) {
261 dev_err(dev, "omap_usbhs_alloc_child failed\n");
Axel Lind9107742011-05-14 14:15:36 +0800262 ret = -ENOMEM;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530263 goto err_end;
264 }
265
266 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ohci");
267 if (!res) {
268 dev_err(dev, "OHCI get resource IORESOURCE_MEM failed\n");
269 ret = -ENODEV;
270 goto err_ehci;
271 }
272 resources[0] = *res;
273
274 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "ohci-irq");
275 if (!res) {
276 dev_err(dev, "OHCI get resource IORESOURCE_IRQ failed\n");
277 ret = -ENODEV;
278 goto err_ehci;
279 }
280 resources[1] = *res;
281
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200282 ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, pdata,
283 sizeof(*pdata), dev);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530284 if (!ohci) {
285 dev_err(dev, "omap_usbhs_alloc_child failed\n");
Axel Lind9107742011-05-14 14:15:36 +0800286 ret = -ENOMEM;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530287 goto err_ehci;
288 }
289
290 return 0;
291
292err_ehci:
Axel Lind9107742011-05-14 14:15:36 +0800293 platform_device_unregister(ehci);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530294
295err_end:
296 return ret;
297}
298
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530299static bool is_ohci_port(enum usbhs_omap_port_mode pmode)
300{
301 switch (pmode) {
302 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
303 case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
304 case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
305 case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
306 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
307 case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
308 case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
309 case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
310 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
311 case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
312 return true;
313
314 default:
315 return false;
316 }
317}
318
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530319static int usbhs_runtime_resume(struct device *dev)
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530320{
321 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200322 struct usbhs_omap_platform_data *pdata = omap->pdata;
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200323 int i, r;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530324
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530325 dev_dbg(dev, "usbhs_runtime_resume\n");
326
Roger Quadros9f4a3ec2013-01-29 15:00:03 +0200327 omap_tll_enable(pdata);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530328
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200329 if (!IS_ERR(omap->ehci_logic_fck))
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530330 clk_enable(omap->ehci_logic_fck);
331
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200332 for (i = 0; i < omap->nports; i++) {
Roger Quadros340c64e2012-11-12 16:53:16 +0200333 switch (pdata->port_mode[i]) {
334 case OMAP_EHCI_PORT_MODE_HSIC:
335 if (!IS_ERR(omap->hsic60m_clk[i])) {
336 r = clk_enable(omap->hsic60m_clk[i]);
337 if (r) {
338 dev_err(dev,
339 "Can't enable port %d hsic60m clk:%d\n",
340 i, r);
341 }
342 }
Keshava Munegowda760189b2012-07-16 19:01:10 +0530343
Roger Quadros340c64e2012-11-12 16:53:16 +0200344 if (!IS_ERR(omap->hsic480m_clk[i])) {
345 r = clk_enable(omap->hsic480m_clk[i]);
346 if (r) {
347 dev_err(dev,
348 "Can't enable port %d hsic480m clk:%d\n",
349 i, r);
350 }
351 }
352 /* Fall through as HSIC mode needs utmi_clk */
353
354 case OMAP_EHCI_PORT_MODE_TLL:
355 if (!IS_ERR(omap->utmi_clk[i])) {
356 r = clk_enable(omap->utmi_clk[i]);
357 if (r) {
358 dev_err(dev,
359 "Can't enable port %d clk : %d\n",
360 i, r);
361 }
362 }
363 break;
364 default:
365 break;
366 }
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200367 }
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530368
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530369 return 0;
370}
371
372static int usbhs_runtime_suspend(struct device *dev)
373{
374 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200375 struct usbhs_omap_platform_data *pdata = omap->pdata;
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200376 int i;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530377
378 dev_dbg(dev, "usbhs_runtime_suspend\n");
379
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200380 for (i = 0; i < omap->nports; i++) {
Roger Quadros340c64e2012-11-12 16:53:16 +0200381 switch (pdata->port_mode[i]) {
382 case OMAP_EHCI_PORT_MODE_HSIC:
383 if (!IS_ERR(omap->hsic60m_clk[i]))
384 clk_disable(omap->hsic60m_clk[i]);
385
386 if (!IS_ERR(omap->hsic480m_clk[i]))
387 clk_disable(omap->hsic480m_clk[i]);
388 /* Fall through as utmi_clks were used in HSIC mode */
389
390 case OMAP_EHCI_PORT_MODE_TLL:
391 if (!IS_ERR(omap->utmi_clk[i]))
392 clk_disable(omap->utmi_clk[i]);
393 break;
394 default:
395 break;
396 }
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200397 }
Keshava Munegowda760189b2012-07-16 19:01:10 +0530398
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200399 if (!IS_ERR(omap->ehci_logic_fck))
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530400 clk_disable(omap->ehci_logic_fck);
401
Roger Quadros9f4a3ec2013-01-29 15:00:03 +0200402 omap_tll_disable(pdata);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530403
404 return 0;
405}
406
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200407static unsigned omap_usbhs_rev1_hostconfig(struct usbhs_hcd_omap *omap,
408 unsigned reg)
409{
410 struct usbhs_omap_platform_data *pdata = omap->pdata;
411 int i;
412
413 for (i = 0; i < omap->nports; i++) {
414 switch (pdata->port_mode[i]) {
415 case OMAP_USBHS_PORT_MODE_UNUSED:
416 reg &= ~(OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS << i);
417 break;
418 case OMAP_EHCI_PORT_MODE_PHY:
419 if (pdata->single_ulpi_bypass)
420 break;
421
422 if (i == 0)
423 reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
424 else
425 reg &= ~(OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS
426 << (i-1));
427 break;
428 default:
429 if (pdata->single_ulpi_bypass)
430 break;
431
432 if (i == 0)
433 reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
434 else
435 reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS
436 << (i-1);
437 break;
438 }
439 }
440
441 if (pdata->single_ulpi_bypass) {
442 /* bypass ULPI only if none of the ports use PHY mode */
443 reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
444
445 for (i = 0; i < omap->nports; i++) {
446 if (is_ehci_phy_mode(pdata->port_mode[i])) {
447 reg &= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
448 break;
449 }
450 }
451 }
452
453 return reg;
454}
455
456static unsigned omap_usbhs_rev2_hostconfig(struct usbhs_hcd_omap *omap,
457 unsigned reg)
458{
459 struct usbhs_omap_platform_data *pdata = omap->pdata;
460 int i;
461
462 for (i = 0; i < omap->nports; i++) {
463 /* Clear port mode fields for PHY mode */
464 reg &= ~(OMAP4_P1_MODE_CLEAR << 2 * i);
465
466 if (is_ehci_tll_mode(pdata->port_mode[i]) ||
467 (is_ohci_port(pdata->port_mode[i])))
468 reg |= OMAP4_P1_MODE_TLL << 2 * i;
469 else if (is_ehci_hsic_mode(pdata->port_mode[i]))
470 reg |= OMAP4_P1_MODE_HSIC << 2 * i;
471 }
472
473 return reg;
474}
475
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530476static void omap_usbhs_init(struct device *dev)
477{
478 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530479 unsigned reg;
480
481 dev_dbg(dev, "starting TI HSUSB Controller\n");
482
Keshava Munegowda760189b2012-07-16 19:01:10 +0530483 pm_runtime_get_sync(dev);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530484
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530485 reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
486 /* setup ULPI bypass and burst configurations */
487 reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
488 | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
489 | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN);
490 reg |= OMAP4_UHH_HOSTCONFIG_APP_START_CLK;
491 reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN;
492
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200493 switch (omap->usbhs_rev) {
494 case OMAP_USBHS_REV1:
Roger Quadros26bacba2013-02-27 15:19:24 +0200495 reg = omap_usbhs_rev1_hostconfig(omap, reg);
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200496 break;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530497
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200498 case OMAP_USBHS_REV2:
Roger Quadros26bacba2013-02-27 15:19:24 +0200499 reg = omap_usbhs_rev2_hostconfig(omap, reg);
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200500 break;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530501
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200502 default: /* newer revisions */
Roger Quadros26bacba2013-02-27 15:19:24 +0200503 reg = omap_usbhs_rev2_hostconfig(omap, reg);
Roger Quadrosc4df00a2012-11-12 16:32:01 +0200504 break;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530505 }
506
507 usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
508 dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
509
Keshava Munegowda760189b2012-07-16 19:01:10 +0530510 pm_runtime_put_sync(dev);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530511}
512
Roger Quadros03a8f432013-04-09 11:39:18 +0300513static int usbhs_omap_get_dt_pdata(struct device *dev,
514 struct usbhs_omap_platform_data *pdata)
515{
516 int ret, i;
517 struct device_node *node = dev->of_node;
518
519 ret = of_property_read_u32(node, "num-ports", &pdata->nports);
520 if (ret)
521 pdata->nports = 0;
522
523 if (pdata->nports > OMAP3_HS_USB_PORTS) {
524 dev_warn(dev, "Too many num_ports <%d> in device tree. Max %d\n",
525 pdata->nports, OMAP3_HS_USB_PORTS);
526 return -ENODEV;
527 }
528
529 /* get port modes */
530 for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
531 char prop[11];
532 const char *mode;
533
534 pdata->port_mode[i] = OMAP_USBHS_PORT_MODE_UNUSED;
535
536 snprintf(prop, sizeof(prop), "port%d-mode", i + 1);
537 ret = of_property_read_string(node, prop, &mode);
538 if (ret < 0)
539 continue;
540
541 ret = omap_usbhs_get_dt_port_mode(mode);
542 if (ret < 0) {
543 dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n",
544 i, mode);
545 return -ENODEV;
546 }
547
548 dev_dbg(dev, "port%d-mode: %s -> %d\n", i, mode, ret);
549 pdata->port_mode[i] = ret;
550 }
551
552 /* get flags */
553 pdata->single_ulpi_bypass = of_property_read_bool(node,
554 "single-ulpi-bypass");
555
556 return 0;
557}
558
559static struct of_device_id usbhs_child_match_table[] = {
560 { .compatible = "ti,omap-ehci", },
561 { .compatible = "ti,omap-ohci", },
562 { }
563};
564
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530565/**
566 * usbhs_omap_probe - initialize TI-based HCDs
567 *
568 * Allocates basic resources for this USB host controller.
569 */
Bill Pembertonf791be42012-11-19 13:23:04 -0500570static int usbhs_omap_probe(struct platform_device *pdev)
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530571{
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530572 struct device *dev = &pdev->dev;
573 struct usbhs_omap_platform_data *pdata = dev->platform_data;
574 struct usbhs_hcd_omap *omap;
575 struct resource *res;
576 int ret = 0;
577 int i;
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200578 bool need_logic_fck;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530579
Roger Quadros03a8f432013-04-09 11:39:18 +0300580 if (dev->of_node) {
581 /* For DT boot we populate platform data from OF node */
582 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
583 if (!pdata)
584 return -ENOMEM;
585
586 ret = usbhs_omap_get_dt_pdata(dev, pdata);
587 if (ret)
588 return ret;
589
590 dev->platform_data = pdata;
591 }
592
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530593 if (!pdata) {
594 dev_err(dev, "Missing platform data\n");
Roger Quadros27d4f2c2012-11-26 17:59:22 +0200595 return -ENODEV;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530596 }
597
Roger Quadros03a8f432013-04-09 11:39:18 +0300598 if (pdata->nports > OMAP3_HS_USB_PORTS) {
599 dev_info(dev, "Too many num_ports <%d> in platform_data. Max %d\n",
600 pdata->nports, OMAP3_HS_USB_PORTS);
601 return -ENODEV;
602 }
603
Roger Quadros27d4f2c2012-11-26 17:59:22 +0200604 omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530605 if (!omap) {
606 dev_err(dev, "Memory allocation failed\n");
Roger Quadros27d4f2c2012-11-26 17:59:22 +0200607 return -ENOMEM;
608 }
609
Roger Quadros03a8f432013-04-09 11:39:18 +0300610 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Roger Quadros27d4f2c2012-11-26 17:59:22 +0200611 omap->uhh_base = devm_request_and_ioremap(dev, res);
612 if (!omap->uhh_base) {
613 dev_err(dev, "Resource request/ioremap failed\n");
614 return -EADDRNOTAVAIL;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530615 }
616
Roger Quadros9d9c6ae2013-02-13 13:16:25 +0200617 omap->pdata = pdata;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530618
Roger Quadros9f4a3ec2013-01-29 15:00:03 +0200619 /* Initialize the TLL subsystem */
620 omap_tll_init(pdata);
621
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530622 pm_runtime_enable(dev);
623
Roger Quadrosd7eaf862012-11-08 18:04:26 +0200624 platform_set_drvdata(pdev, omap);
625 pm_runtime_get_sync(dev);
626
627 omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
628
629 /* we need to call runtime suspend before we update omap->nports
630 * to prevent unbalanced clk_disable()
631 */
632 pm_runtime_put_sync(dev);
633
Roger Quadrosccac71a2012-11-08 19:18:08 +0200634 /*
635 * If platform data contains nports then use that
636 * else make out number of ports from USBHS revision
637 */
638 if (pdata->nports) {
639 omap->nports = pdata->nports;
640 } else {
641 switch (omap->usbhs_rev) {
642 case OMAP_USBHS_REV1:
643 omap->nports = 3;
644 break;
645 case OMAP_USBHS_REV2:
646 omap->nports = 2;
647 break;
648 default:
649 omap->nports = OMAP3_HS_USB_PORTS;
650 dev_dbg(dev,
651 "USB HOST Rev:0x%d not recognized, assuming %d ports\n",
652 omap->usbhs_rev, omap->nports);
653 break;
654 }
Roger Quadros662e4692013-01-08 16:01:52 +0200655 pdata->nports = omap->nports;
Roger Quadrosd7eaf862012-11-08 18:04:26 +0200656 }
657
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200658 i = sizeof(struct clk *) * omap->nports;
659 omap->utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
Roger Quadros340c64e2012-11-12 16:53:16 +0200660 omap->hsic480m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
661 omap->hsic60m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
662
663 if (!omap->utmi_clk || !omap->hsic480m_clk || !omap->hsic60m_clk) {
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200664 dev_err(dev, "Memory allocation failed\n");
665 ret = -ENOMEM;
666 goto err_mem;
667 }
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530668
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200669 need_logic_fck = false;
670 for (i = 0; i < omap->nports; i++) {
671 if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
672 is_ehci_hsic_mode(i))
673 need_logic_fck |= true;
674 }
675
676 omap->ehci_logic_fck = ERR_PTR(-EINVAL);
677 if (need_logic_fck) {
678 omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck");
679 if (IS_ERR(omap->ehci_logic_fck)) {
680 ret = PTR_ERR(omap->ehci_logic_fck);
681 dev_dbg(dev, "ehci_logic_fck failed:%d\n", ret);
682 }
683 }
684
685 omap->utmi_p1_gfclk = clk_get(dev, "utmi_p1_gfclk");
686 if (IS_ERR(omap->utmi_p1_gfclk)) {
687 ret = PTR_ERR(omap->utmi_p1_gfclk);
688 dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret);
689 goto err_p1_gfclk;
690 }
691
692 omap->utmi_p2_gfclk = clk_get(dev, "utmi_p2_gfclk");
693 if (IS_ERR(omap->utmi_p2_gfclk)) {
694 ret = PTR_ERR(omap->utmi_p2_gfclk);
695 dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret);
696 goto err_p2_gfclk;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530697 }
698
699 omap->xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1_ck");
700 if (IS_ERR(omap->xclk60mhsp1_ck)) {
701 ret = PTR_ERR(omap->xclk60mhsp1_ck);
702 dev_err(dev, "xclk60mhsp1_ck failed error:%d\n", ret);
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200703 goto err_xclk60mhsp1;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530704 }
705
706 omap->xclk60mhsp2_ck = clk_get(dev, "xclk60mhsp2_ck");
707 if (IS_ERR(omap->xclk60mhsp2_ck)) {
708 ret = PTR_ERR(omap->xclk60mhsp2_ck);
709 dev_err(dev, "xclk60mhsp2_ck failed error:%d\n", ret);
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200710 goto err_xclk60mhsp2;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530711 }
712
713 omap->init_60m_fclk = clk_get(dev, "init_60m_fclk");
714 if (IS_ERR(omap->init_60m_fclk)) {
715 ret = PTR_ERR(omap->init_60m_fclk);
716 dev_err(dev, "init_60m_fclk failed error:%d\n", ret);
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200717 goto err_init60m;
718 }
719
720 for (i = 0; i < omap->nports; i++) {
Roger Quadros340c64e2012-11-12 16:53:16 +0200721 char clkname[30];
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200722
723 /* clock names are indexed from 1*/
724 snprintf(clkname, sizeof(clkname),
725 "usb_host_hs_utmi_p%d_clk", i + 1);
726
727 /* If a clock is not found we won't bail out as not all
728 * platforms have all clocks and we can function without
729 * them
730 */
731 omap->utmi_clk[i] = clk_get(dev, clkname);
732 if (IS_ERR(omap->utmi_clk[i]))
733 dev_dbg(dev, "Failed to get clock : %s : %ld\n",
734 clkname, PTR_ERR(omap->utmi_clk[i]));
Roger Quadros340c64e2012-11-12 16:53:16 +0200735
736 snprintf(clkname, sizeof(clkname),
737 "usb_host_hs_hsic480m_p%d_clk", i + 1);
738 omap->hsic480m_clk[i] = clk_get(dev, clkname);
739 if (IS_ERR(omap->hsic480m_clk[i]))
740 dev_dbg(dev, "Failed to get clock : %s : %ld\n",
741 clkname, PTR_ERR(omap->hsic480m_clk[i]));
742
743 snprintf(clkname, sizeof(clkname),
744 "usb_host_hs_hsic60m_p%d_clk", i + 1);
745 omap->hsic60m_clk[i] = clk_get(dev, clkname);
746 if (IS_ERR(omap->hsic60m_clk[i]))
747 dev_dbg(dev, "Failed to get clock : %s : %ld\n",
748 clkname, PTR_ERR(omap->hsic60m_clk[i]));
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530749 }
750
751 if (is_ehci_phy_mode(pdata->port_mode[0])) {
Roger Quadrosa8c4e9e2012-11-28 16:31:29 +0200752 /* for OMAP3, clk_set_parent fails */
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200753 ret = clk_set_parent(omap->utmi_p1_gfclk,
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530754 omap->xclk60mhsp1_ck);
755 if (ret != 0)
Roger Quadrosa8c4e9e2012-11-28 16:31:29 +0200756 dev_dbg(dev, "xclk60mhsp1_ck set parent failed: %d\n",
757 ret);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530758 } else if (is_ehci_tll_mode(pdata->port_mode[0])) {
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200759 ret = clk_set_parent(omap->utmi_p1_gfclk,
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530760 omap->init_60m_fclk);
761 if (ret != 0)
Roger Quadrosa8c4e9e2012-11-28 16:31:29 +0200762 dev_dbg(dev, "P0 init_60m_fclk set parent failed: %d\n",
763 ret);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530764 }
765
766 if (is_ehci_phy_mode(pdata->port_mode[1])) {
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200767 ret = clk_set_parent(omap->utmi_p2_gfclk,
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530768 omap->xclk60mhsp2_ck);
769 if (ret != 0)
Roger Quadrosa8c4e9e2012-11-28 16:31:29 +0200770 dev_dbg(dev, "xclk60mhsp2_ck set parent failed: %d\n",
771 ret);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530772 } else if (is_ehci_tll_mode(pdata->port_mode[1])) {
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200773 ret = clk_set_parent(omap->utmi_p2_gfclk,
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530774 omap->init_60m_fclk);
775 if (ret != 0)
Roger Quadrosa8c4e9e2012-11-28 16:31:29 +0200776 dev_dbg(dev, "P1 init_60m_fclk set parent failed: %d\n",
777 ret);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530778 }
779
Govindraj.Rf0447a62012-02-15 15:53:34 +0530780 omap_usbhs_init(dev);
Roger Quadros03a8f432013-04-09 11:39:18 +0300781
782 if (dev->of_node) {
783 ret = of_platform_populate(dev->of_node,
784 usbhs_child_match_table, NULL, dev);
785
786 if (ret) {
787 dev_err(dev, "Failed to create DT children: %d\n", ret);
788 goto err_alloc;
789 }
790
791 } else {
792 ret = omap_usbhs_alloc_children(pdev);
793 if (ret) {
794 dev_err(dev, "omap_usbhs_alloc_children failed: %d\n",
795 ret);
796 goto err_alloc;
797 }
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530798 }
799
Roger Quadros27d4f2c2012-11-26 17:59:22 +0200800 return 0;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530801
802err_alloc:
Roger Quadros340c64e2012-11-12 16:53:16 +0200803 for (i = 0; i < omap->nports; i++) {
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200804 if (!IS_ERR(omap->utmi_clk[i]))
805 clk_put(omap->utmi_clk[i]);
Roger Quadros340c64e2012-11-12 16:53:16 +0200806 if (!IS_ERR(omap->hsic60m_clk[i]))
807 clk_put(omap->hsic60m_clk[i]);
808 if (!IS_ERR(omap->hsic480m_clk[i]))
809 clk_put(omap->hsic480m_clk[i]);
810 }
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200811
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530812 clk_put(omap->init_60m_fclk);
813
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200814err_init60m:
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530815 clk_put(omap->xclk60mhsp2_ck);
816
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200817err_xclk60mhsp2:
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530818 clk_put(omap->xclk60mhsp1_ck);
819
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200820err_xclk60mhsp1:
821 clk_put(omap->utmi_p2_gfclk);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530822
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200823err_p2_gfclk:
824 clk_put(omap->utmi_p1_gfclk);
825
826err_p1_gfclk:
827 if (!IS_ERR(omap->ehci_logic_fck))
828 clk_put(omap->ehci_logic_fck);
829
830err_mem:
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530831 pm_runtime_disable(dev);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530832
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530833 return ret;
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530834}
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530835
Roger Quadros03a8f432013-04-09 11:39:18 +0300836static int usbhs_omap_remove_child(struct device *dev, void *data)
837{
838 dev_info(dev, "unregistering\n");
839 platform_device_unregister(to_platform_device(dev));
840 return 0;
841}
842
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530843/**
844 * usbhs_omap_remove - shutdown processing for UHH & TLL HCDs
845 * @pdev: USB Host Controller being removed
846 *
847 * Reverses the effect of usbhs_omap_probe().
848 */
Bill Pemberton4740f732012-11-19 13:26:01 -0500849static int usbhs_omap_remove(struct platform_device *pdev)
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530850{
851 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200852 int i;
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530853
Roger Quadros340c64e2012-11-12 16:53:16 +0200854 for (i = 0; i < omap->nports; i++) {
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200855 if (!IS_ERR(omap->utmi_clk[i]))
856 clk_put(omap->utmi_clk[i]);
Roger Quadros340c64e2012-11-12 16:53:16 +0200857 if (!IS_ERR(omap->hsic60m_clk[i]))
858 clk_put(omap->hsic60m_clk[i]);
859 if (!IS_ERR(omap->hsic480m_clk[i]))
860 clk_put(omap->hsic480m_clk[i]);
861 }
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200862
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530863 clk_put(omap->init_60m_fclk);
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200864 clk_put(omap->utmi_p1_gfclk);
865 clk_put(omap->utmi_p2_gfclk);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530866 clk_put(omap->xclk60mhsp2_ck);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530867 clk_put(omap->xclk60mhsp1_ck);
Roger Quadros06ba7dc2012-11-08 17:40:25 +0200868
869 if (!IS_ERR(omap->ehci_logic_fck))
870 clk_put(omap->ehci_logic_fck);
871
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530872 pm_runtime_disable(&pdev->dev);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530873
Roger Quadros03a8f432013-04-09 11:39:18 +0300874 /* remove children */
875 device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530876 return 0;
877}
878
879static const struct dev_pm_ops usbhsomap_dev_pm_ops = {
880 .runtime_suspend = usbhs_runtime_suspend,
881 .runtime_resume = usbhs_runtime_resume,
882};
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530883
Roger Quadros03a8f432013-04-09 11:39:18 +0300884static const struct of_device_id usbhs_omap_dt_ids[] = {
885 { .compatible = "ti,usbhs-host" },
886 { }
887};
888
889MODULE_DEVICE_TABLE(of, usbhs_omap_dt_ids);
890
891
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530892static struct platform_driver usbhs_omap_driver = {
893 .driver = {
894 .name = (char *)usbhs_driver_name,
895 .owner = THIS_MODULE,
Keshava Munegowda1e7fe1a2011-10-11 13:23:29 +0530896 .pm = &usbhsomap_dev_pm_ops,
Roger Quadros03a8f432013-04-09 11:39:18 +0300897 .of_match_table = of_match_ptr(usbhs_omap_dt_ids),
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530898 },
Roger Quadrosab3f2a82013-01-02 15:59:28 +0200899 .remove = usbhs_omap_remove,
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530900};
901
902MODULE_AUTHOR("Keshava Munegowda <keshava_mgowda@ti.com>");
Roger Quadros03a8f432013-04-09 11:39:18 +0300903MODULE_AUTHOR("Roger Quadros <rogerq@ti.com>");
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530904MODULE_ALIAS("platform:" USBHS_DRIVER_NAME);
905MODULE_LICENSE("GPL v2");
906MODULE_DESCRIPTION("usb host common core driver for omap EHCI and OHCI");
907
908static int __init omap_usbhs_drvinit(void)
909{
910 return platform_driver_probe(&usbhs_omap_driver, usbhs_omap_probe);
911}
912
913/*
914 * init before ehci and ohci drivers;
915 * The usbhs core driver should be initialized much before
916 * the omap ehci and ohci probe functions are called.
Keshava Munegowda4dc2cce2012-07-16 19:01:09 +0530917 * This usbhs core driver should be initialized after
918 * usb tll driver
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530919 */
Keshava Munegowda4dc2cce2012-07-16 19:01:09 +0530920fs_initcall_sync(omap_usbhs_drvinit);
Keshava Munegowda17cdd292011-03-01 20:08:17 +0530921
922static void __exit omap_usbhs_drvexit(void)
923{
924 platform_driver_unregister(&usbhs_omap_driver);
925}
926module_exit(omap_usbhs_drvexit);