blob: 6e15fc87cf606ef0d8473b27dcfc967b52a416ff [file] [log] [blame]
Felipe Balbi54ab2b02009-10-14 11:44:14 +03001/*
Anand Gadiyar4792a152010-11-21 23:23:42 +05302 * ehci-omap.c - driver for USBHOST on OMAP3/4 processors
Felipe Balbi54ab2b02009-10-14 11:44:14 +03003 *
Anand Gadiyar4792a152010-11-21 23:23:42 +05304 * Bus Glue for the EHCI controllers in OMAP3/4
5 * Tested on several OMAP3 boards, and OMAP4 Pandaboard
Felipe Balbi54ab2b02009-10-14 11:44:14 +03006 *
Keshava Munegowda19403162011-03-01 20:08:21 +05307 * Copyright (C) 2007-2011 Texas Instruments, Inc.
Felipe Balbi54ab2b02009-10-14 11:44:14 +03008 * Author: Vikram Pandita <vikram.pandita@ti.com>
Anand Gadiyar4792a152010-11-21 23:23:42 +05309 * Author: Anand Gadiyar <gadiyar@ti.com>
Keshava Munegowda19403162011-03-01 20:08:21 +053010 * Author: Keshava Munegowda <keshava_mgowda@ti.com>
Felipe Balbi54ab2b02009-10-14 11:44:14 +030011 *
12 * Copyright (C) 2009 Nokia Corporation
13 * Contact: Felipe Balbi <felipe.balbi@nokia.com>
14 *
15 * Based on "ehci-fsl.c" and "ehci-au1xxx.c" ehci glue layers
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 *
Keshava Munegowda19403162011-03-01 20:08:21 +053031 * TODO (last updated Feb 27, 2010):
Felipe Balbi54ab2b02009-10-14 11:44:14 +030032 * - add kernel-doc
33 * - enable AUTOIDLE
Felipe Balbi54ab2b02009-10-14 11:44:14 +030034 * - add suspend/resume
Anand Gadiyar4792a152010-11-21 23:23:42 +053035 * - add HSIC and TLL support
36 * - convert to use hwmod and runtime PM
Felipe Balbi54ab2b02009-10-14 11:44:14 +030037 */
38
39#include <linux/platform_device.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090040#include <linux/slab.h>
Ajay Kumar Gupta5aa4af22010-07-08 14:03:02 +053041#include <linux/usb/ulpi.h>
Thomas Weberc76f7822009-12-15 10:38:05 -080042#include <plat/usb.h>
Keshava Munegowda6e3d4be2011-04-21 19:52:43 +053043#include <linux/regulator/consumer.h>
Keshava Munegowda6c984b02011-10-11 13:22:11 +053044#include <linux/pm_runtime.h>
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +053045#include <linux/gpio.h>
Anand Gadiyar354ab852012-06-05 15:34:27 +030046#include <linux/clk.h>
Felipe Balbi54ab2b02009-10-14 11:44:14 +030047
Felipe Balbi54ab2b02009-10-14 11:44:14 +030048/* EHCI Register Set */
Anand Gadiyar572538d2010-05-06 20:09:48 +053049#define EHCI_INSNREG04 (0xA0)
50#define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5)
Felipe Balbi54ab2b02009-10-14 11:44:14 +030051#define EHCI_INSNREG05_ULPI (0xA4)
52#define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31
53#define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24
54#define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
55#define EHCI_INSNREG05_ULPI_REGADD_SHIFT 16
56#define EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
57#define EHCI_INSNREG05_ULPI_WRDATA_SHIFT 0
58
Anand Gadiyar354ab852012-06-05 15:34:27 +030059/* Errata i693 */
60static struct clk *utmi_p1_fck;
61static struct clk *utmi_p2_fck;
62static struct clk *xclk60mhsp1_ck;
63static struct clk *xclk60mhsp2_ck;
64static struct clk *usbhost_p1_fck;
65static struct clk *usbhost_p2_fck;
66static struct clk *init_60m_fclk;
67
Felipe Balbi54ab2b02009-10-14 11:44:14 +030068/*-------------------------------------------------------------------------*/
69
Keshava Munegowda19403162011-03-01 20:08:21 +053070static const struct hc_driver ehci_omap_hc_driver;
71
72
73static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
Felipe Balbi54ab2b02009-10-14 11:44:14 +030074{
75 __raw_writel(val, base + reg);
76}
77
Keshava Munegowda19403162011-03-01 20:08:21 +053078static inline u32 ehci_read(void __iomem *base, u32 reg)
Felipe Balbi54ab2b02009-10-14 11:44:14 +030079{
80 return __raw_readl(base + reg);
81}
82
Anand Gadiyar354ab852012-06-05 15:34:27 +030083/* Erratum i693 workaround sequence */
84static void omap_ehci_erratum_i693(struct ehci_hcd *ehci)
85{
86 int ret = 0;
87
88 /* Switch to the internal 60 MHz clock */
89 ret = clk_set_parent(utmi_p1_fck, init_60m_fclk);
90 if (ret != 0)
91 ehci_err(ehci, "init_60m_fclk set parent"
92 "failed error:%d\n", ret);
93
94 ret = clk_set_parent(utmi_p2_fck, init_60m_fclk);
95 if (ret != 0)
96 ehci_err(ehci, "init_60m_fclk set parent"
97 "failed error:%d\n", ret);
98
99 clk_enable(usbhost_p1_fck);
100 clk_enable(usbhost_p2_fck);
101
102 /* Wait 1ms and switch back to the external clock */
103 mdelay(1);
104 ret = clk_set_parent(utmi_p1_fck, xclk60mhsp1_ck);
105 if (ret != 0)
106 ehci_err(ehci, "xclk60mhsp1_ck set parent"
107 "failed error:%d\n", ret);
108
109 ret = clk_set_parent(utmi_p2_fck, xclk60mhsp2_ck);
110 if (ret != 0)
111 ehci_err(ehci, "xclk60mhsp2_ck set parent"
112 "failed error:%d\n", ret);
113
114 clk_disable(usbhost_p1_fck);
115 clk_disable(usbhost_p2_fck);
116}
117
Keshava Munegowda19403162011-03-01 20:08:21 +0530118static void omap_ehci_soft_phy_reset(struct platform_device *pdev, u8 port)
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300119{
Keshava Munegowda19403162011-03-01 20:08:21 +0530120 struct usb_hcd *hcd = dev_get_drvdata(&pdev->dev);
Ajay Kumar Gupta5aa4af22010-07-08 14:03:02 +0530121 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
122 unsigned reg = 0;
123
124 reg = ULPI_FUNC_CTRL_RESET
125 /* FUNCTION_CTRL_SET register */
126 | (ULPI_SET(ULPI_FUNC_CTRL) << EHCI_INSNREG05_ULPI_REGADD_SHIFT)
127 /* Write */
128 | (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT)
129 /* PORTn */
130 | ((port + 1) << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT)
131 /* start ULPI access*/
132 | (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT);
133
Keshava Munegowda19403162011-03-01 20:08:21 +0530134 ehci_write(hcd->regs, EHCI_INSNREG05_ULPI, reg);
Ajay Kumar Gupta5aa4af22010-07-08 14:03:02 +0530135
136 /* Wait for ULPI access completion */
Keshava Munegowda19403162011-03-01 20:08:21 +0530137 while ((ehci_read(hcd->regs, EHCI_INSNREG05_ULPI)
Ajay Kumar Gupta5aa4af22010-07-08 14:03:02 +0530138 & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
139 cpu_relax();
140
141 if (time_after(jiffies, timeout)) {
Keshava Munegowda19403162011-03-01 20:08:21 +0530142 dev_dbg(&pdev->dev, "phy reset operation timed out\n");
Ajay Kumar Gupta5aa4af22010-07-08 14:03:02 +0530143 break;
144 }
145 }
146}
147
Anand Gadiyar354ab852012-06-05 15:34:27 +0300148static int omap_ehci_hub_control(
149 struct usb_hcd *hcd,
150 u16 typeReq,
151 u16 wValue,
152 u16 wIndex,
153 char *buf,
154 u16 wLength
155)
156{
157 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
158 u32 __iomem *status_reg = &ehci->regs->port_status[
159 (wIndex & 0xff) - 1];
160 u32 temp;
161 unsigned long flags;
162 int retval = 0;
163
164 spin_lock_irqsave(&ehci->lock, flags);
165
166 if (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_SUSPEND) {
167 temp = ehci_readl(ehci, status_reg);
168 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) {
169 retval = -EPIPE;
170 goto done;
171 }
172
173 temp &= ~PORT_WKCONN_E;
174 temp |= PORT_WKDISC_E | PORT_WKOC_E;
175 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
176
177 omap_ehci_erratum_i693(ehci);
178
179 set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports);
180 goto done;
181 }
182
183 spin_unlock_irqrestore(&ehci->lock, flags);
184
185 /* Handle the hub control events here */
186 return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
187done:
188 spin_unlock_irqrestore(&ehci->lock, flags);
189 return retval;
190}
191
Ming Leid4aefec2011-07-28 22:59:53 +0800192static void disable_put_regulator(
193 struct ehci_hcd_omap_platform_data *pdata)
194{
195 int i;
196
197 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
198 if (pdata->regulator[i]) {
199 regulator_disable(pdata->regulator[i]);
200 regulator_put(pdata->regulator[i]);
201 }
202 }
203}
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300204
205/* configure so an HC device and id are always provided */
206/* always called with process context; sleeping is OK */
207
208/**
209 * ehci_hcd_omap_probe - initialize TI-based HCDs
210 *
211 * Allocates basic resources for this USB host controller, and
212 * then invokes the start() method for the HCD associated with it
213 * through the hotplug entry's driver_data.
214 */
215static int ehci_hcd_omap_probe(struct platform_device *pdev)
216{
Keshava Munegowda19403162011-03-01 20:08:21 +0530217 struct device *dev = &pdev->dev;
218 struct ehci_hcd_omap_platform_data *pdata = dev->platform_data;
219 struct resource *res;
220 struct usb_hcd *hcd;
221 void __iomem *regs;
222 struct ehci_hcd *omap_ehci;
223 int ret = -ENODEV;
224 int irq;
Keshava Munegowda6e3d4be2011-04-21 19:52:43 +0530225 int i;
226 char supply[7];
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300227
228 if (usb_disabled())
Keshava Munegowda19403162011-03-01 20:08:21 +0530229 return -ENODEV;
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300230
Keshava Munegowda19403162011-03-01 20:08:21 +0530231 if (!dev->parent) {
232 dev_err(dev, "Missing parent device\n");
233 return -ENODEV;
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300234 }
235
Keshava Munegowda19403162011-03-01 20:08:21 +0530236 irq = platform_get_irq_byname(pdev, "ehci-irq");
237 if (irq < 0) {
238 dev_err(dev, "EHCI irq failed\n");
239 return -ENODEV;
240 }
241
242 res = platform_get_resource_byname(pdev,
243 IORESOURCE_MEM, "ehci");
244 if (!res) {
245 dev_err(dev, "UHH EHCI get resource failed\n");
246 return -ENODEV;
247 }
248
249 regs = ioremap(res->start, resource_size(res));
250 if (!regs) {
251 dev_err(dev, "UHH EHCI ioremap failed\n");
252 return -ENOMEM;
253 }
254
255 hcd = usb_create_hcd(&ehci_omap_hc_driver, dev,
256 dev_name(dev));
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300257 if (!hcd) {
Keshava Munegowda19403162011-03-01 20:08:21 +0530258 dev_err(dev, "failed to create hcd with err %d\n", ret);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300259 ret = -ENOMEM;
Keshava Munegowda19403162011-03-01 20:08:21 +0530260 goto err_io;
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300261 }
262
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300263 hcd->rsrc_start = res->start;
264 hcd->rsrc_len = resource_size(res);
Keshava Munegowda19403162011-03-01 20:08:21 +0530265 hcd->regs = regs;
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300266
Keshava Munegowda6e3d4be2011-04-21 19:52:43 +0530267 /* get ehci regulator and enable */
268 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
269 if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
270 pdata->regulator[i] = NULL;
271 continue;
272 }
273 snprintf(supply, sizeof(supply), "hsusb%d", i);
274 pdata->regulator[i] = regulator_get(dev, supply);
275 if (IS_ERR(pdata->regulator[i])) {
276 pdata->regulator[i] = NULL;
277 dev_dbg(dev,
278 "failed to get ehci port%d regulator\n", i);
279 } else {
280 regulator_enable(pdata->regulator[i]);
281 }
282 }
283
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +0530284 if (pdata->phy_reset) {
285 if (gpio_is_valid(pdata->reset_gpio_port[0]))
286 gpio_request_one(pdata->reset_gpio_port[0],
287 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
288
289 if (gpio_is_valid(pdata->reset_gpio_port[1]))
290 gpio_request_one(pdata->reset_gpio_port[1],
291 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
292
293 /* Hold the PHY in RESET for enough time till DIR is high */
294 udelay(10);
295 }
296
Keshava Munegowda6c984b02011-10-11 13:22:11 +0530297 pm_runtime_enable(dev);
298 pm_runtime_get_sync(dev);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300299
Keshava Munegowda19403162011-03-01 20:08:21 +0530300 /*
301 * An undocumented "feature" in the OMAP3 EHCI controller,
302 * causes suspended ports to be taken out of suspend when
303 * the USBCMD.Run/Stop bit is cleared (for example when
304 * we do ehci_bus_suspend).
305 * This breaks suspend-resume if the root-hub is allowed
306 * to suspend. Writing 1 to this undocumented register bit
307 * disables this feature and restores normal behavior.
308 */
309 ehci_write(regs, EHCI_INSNREG04,
310 EHCI_INSNREG04_DISABLE_UNSUSPEND);
311
312 /* Soft reset the PHY using PHY reset command over ULPI */
313 if (pdata->port_mode[0] == OMAP_EHCI_PORT_MODE_PHY)
314 omap_ehci_soft_phy_reset(pdev, 0);
315 if (pdata->port_mode[1] == OMAP_EHCI_PORT_MODE_PHY)
316 omap_ehci_soft_phy_reset(pdev, 1);
317
318 omap_ehci = hcd_to_ehci(hcd);
319 omap_ehci->sbrn = 0x20;
320
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300321 /* we know this is the memory we want, no need to ioremap again */
Keshava Munegowda19403162011-03-01 20:08:21 +0530322 omap_ehci->caps = hcd->regs;
323 omap_ehci->regs = hcd->regs
Jan Anderssonc4301312011-05-03 20:11:57 +0200324 + HC_LENGTH(ehci, readl(&omap_ehci->caps->hc_capbase));
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300325
Keshava Munegowda19403162011-03-01 20:08:21 +0530326 dbg_hcs_params(omap_ehci, "reset");
327 dbg_hcc_params(omap_ehci, "reset");
Anand Gadiyarbdb581b2010-02-12 17:54:59 +0530328
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300329 /* cache this readonly data; minimize chip reads */
Keshava Munegowda19403162011-03-01 20:08:21 +0530330 omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300331
Geoff Levand876e0df2011-11-22 18:04:45 -0800332 ehci_reset(omap_ehci);
333
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +0530334 if (pdata->phy_reset) {
335 /* Hold the PHY in RESET for enough time till
336 * PHY is settled and ready
337 */
338 udelay(10);
339
340 if (gpio_is_valid(pdata->reset_gpio_port[0]))
Igor Grinberg7b183892012-05-09 10:31:35 +0300341 gpio_set_value_cansleep(pdata->reset_gpio_port[0], 1);
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +0530342
343 if (gpio_is_valid(pdata->reset_gpio_port[1]))
Igor Grinberg7b183892012-05-09 10:31:35 +0300344 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +0530345 }
346
Russ Dill3aa2ae72012-05-04 04:24:47 -0700347 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
348 if (ret) {
349 dev_err(dev, "failed to add hcd with err %d\n", ret);
Russ Dill984e9742012-06-21 03:44:31 -0700350 goto err_pm_runtime;
Russ Dill3aa2ae72012-05-04 04:24:47 -0700351 }
352
353 /* root ports should always stay powered */
354 ehci_port_power(omap_ehci, 1);
355
Anand Gadiyar354ab852012-06-05 15:34:27 +0300356 /* get clocks */
357 utmi_p1_fck = clk_get(dev, "utmi_p1_gfclk");
358 if (IS_ERR(utmi_p1_fck)) {
359 ret = PTR_ERR(utmi_p1_fck);
360 dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret);
361 goto err_add_hcd;
362 }
363
364 xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1_ck");
365 if (IS_ERR(xclk60mhsp1_ck)) {
366 ret = PTR_ERR(xclk60mhsp1_ck);
367 dev_err(dev, "xclk60mhsp1_ck failed error:%d\n", ret);
368 goto err_utmi_p1_fck;
369 }
370
371 utmi_p2_fck = clk_get(dev, "utmi_p2_gfclk");
372 if (IS_ERR(utmi_p2_fck)) {
373 ret = PTR_ERR(utmi_p2_fck);
374 dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret);
375 goto err_xclk60mhsp1_ck;
376 }
377
378 xclk60mhsp2_ck = clk_get(dev, "xclk60mhsp2_ck");
379 if (IS_ERR(xclk60mhsp2_ck)) {
380 ret = PTR_ERR(xclk60mhsp2_ck);
381 dev_err(dev, "xclk60mhsp2_ck failed error:%d\n", ret);
382 goto err_utmi_p2_fck;
383 }
384
385 usbhost_p1_fck = clk_get(dev, "usb_host_hs_utmi_p1_clk");
386 if (IS_ERR(usbhost_p1_fck)) {
387 ret = PTR_ERR(usbhost_p1_fck);
388 dev_err(dev, "usbhost_p1_fck failed error:%d\n", ret);
389 goto err_xclk60mhsp2_ck;
390 }
391
392 usbhost_p2_fck = clk_get(dev, "usb_host_hs_utmi_p2_clk");
393 if (IS_ERR(usbhost_p2_fck)) {
394 ret = PTR_ERR(usbhost_p2_fck);
395 dev_err(dev, "usbhost_p2_fck failed error:%d\n", ret);
396 goto err_usbhost_p1_fck;
397 }
398
399 init_60m_fclk = clk_get(dev, "init_60m_fclk");
400 if (IS_ERR(init_60m_fclk)) {
401 ret = PTR_ERR(init_60m_fclk);
402 dev_err(dev, "init_60m_fclk failed error:%d\n", ret);
403 goto err_usbhost_p2_fck;
404 }
405
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300406 return 0;
407
Anand Gadiyar354ab852012-06-05 15:34:27 +0300408err_usbhost_p2_fck:
409 clk_put(usbhost_p2_fck);
410
411err_usbhost_p1_fck:
412 clk_put(usbhost_p1_fck);
413
414err_xclk60mhsp2_ck:
415 clk_put(xclk60mhsp2_ck);
416
417err_utmi_p2_fck:
418 clk_put(utmi_p2_fck);
419
420err_xclk60mhsp1_ck:
421 clk_put(xclk60mhsp1_ck);
422
423err_utmi_p1_fck:
424 clk_put(utmi_p1_fck);
425
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300426err_add_hcd:
Russ Dill984e9742012-06-21 03:44:31 -0700427 usb_remove_hcd(hcd);
428
429err_pm_runtime:
Ming Leid4aefec2011-07-28 22:59:53 +0800430 disable_put_regulator(pdata);
Keshava Munegowda6c984b02011-10-11 13:22:11 +0530431 pm_runtime_put_sync(dev);
Russ Dill984e9742012-06-21 03:44:31 -0700432 usb_put_hcd(hcd);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300433
Keshava Munegowda19403162011-03-01 20:08:21 +0530434err_io:
Ming Leid4aefec2011-07-28 22:59:53 +0800435 iounmap(regs);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300436 return ret;
437}
438
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300439
440/**
441 * ehci_hcd_omap_remove - shutdown processing for EHCI HCDs
442 * @pdev: USB Host Controller being removed
443 *
444 * Reverses the effect of usb_ehci_hcd_omap_probe(), first invoking
445 * the HCD's stop() method. It is always called from a thread
446 * context, normally "rmmod", "apmd", or something similar.
447 */
448static int ehci_hcd_omap_remove(struct platform_device *pdev)
449{
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +0530450 struct device *dev = &pdev->dev;
451 struct usb_hcd *hcd = dev_get_drvdata(dev);
452 struct ehci_hcd_omap_platform_data *pdata = dev->platform_data;
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300453
454 usb_remove_hcd(hcd);
Ming Leid4aefec2011-07-28 22:59:53 +0800455 disable_put_regulator(dev->platform_data);
456 iounmap(hcd->regs);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300457 usb_put_hcd(hcd);
Anand Gadiyar354ab852012-06-05 15:34:27 +0300458
459 clk_put(utmi_p1_fck);
460 clk_put(utmi_p2_fck);
461 clk_put(xclk60mhsp1_ck);
462 clk_put(xclk60mhsp2_ck);
463 clk_put(usbhost_p1_fck);
464 clk_put(usbhost_p2_fck);
465 clk_put(init_60m_fclk);
466
Keshava Munegowda6c984b02011-10-11 13:22:11 +0530467 pm_runtime_put_sync(dev);
468 pm_runtime_disable(dev);
469
Keshava Munegowda1fcb57d2012-03-19 12:12:47 +0530470 if (pdata->phy_reset) {
471 if (gpio_is_valid(pdata->reset_gpio_port[0]))
472 gpio_free(pdata->reset_gpio_port[0]);
473
474 if (gpio_is_valid(pdata->reset_gpio_port[1]))
475 gpio_free(pdata->reset_gpio_port[1]);
476 }
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300477 return 0;
478}
479
480static void ehci_hcd_omap_shutdown(struct platform_device *pdev)
481{
Keshava Munegowda19403162011-03-01 20:08:21 +0530482 struct usb_hcd *hcd = dev_get_drvdata(&pdev->dev);
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300483
484 if (hcd->driver->shutdown)
485 hcd->driver->shutdown(hcd);
486}
487
488static struct platform_driver ehci_hcd_omap_driver = {
489 .probe = ehci_hcd_omap_probe,
490 .remove = ehci_hcd_omap_remove,
491 .shutdown = ehci_hcd_omap_shutdown,
492 /*.suspend = ehci_hcd_omap_suspend, */
493 /*.resume = ehci_hcd_omap_resume, */
494 .driver = {
495 .name = "ehci-omap",
496 }
497};
498
499/*-------------------------------------------------------------------------*/
500
501static const struct hc_driver ehci_omap_hc_driver = {
502 .description = hcd_name,
503 .product_desc = "OMAP-EHCI Host Controller",
504 .hcd_priv_size = sizeof(struct ehci_hcd),
505
506 /*
507 * generic hardware linkage
508 */
509 .irq = ehci_irq,
510 .flags = HCD_MEMORY | HCD_USB2,
511
512 /*
513 * basic lifecycle operations
514 */
515 .reset = ehci_init,
516 .start = ehci_run,
517 .stop = ehci_stop,
518 .shutdown = ehci_shutdown,
519
520 /*
521 * managing i/o requests and associated device resources
522 */
523 .urb_enqueue = ehci_urb_enqueue,
524 .urb_dequeue = ehci_urb_dequeue,
525 .endpoint_disable = ehci_endpoint_disable,
526 .endpoint_reset = ehci_endpoint_reset,
527
528 /*
529 * scheduling support
530 */
531 .get_frame_number = ehci_get_frame,
532
533 /*
534 * root hub support
535 */
536 .hub_status_data = ehci_hub_status_data,
Anand Gadiyar354ab852012-06-05 15:34:27 +0300537 .hub_control = omap_ehci_hub_control,
Felipe Balbi54ab2b02009-10-14 11:44:14 +0300538 .bus_suspend = ehci_bus_suspend,
539 .bus_resume = ehci_bus_resume,
540
541 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
542};
543
544MODULE_ALIAS("platform:omap-ehci");
545MODULE_AUTHOR("Texas Instruments, Inc.");
546MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
547