blob: c612cb93dd15c1722c0b02f7f822f4b0069e8b94 [file] [log] [blame]
Manu Gautam91223e02011-11-08 15:27:22 +05301/* ehci-msm2.c - HSUSB Host Controller Driver Implementation
2 *
3 * Copyright (c) 2008-2012, Code Aurora Forum. All rights reserved.
4 *
5 * Partly derived from ehci-fsl.c and ehci-hcd.c
6 * Copyright (c) 2000-2004 by David Brownell
7 * Copyright (c) 2005 MontaVista Software
8 *
9 * All source code in this file is licensed under the following license except
10 * where indicated.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 as published
14 * by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * See the GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, you can find it at http://www.fsf.org
23 */
24
25#include <linux/platform_device.h>
26#include <linux/clk.h>
27#include <linux/err.h>
28#include <linux/wakelock.h>
29#include <linux/pm_runtime.h>
30#include <linux/regulator/consumer.h>
31
32#include <linux/usb/ulpi.h>
33#include <linux/usb/msm_hsusb_hw.h>
34#include <linux/usb/msm_hsusb.h>
35#include <mach/clk.h>
Hemant Kumar8c0f2a82012-05-03 19:17:26 -070036#include <mach/msm_xo.h>
Manu Gautam91223e02011-11-08 15:27:22 +053037#include <mach/msm_iomap.h>
38
39#define MSM_USB_BASE (hcd->regs)
40
Hemant Kumar8c0f2a82012-05-03 19:17:26 -070041#define PDEV_NAME_LEN 20
42
Manu Gautam91223e02011-11-08 15:27:22 +053043struct msm_hcd {
44 struct ehci_hcd ehci;
45 struct device *dev;
46 struct clk *iface_clk;
47 struct clk *core_clk;
48 struct clk *alt_core_clk;
49 struct regulator *hsusb_vddcx;
50 struct regulator *hsusb_3p3;
51 struct regulator *hsusb_1p8;
52 struct regulator *vbus;
Hemant Kumar8c0f2a82012-05-03 19:17:26 -070053 struct msm_xo_voter *xo_handle;
Manu Gautam91223e02011-11-08 15:27:22 +053054 bool async_int;
Hemant Kumar56925352012-02-13 16:59:52 -080055 bool vbus_on;
Manu Gautam91223e02011-11-08 15:27:22 +053056 atomic_t in_lpm;
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +053057 int pmic_gpio_dp_irq;
58 bool pmic_gpio_dp_irq_enabled;
59 uint32_t pmic_gpio_int_cnt;
60 atomic_t pm_usage_cnt;
Manu Gautam91223e02011-11-08 15:27:22 +053061 struct wake_lock wlock;
62};
63
64static inline struct msm_hcd *hcd_to_mhcd(struct usb_hcd *hcd)
65{
66 return (struct msm_hcd *) (hcd->hcd_priv);
67}
68
69static inline struct usb_hcd *mhcd_to_hcd(struct msm_hcd *mhcd)
70{
71 return container_of((void *) mhcd, struct usb_hcd, hcd_priv);
72}
73
74#define HSUSB_PHY_3P3_VOL_MIN 3050000 /* uV */
75#define HSUSB_PHY_3P3_VOL_MAX 3300000 /* uV */
76#define HSUSB_PHY_3P3_HPM_LOAD 50000 /* uA */
77
78#define HSUSB_PHY_1P8_VOL_MIN 1800000 /* uV */
79#define HSUSB_PHY_1P8_VOL_MAX 1800000 /* uV */
80#define HSUSB_PHY_1P8_HPM_LOAD 50000 /* uA */
81
82#define HSUSB_PHY_VDD_DIG_VOL_MIN 1045000 /* uV */
83#define HSUSB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */
84#define HSUSB_PHY_VDD_DIG_LOAD 49360 /* uA */
85
86static int msm_ehci_init_vddcx(struct msm_hcd *mhcd, int init)
87{
88 int ret = 0;
89
90 if (!init)
91 goto disable_reg;
92
Mayank Rana2f416c22012-03-24 05:23:25 +053093 mhcd->hsusb_vddcx = devm_regulator_get(mhcd->dev, "HSUSB_VDDCX");
Manu Gautam91223e02011-11-08 15:27:22 +053094 if (IS_ERR(mhcd->hsusb_vddcx)) {
95 dev_err(mhcd->dev, "unable to get ehci vddcx\n");
96 return PTR_ERR(mhcd->hsusb_vddcx);
97 }
98
99 ret = regulator_set_voltage(mhcd->hsusb_vddcx,
100 HSUSB_PHY_VDD_DIG_VOL_MIN,
101 HSUSB_PHY_VDD_DIG_VOL_MAX);
102 if (ret) {
103 dev_err(mhcd->dev, "unable to set the voltage"
104 "for ehci vddcx\n");
Mayank Rana2f416c22012-03-24 05:23:25 +0530105 return ret;
Manu Gautam91223e02011-11-08 15:27:22 +0530106 }
107
108 ret = regulator_set_optimum_mode(mhcd->hsusb_vddcx,
109 HSUSB_PHY_VDD_DIG_LOAD);
110 if (ret < 0) {
111 dev_err(mhcd->dev, "%s: Unable to set optimum mode of the"
112 " regulator: VDDCX\n", __func__);
113 goto reg_optimum_mode_err;
114 }
115
116 ret = regulator_enable(mhcd->hsusb_vddcx);
117 if (ret) {
118 dev_err(mhcd->dev, "unable to enable ehci vddcx\n");
119 goto reg_enable_err;
120 }
121
122 return 0;
123
124disable_reg:
125 regulator_disable(mhcd->hsusb_vddcx);
126reg_enable_err:
127 regulator_set_optimum_mode(mhcd->hsusb_vddcx, 0);
128reg_optimum_mode_err:
129 regulator_set_voltage(mhcd->hsusb_vddcx, 0,
130 HSUSB_PHY_VDD_DIG_VOL_MIN);
Manu Gautam91223e02011-11-08 15:27:22 +0530131 return ret;
132
133}
134
135static int msm_ehci_ldo_init(struct msm_hcd *mhcd, int init)
136{
137 int rc = 0;
138
139 if (!init)
140 goto put_1p8;
141
Mayank Rana2f416c22012-03-24 05:23:25 +0530142 mhcd->hsusb_3p3 = devm_regulator_get(mhcd->dev, "HSUSB_3p3");
Manu Gautam91223e02011-11-08 15:27:22 +0530143 if (IS_ERR(mhcd->hsusb_3p3)) {
144 dev_err(mhcd->dev, "unable to get hsusb 3p3\n");
145 return PTR_ERR(mhcd->hsusb_3p3);
146 }
147
148 rc = regulator_set_voltage(mhcd->hsusb_3p3,
149 HSUSB_PHY_3P3_VOL_MIN, HSUSB_PHY_3P3_VOL_MAX);
150 if (rc) {
151 dev_err(mhcd->dev, "unable to set voltage level for"
152 "hsusb 3p3\n");
Mayank Rana2f416c22012-03-24 05:23:25 +0530153 return rc;
Manu Gautam91223e02011-11-08 15:27:22 +0530154 }
Mayank Rana2f416c22012-03-24 05:23:25 +0530155 mhcd->hsusb_1p8 = devm_regulator_get(mhcd->dev, "HSUSB_1p8");
Manu Gautam91223e02011-11-08 15:27:22 +0530156 if (IS_ERR(mhcd->hsusb_1p8)) {
157 dev_err(mhcd->dev, "unable to get hsusb 1p8\n");
158 rc = PTR_ERR(mhcd->hsusb_1p8);
159 goto put_3p3_lpm;
160 }
161 rc = regulator_set_voltage(mhcd->hsusb_1p8,
162 HSUSB_PHY_1P8_VOL_MIN, HSUSB_PHY_1P8_VOL_MAX);
163 if (rc) {
164 dev_err(mhcd->dev, "unable to set voltage level for"
165 "hsusb 1p8\n");
166 goto put_1p8;
167 }
168
169 return 0;
170
171put_1p8:
172 regulator_set_voltage(mhcd->hsusb_1p8, 0, HSUSB_PHY_1P8_VOL_MAX);
Manu Gautam91223e02011-11-08 15:27:22 +0530173put_3p3_lpm:
174 regulator_set_voltage(mhcd->hsusb_3p3, 0, HSUSB_PHY_3P3_VOL_MAX);
Manu Gautam91223e02011-11-08 15:27:22 +0530175
176 return rc;
177}
178
179#ifdef CONFIG_PM_SLEEP
Hemant Kumar441356be2012-02-13 16:12:49 -0800180#define HSUSB_PHY_SUSP_DIG_VOL_P50 500000
181#define HSUSB_PHY_SUSP_DIG_VOL_P75 750000
Manu Gautam91223e02011-11-08 15:27:22 +0530182static int msm_ehci_config_vddcx(struct msm_hcd *mhcd, int high)
183{
Hemant Kumar441356be2012-02-13 16:12:49 -0800184 struct msm_usb_host_platform_data *pdata;
Manu Gautam91223e02011-11-08 15:27:22 +0530185 int max_vol = HSUSB_PHY_VDD_DIG_VOL_MAX;
186 int min_vol;
187 int ret;
188
Hemant Kumar441356be2012-02-13 16:12:49 -0800189 pdata = mhcd->dev->platform_data;
190
Manu Gautam91223e02011-11-08 15:27:22 +0530191 if (high)
192 min_vol = HSUSB_PHY_VDD_DIG_VOL_MIN;
Hemant Kumar441356be2012-02-13 16:12:49 -0800193 else if (pdata && pdata->dock_connect_irq &&
194 !irq_read_line(pdata->dock_connect_irq))
195 min_vol = HSUSB_PHY_SUSP_DIG_VOL_P75;
Manu Gautam91223e02011-11-08 15:27:22 +0530196 else
Hemant Kumar441356be2012-02-13 16:12:49 -0800197 min_vol = HSUSB_PHY_SUSP_DIG_VOL_P50;
Manu Gautam91223e02011-11-08 15:27:22 +0530198
199 ret = regulator_set_voltage(mhcd->hsusb_vddcx, min_vol, max_vol);
200 if (ret) {
201 dev_err(mhcd->dev, "%s: unable to set the voltage of regulator"
202 " HSUSB_VDDCX\n", __func__);
203 return ret;
204 }
205
206 dev_dbg(mhcd->dev, "%s: min_vol:%d max_vol:%d\n", __func__, min_vol,
207 max_vol);
208
209 return ret;
210}
211#else
212static int msm_ehci_config_vddcx(struct msm_hcd *mhcd, int high)
213{
214 return 0;
215}
216#endif
217
Manu Gautam91223e02011-11-08 15:27:22 +0530218static void msm_ehci_vbus_power(struct msm_hcd *mhcd, bool on)
219{
220 int ret;
221
222 if (!mhcd->vbus) {
223 pr_err("vbus is NULL.");
224 return;
225 }
Hemant Kumar56925352012-02-13 16:59:52 -0800226
227 if (mhcd->vbus_on == on)
228 return;
229
Manu Gautam91223e02011-11-08 15:27:22 +0530230 if (on) {
231 ret = regulator_enable(mhcd->vbus);
232 if (ret) {
233 pr_err("unable to enable vbus\n");
234 return;
235 }
Hemant Kumar56925352012-02-13 16:59:52 -0800236 mhcd->vbus_on = true;
Manu Gautam91223e02011-11-08 15:27:22 +0530237 } else {
238 ret = regulator_disable(mhcd->vbus);
239 if (ret) {
240 pr_err("unable to disable vbus\n");
241 return;
242 }
Hemant Kumar56925352012-02-13 16:59:52 -0800243 mhcd->vbus_on = false;
Manu Gautam91223e02011-11-08 15:27:22 +0530244 }
245}
246
Hemant Kumar56925352012-02-13 16:59:52 -0800247static irqreturn_t msm_ehci_dock_connect_irq(int irq, void *data)
248{
249 const struct msm_usb_host_platform_data *pdata;
250 struct msm_hcd *mhcd = data;
251 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
252
253 pdata = mhcd->dev->platform_data;
254
255 if (atomic_read(&mhcd->in_lpm))
256 usb_hcd_resume_root_hub(hcd);
257
258 if (irq_read_line(pdata->dock_connect_irq)) {
259 dev_dbg(mhcd->dev, "%s:Dock removed disable vbus\n", __func__);
260 msm_ehci_vbus_power(mhcd, 0);
261 } else {
262 dev_dbg(mhcd->dev, "%s:Dock connected enable vbus\n", __func__);
263 msm_ehci_vbus_power(mhcd, 1);
264 }
265
266 return IRQ_HANDLED;
267}
268
269static int msm_ehci_init_vbus(struct msm_hcd *mhcd, int init)
270{
271 int rc = 0;
272 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
273 const struct msm_usb_host_platform_data *pdata;
274
275 pdata = mhcd->dev->platform_data;
276
277 if (!init) {
Hemant Kumar56925352012-02-13 16:59:52 -0800278 if (pdata && pdata->dock_connect_irq)
279 free_irq(pdata->dock_connect_irq, mhcd);
280 return rc;
281 }
282
Mayank Rana2f416c22012-03-24 05:23:25 +0530283 mhcd->vbus = devm_regulator_get(mhcd->dev, "vbus");
Hemant Kumar56925352012-02-13 16:59:52 -0800284 if (IS_ERR(mhcd->vbus)) {
285 pr_err("Unable to get vbus\n");
286 return -ENODEV;
287 }
288
289 if (pdata) {
290 hcd->power_budget = pdata->power_budget;
291
292 if (pdata->dock_connect_irq) {
293 rc = request_threaded_irq(pdata->dock_connect_irq, NULL,
294 msm_ehci_dock_connect_irq,
295 IRQF_TRIGGER_FALLING |
296 IRQF_TRIGGER_RISING |
297 IRQF_ONESHOT, "msm_ehci_host", mhcd);
298 if (!rc)
299 enable_irq_wake(pdata->dock_connect_irq);
300 }
301 }
302 return rc;
303}
304
Manu Gautam91223e02011-11-08 15:27:22 +0530305static int msm_ehci_ldo_enable(struct msm_hcd *mhcd, int on)
306{
307 int ret = 0;
308
309 if (IS_ERR(mhcd->hsusb_1p8)) {
310 dev_err(mhcd->dev, "%s: HSUSB_1p8 is not initialized\n",
311 __func__);
312 return -ENODEV;
313 }
314
315 if (IS_ERR(mhcd->hsusb_3p3)) {
316 dev_err(mhcd->dev, "%s: HSUSB_3p3 is not initialized\n",
317 __func__);
318 return -ENODEV;
319 }
320
321 if (on) {
322 ret = regulator_set_optimum_mode(mhcd->hsusb_1p8,
323 HSUSB_PHY_1P8_HPM_LOAD);
324 if (ret < 0) {
325 dev_err(mhcd->dev, "%s: Unable to set HPM of the"
326 " regulator: HSUSB_1p8\n", __func__);
327 return ret;
328 }
329
330 ret = regulator_enable(mhcd->hsusb_1p8);
331 if (ret) {
332 dev_err(mhcd->dev, "%s: unable to enable the hsusb"
333 " 1p8\n", __func__);
334 regulator_set_optimum_mode(mhcd->hsusb_1p8, 0);
335 return ret;
336 }
337
338 ret = regulator_set_optimum_mode(mhcd->hsusb_3p3,
339 HSUSB_PHY_3P3_HPM_LOAD);
340 if (ret < 0) {
341 dev_err(mhcd->dev, "%s: Unable to set HPM of the "
342 "regulator: HSUSB_3p3\n", __func__);
343 regulator_set_optimum_mode(mhcd->hsusb_1p8, 0);
344 regulator_disable(mhcd->hsusb_1p8);
345 return ret;
346 }
347
348 ret = regulator_enable(mhcd->hsusb_3p3);
349 if (ret) {
350 dev_err(mhcd->dev, "%s: unable to enable the "
351 "hsusb 3p3\n", __func__);
352 regulator_set_optimum_mode(mhcd->hsusb_3p3, 0);
353 regulator_set_optimum_mode(mhcd->hsusb_1p8, 0);
354 regulator_disable(mhcd->hsusb_1p8);
355 return ret;
356 }
357
358 } else {
359 ret = regulator_disable(mhcd->hsusb_1p8);
360 if (ret) {
361 dev_err(mhcd->dev, "%s: unable to disable the "
362 "hsusb 1p8\n", __func__);
363 return ret;
364 }
365
366 ret = regulator_set_optimum_mode(mhcd->hsusb_1p8, 0);
367 if (ret < 0)
368 dev_err(mhcd->dev, "%s: Unable to set LPM of the "
369 "regulator: HSUSB_1p8\n", __func__);
370
371 ret = regulator_disable(mhcd->hsusb_3p3);
372 if (ret) {
373 dev_err(mhcd->dev, "%s: unable to disable the "
374 "hsusb 3p3\n", __func__);
375 return ret;
376 }
377 ret = regulator_set_optimum_mode(mhcd->hsusb_3p3, 0);
378 if (ret < 0)
379 dev_err(mhcd->dev, "%s: Unable to set LPM of the "
380 "regulator: HSUSB_3p3\n", __func__);
381 }
382
383 dev_dbg(mhcd->dev, "reg (%s)\n", on ? "HPM" : "LPM");
384
385 return ret < 0 ? ret : 0;
386}
387
388
389#define ULPI_IO_TIMEOUT_USECS (10 * 1000)
390static int msm_ulpi_read(struct msm_hcd *mhcd, u32 reg)
391{
392 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
393 unsigned long timeout;
394
395 /* initiate read operation */
396 writel_relaxed(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg),
397 USB_ULPI_VIEWPORT);
398
399 /* wait for completion */
400 timeout = jiffies + usecs_to_jiffies(ULPI_IO_TIMEOUT_USECS);
401 while (readl_relaxed(USB_ULPI_VIEWPORT) & ULPI_RUN) {
402 if (time_after(jiffies, timeout)) {
403 dev_err(mhcd->dev, "msm_ulpi_read: timeout %08x\n",
404 readl_relaxed(USB_ULPI_VIEWPORT));
405 return -ETIMEDOUT;
406 }
407 udelay(1);
408 }
409
410 return ULPI_DATA_READ(readl_relaxed(USB_ULPI_VIEWPORT));
411}
412
413
414static int msm_ulpi_write(struct msm_hcd *mhcd, u32 val, u32 reg)
415{
416 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
417 unsigned long timeout;
418
419 /* initiate write operation */
420 writel_relaxed(ULPI_RUN | ULPI_WRITE |
421 ULPI_ADDR(reg) | ULPI_DATA(val),
422 USB_ULPI_VIEWPORT);
423
424 /* wait for completion */
425 timeout = jiffies + usecs_to_jiffies(ULPI_IO_TIMEOUT_USECS);
426 while (readl_relaxed(USB_ULPI_VIEWPORT) & ULPI_RUN) {
427 if (time_after(jiffies, timeout)) {
428 dev_err(mhcd->dev, "msm_ulpi_write: timeout\n");
429 return -ETIMEDOUT;
430 }
431 udelay(1);
432 }
433
434 return 0;
435}
436
437static int msm_ehci_link_clk_reset(struct msm_hcd *mhcd, bool assert)
438{
439 int ret;
440
441 if (assert) {
442 ret = clk_reset(mhcd->alt_core_clk, CLK_RESET_ASSERT);
443 if (ret)
444 dev_err(mhcd->dev, "usb alt_core_clk assert failed\n");
445 } else {
446 ret = clk_reset(mhcd->alt_core_clk, CLK_RESET_DEASSERT);
447 if (ret)
448 dev_err(mhcd->dev, "usb alt_core_clk deassert failed\n");
449 }
450
451 return ret;
452}
453
454static int msm_ehci_phy_reset(struct msm_hcd *mhcd)
455{
456 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
457 u32 val;
458 int ret;
459 int retries;
460
461 ret = msm_ehci_link_clk_reset(mhcd, 1);
462 if (ret)
463 return ret;
464
465 udelay(1);
466
467 ret = msm_ehci_link_clk_reset(mhcd, 0);
468 if (ret)
469 return ret;
470
471 val = readl_relaxed(USB_PORTSC) & ~PORTSC_PTS_MASK;
472 writel_relaxed(val | PORTSC_PTS_ULPI, USB_PORTSC);
473
474 for (retries = 3; retries > 0; retries--) {
475 ret = msm_ulpi_write(mhcd, ULPI_FUNC_CTRL_SUSPENDM,
476 ULPI_CLR(ULPI_FUNC_CTRL));
477 if (!ret)
478 break;
479 }
480 if (!retries)
481 return -ETIMEDOUT;
482
483 /* Wakeup the PHY with a reg-access for calibration */
484 for (retries = 3; retries > 0; retries--) {
485 ret = msm_ulpi_read(mhcd, ULPI_DEBUG);
486 if (ret != -ETIMEDOUT)
487 break;
488 }
489 if (!retries)
490 return -ETIMEDOUT;
491
492 dev_info(mhcd->dev, "phy_reset: success\n");
493
494 return 0;
495}
496
497#define LINK_RESET_TIMEOUT_USEC (250 * 1000)
498static int msm_hsusb_reset(struct msm_hcd *mhcd)
499{
500 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
501 unsigned long timeout;
502 int ret;
503
504 clk_prepare_enable(mhcd->alt_core_clk);
505 ret = msm_ehci_phy_reset(mhcd);
506 if (ret) {
507 dev_err(mhcd->dev, "phy_reset failed\n");
508 return ret;
509 }
510
511 writel_relaxed(USBCMD_RESET, USB_USBCMD);
512
513 timeout = jiffies + usecs_to_jiffies(LINK_RESET_TIMEOUT_USEC);
514 while (readl_relaxed(USB_USBCMD) & USBCMD_RESET) {
515 if (time_after(jiffies, timeout))
516 return -ETIMEDOUT;
517 udelay(1);
518 }
519
520 /* select ULPI phy */
521 writel_relaxed(0x80000000, USB_PORTSC);
522
523 msleep(100);
524
525 writel_relaxed(0x0, USB_AHBBURST);
Vijayavardhan Vennapusa5f32d7a2012-03-14 16:30:26 +0530526 writel_relaxed(0x08, USB_AHBMODE);
Manu Gautam91223e02011-11-08 15:27:22 +0530527
528 /* Ensure that RESET operation is completed before turning off clock */
529 mb();
530 clk_disable_unprepare(mhcd->alt_core_clk);
531
532 /*rising edge interrupts with Dp rise and fall enabled*/
533 msm_ulpi_write(mhcd, ULPI_INT_DP, ULPI_USB_INT_EN_RISE);
534 msm_ulpi_write(mhcd, ULPI_INT_DP, ULPI_USB_INT_EN_FALL);
535
536 /*Clear the PHY interrupts by reading the PHY interrupt latch register*/
537 msm_ulpi_read(mhcd, ULPI_USB_INT_LATCH);
538
539 return 0;
540}
541
542#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)
543#define PHY_RESUME_TIMEOUT_USEC (100 * 1000)
544
545#ifdef CONFIG_PM_SLEEP
546static int msm_ehci_suspend(struct msm_hcd *mhcd)
547{
548 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
549 unsigned long timeout;
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700550 int ret;
Manu Gautam91223e02011-11-08 15:27:22 +0530551 u32 portsc;
552
553 if (atomic_read(&mhcd->in_lpm)) {
554 dev_dbg(mhcd->dev, "%s called in lpm\n", __func__);
555 return 0;
556 }
557
558 disable_irq(hcd->irq);
559
560 /* Set the PHCD bit, only if it is not set by the controller.
561 * PHY may take some time or even fail to enter into low power
562 * mode (LPM). Hence poll for 500 msec and reset the PHY and link
563 * in failure case.
564 */
565 portsc = readl_relaxed(USB_PORTSC);
566 if (!(portsc & PORTSC_PHCD)) {
567 writel_relaxed(portsc | PORTSC_PHCD,
568 USB_PORTSC);
569
570 timeout = jiffies + usecs_to_jiffies(PHY_SUSPEND_TIMEOUT_USEC);
571 while (!(readl_relaxed(USB_PORTSC) & PORTSC_PHCD)) {
572 if (time_after(jiffies, timeout)) {
573 dev_err(mhcd->dev, "Unable to suspend PHY\n");
574 msm_hsusb_reset(mhcd);
575 break;
576 }
577 udelay(1);
578 }
579 }
580
581 /*
582 * PHY has capability to generate interrupt asynchronously in low
583 * power mode (LPM). This interrupt is level triggered. So USB IRQ
584 * line must be disabled till async interrupt enable bit is cleared
585 * in USBCMD register. Assert STP (ULPI interface STOP signal) to
586 * block data communication from PHY.
587 */
588 writel_relaxed(readl_relaxed(USB_USBCMD) | ASYNC_INTR_CTRL |
589 ULPI_STP_CTRL, USB_USBCMD);
590
591 /*
592 * Ensure that hardware is put in low power mode before
593 * clocks are turned OFF and VDD is allowed to minimize.
594 */
595 mb();
596
597 clk_disable_unprepare(mhcd->iface_clk);
598 clk_disable_unprepare(mhcd->core_clk);
599
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700600 /* usb phy does not require TCXO clock, hence vote for TCXO disable */
601 ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_OFF);
602 if (ret)
603 dev_err(mhcd->dev, "%s failed to devote for "
604 "TCXO D0 buffer%d\n", __func__, ret);
605
Manu Gautam91223e02011-11-08 15:27:22 +0530606 msm_ehci_config_vddcx(mhcd, 0);
607
608 atomic_set(&mhcd->in_lpm, 1);
609 enable_irq(hcd->irq);
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530610 if (mhcd->pmic_gpio_dp_irq) {
611 mhcd->pmic_gpio_dp_irq_enabled = 1;
612 enable_irq_wake(mhcd->pmic_gpio_dp_irq);
613 enable_irq(mhcd->pmic_gpio_dp_irq);
614 }
Manu Gautam91223e02011-11-08 15:27:22 +0530615 wake_unlock(&mhcd->wlock);
616
617 dev_info(mhcd->dev, "EHCI USB in low power mode\n");
618
619 return 0;
620}
621
622static int msm_ehci_resume(struct msm_hcd *mhcd)
623{
624 struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
625 unsigned long timeout;
626 unsigned temp;
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700627 int ret;
Manu Gautam91223e02011-11-08 15:27:22 +0530628
629 if (!atomic_read(&mhcd->in_lpm)) {
630 dev_dbg(mhcd->dev, "%s called in !in_lpm\n", __func__);
631 return 0;
632 }
633
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530634 if (mhcd->pmic_gpio_dp_irq_enabled) {
635 disable_irq_wake(mhcd->pmic_gpio_dp_irq);
636 disable_irq_nosync(mhcd->pmic_gpio_dp_irq);
637 mhcd->pmic_gpio_dp_irq_enabled = 0;
638 }
Manu Gautam91223e02011-11-08 15:27:22 +0530639 wake_lock(&mhcd->wlock);
640
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700641 /* Vote for TCXO when waking up the phy */
642 ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_ON);
643 if (ret)
644 dev_err(mhcd->dev, "%s failed to vote for "
645 "TCXO D0 buffer%d\n", __func__, ret);
646
Manu Gautam91223e02011-11-08 15:27:22 +0530647 clk_prepare_enable(mhcd->core_clk);
648 clk_prepare_enable(mhcd->iface_clk);
649
650 msm_ehci_config_vddcx(mhcd, 1);
651
652 temp = readl_relaxed(USB_USBCMD);
653 temp &= ~ASYNC_INTR_CTRL;
654 temp &= ~ULPI_STP_CTRL;
655 writel_relaxed(temp, USB_USBCMD);
656
657 if (!(readl_relaxed(USB_PORTSC) & PORTSC_PHCD))
658 goto skip_phy_resume;
659
660 temp = readl_relaxed(USB_PORTSC) & ~PORTSC_PHCD;
661 writel_relaxed(temp, USB_PORTSC);
662
663 timeout = jiffies + usecs_to_jiffies(PHY_RESUME_TIMEOUT_USEC);
664 while ((readl_relaxed(USB_PORTSC) & PORTSC_PHCD) ||
665 !(readl_relaxed(USB_ULPI_VIEWPORT) & ULPI_SYNC_STATE)) {
666 if (time_after(jiffies, timeout)) {
667 /*This is a fatal error. Reset the link and PHY*/
668 dev_err(mhcd->dev, "Unable to resume USB. Resetting the h/w\n");
669 msm_hsusb_reset(mhcd);
670 break;
671 }
672 udelay(1);
673 }
674
675skip_phy_resume:
676
Chiranjeevi Velempati35d46ab2012-07-18 20:36:53 +0530677 usb_hcd_resume_root_hub(hcd);
Manu Gautam91223e02011-11-08 15:27:22 +0530678 atomic_set(&mhcd->in_lpm, 0);
679
680 if (mhcd->async_int) {
681 mhcd->async_int = false;
682 pm_runtime_put_noidle(mhcd->dev);
683 enable_irq(hcd->irq);
684 }
685
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530686 if (atomic_read(&mhcd->pm_usage_cnt)) {
687 atomic_set(&mhcd->pm_usage_cnt, 0);
688 pm_runtime_put_noidle(mhcd->dev);
689 }
690
Manu Gautam91223e02011-11-08 15:27:22 +0530691 dev_info(mhcd->dev, "EHCI USB exited from low power mode\n");
692
693 return 0;
694}
695#endif
696
697static irqreturn_t msm_ehci_irq(struct usb_hcd *hcd)
698{
699 struct msm_hcd *mhcd = hcd_to_mhcd(hcd);
700
701 if (atomic_read(&mhcd->in_lpm)) {
702 disable_irq_nosync(hcd->irq);
703 mhcd->async_int = true;
704 pm_runtime_get(mhcd->dev);
705 return IRQ_HANDLED;
706 }
707
708 return ehci_irq(hcd);
709}
710
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530711static irqreturn_t msm_ehci_host_wakeup_irq(int irq, void *data)
712{
713
714 struct msm_hcd *mhcd = data;
715
716 mhcd->pmic_gpio_int_cnt++;
717 dev_dbg(mhcd->dev, "%s: hsusb host remote wakeup interrupt cnt: %u\n",
718 __func__, mhcd->pmic_gpio_int_cnt);
719
720
721 wake_lock(&mhcd->wlock);
722
723 if (mhcd->pmic_gpio_dp_irq_enabled) {
724 mhcd->pmic_gpio_dp_irq_enabled = 0;
725 disable_irq_wake(irq);
726 disable_irq_nosync(irq);
727 }
728
729 if (!atomic_read(&mhcd->pm_usage_cnt)) {
730 atomic_set(&mhcd->pm_usage_cnt, 1);
731 pm_runtime_get(mhcd->dev);
732 }
733
734 return IRQ_HANDLED;
735}
736
Manu Gautam91223e02011-11-08 15:27:22 +0530737static int msm_ehci_reset(struct usb_hcd *hcd)
738{
739 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
740 int retval;
741
742 ehci->caps = USB_CAPLENGTH;
743 ehci->regs = USB_CAPLENGTH +
744 HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
745 dbg_hcs_params(ehci, "reset");
746 dbg_hcc_params(ehci, "reset");
747
748 /* cache the data to minimize the chip reads*/
749 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
750
751 hcd->has_tt = 1;
752 ehci->sbrn = HCD_USB2;
753
754 retval = ehci_halt(ehci);
755 if (retval)
756 return retval;
757
758 /* data structure init */
759 retval = ehci_init(hcd);
760 if (retval)
761 return retval;
762
763 retval = ehci_reset(ehci);
764 if (retval)
765 return retval;
766
767 /* bursts of unspecified length. */
768 writel_relaxed(0, USB_AHBBURST);
769 /* Use the AHB transactor */
Vijayavardhan Vennapusa5f32d7a2012-03-14 16:30:26 +0530770 writel_relaxed(0x08, USB_AHBMODE);
Manu Gautam91223e02011-11-08 15:27:22 +0530771 /* Disable streaming mode and select host mode */
772 writel_relaxed(0x13, USB_USBMODE);
773
774 ehci_port_power(ehci, 1);
775 return 0;
776}
777
778static struct hc_driver msm_hc2_driver = {
779 .description = hcd_name,
780 .product_desc = "Qualcomm EHCI Host Controller",
781 .hcd_priv_size = sizeof(struct msm_hcd),
782
783 /*
784 * generic hardware linkage
785 */
786 .irq = msm_ehci_irq,
787 .flags = HCD_USB2 | HCD_MEMORY,
788
789 .reset = msm_ehci_reset,
790 .start = ehci_run,
791
792 .stop = ehci_stop,
793 .shutdown = ehci_shutdown,
794
795 /*
796 * managing i/o requests and associated device resources
797 */
798 .urb_enqueue = ehci_urb_enqueue,
799 .urb_dequeue = ehci_urb_dequeue,
800 .endpoint_disable = ehci_endpoint_disable,
801 .endpoint_reset = ehci_endpoint_reset,
802 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
803
804 /*
805 * scheduling support
806 */
807 .get_frame_number = ehci_get_frame,
808
809 /*
810 * root hub support
811 */
812 .hub_status_data = ehci_hub_status_data,
813 .hub_control = ehci_hub_control,
814 .relinquish_port = ehci_relinquish_port,
815 .port_handed_over = ehci_port_handed_over,
816
817 /*
818 * PM support
819 */
820 .bus_suspend = ehci_bus_suspend,
821 .bus_resume = ehci_bus_resume,
822};
823
824static int msm_ehci_init_clocks(struct msm_hcd *mhcd, u32 init)
825{
826 int ret = 0;
827
828 if (!init)
829 goto put_clocks;
830
831 /* 60MHz alt_core_clk is for LINK to be used during PHY RESET */
832 mhcd->alt_core_clk = clk_get(mhcd->dev, "alt_core_clk");
833 if (IS_ERR(mhcd->alt_core_clk)) {
834 dev_err(mhcd->dev, "failed to get alt_core_clk\n");
835 ret = PTR_ERR(mhcd->alt_core_clk);
836 return ret;
837 }
838 clk_set_rate(mhcd->alt_core_clk, 60000000);
839
840 /* iface_clk is required for data transfers */
841 mhcd->iface_clk = clk_get(mhcd->dev, "iface_clk");
842 if (IS_ERR(mhcd->iface_clk)) {
843 dev_err(mhcd->dev, "failed to get iface_clk\n");
844 ret = PTR_ERR(mhcd->iface_clk);
845 goto put_alt_core_clk;
846 }
847
848 /* Link's protocol engine is based on pclk which must
849 * be running >55Mhz and frequency should also not change.
850 * Hence, vote for maximum clk frequency on its source
851 */
852 mhcd->core_clk = clk_get(mhcd->dev, "core_clk");
853 if (IS_ERR(mhcd->core_clk)) {
854 dev_err(mhcd->dev, "failed to get core_clk\n");
855 ret = PTR_ERR(mhcd->core_clk);
856 goto put_iface_clk;
857 }
858 clk_set_rate(mhcd->core_clk, INT_MAX);
859
860 clk_prepare_enable(mhcd->core_clk);
861 clk_prepare_enable(mhcd->iface_clk);
862
863 return 0;
864
865put_clocks:
866 clk_disable_unprepare(mhcd->iface_clk);
867 clk_disable_unprepare(mhcd->core_clk);
868 clk_put(mhcd->core_clk);
869put_iface_clk:
870 clk_put(mhcd->iface_clk);
871put_alt_core_clk:
872 clk_put(mhcd->alt_core_clk);
873
874 return ret;
875}
876
877static int __devinit ehci_msm2_probe(struct platform_device *pdev)
878{
879 struct usb_hcd *hcd;
880 struct resource *res;
881 struct msm_hcd *mhcd;
Hemant Kumar56925352012-02-13 16:59:52 -0800882 const struct msm_usb_host_platform_data *pdata;
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700883 char pdev_name[PDEV_NAME_LEN];
Manu Gautam91223e02011-11-08 15:27:22 +0530884 int ret;
885
886 dev_dbg(&pdev->dev, "ehci_msm2 probe\n");
887
888 hcd = usb_create_hcd(&msm_hc2_driver, &pdev->dev,
889 dev_name(&pdev->dev));
890 if (!hcd) {
891 dev_err(&pdev->dev, "Unable to create HCD\n");
892 return -ENOMEM;
893 }
894
895 hcd->irq = platform_get_irq(pdev, 0);
896 if (hcd->irq < 0) {
897 dev_err(&pdev->dev, "Unable to get IRQ resource\n");
898 ret = hcd->irq;
899 goto put_hcd;
900 }
901
902 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
903 if (!res) {
904 dev_err(&pdev->dev, "Unable to get memory resource\n");
905 ret = -ENODEV;
906 goto put_hcd;
907 }
908
909 hcd->rsrc_start = res->start;
910 hcd->rsrc_len = resource_size(res);
911 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
912 if (!hcd->regs) {
913 dev_err(&pdev->dev, "ioremap failed\n");
914 ret = -ENOMEM;
915 goto put_hcd;
916 }
917
918 mhcd = hcd_to_mhcd(hcd);
919 mhcd->dev = &pdev->dev;
920
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700921 snprintf(pdev_name, PDEV_NAME_LEN, "%s.%d", pdev->name, pdev->id);
922 mhcd->xo_handle = msm_xo_get(MSM_XO_TCXO_D0, pdev_name);
923 if (IS_ERR(mhcd->xo_handle)) {
924 dev_err(&pdev->dev, "%s not able to get the handle "
925 "to vote for TCXO D0 buffer\n", __func__);
926 ret = PTR_ERR(mhcd->xo_handle);
927 goto unmap;
928 }
929
930 ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_ON);
931 if (ret) {
932 dev_err(&pdev->dev, "%s failed to vote for TCXO "
933 "D0 buffer%d\n", __func__, ret);
934 goto free_xo_handle;
935 }
936
Manu Gautam91223e02011-11-08 15:27:22 +0530937 ret = msm_ehci_init_clocks(mhcd, 1);
938 if (ret) {
939 dev_err(&pdev->dev, "unable to initialize clocks\n");
940 ret = -ENODEV;
Hemant Kumar8c0f2a82012-05-03 19:17:26 -0700941 goto devote_xo_handle;
Manu Gautam91223e02011-11-08 15:27:22 +0530942 }
943
944 ret = msm_ehci_init_vddcx(mhcd, 1);
945 if (ret) {
946 dev_err(&pdev->dev, "unable to initialize VDDCX\n");
947 ret = -ENODEV;
948 goto deinit_clocks;
949 }
950
951 ret = msm_ehci_config_vddcx(mhcd, 1);
952 if (ret) {
953 dev_err(&pdev->dev, "hsusb vddcx configuration failed\n");
954 goto deinit_vddcx;
955 }
956
957 ret = msm_ehci_ldo_init(mhcd, 1);
958 if (ret) {
959 dev_err(&pdev->dev, "hsusb vreg configuration failed\n");
960 goto deinit_vddcx;
961 }
962
963 ret = msm_ehci_ldo_enable(mhcd, 1);
964 if (ret) {
965 dev_err(&pdev->dev, "hsusb vreg enable failed\n");
966 goto deinit_ldo;
967 }
968
969 ret = msm_ehci_init_vbus(mhcd, 1);
970 if (ret) {
971 dev_err(&pdev->dev, "unable to get vbus\n");
972 goto disable_ldo;
973 }
974
975 ret = msm_hsusb_reset(mhcd);
976 if (ret) {
977 dev_err(&pdev->dev, "hsusb PHY initialization failed\n");
978 goto vbus_deinit;
979 }
980
981 ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
982 if (ret) {
983 dev_err(&pdev->dev, "unable to register HCD\n");
984 goto vbus_deinit;
985 }
986
Hemant Kumar56925352012-02-13 16:59:52 -0800987 pdata = mhcd->dev->platform_data;
988 if (pdata && (!pdata->dock_connect_irq ||
989 !irq_read_line(pdata->dock_connect_irq)))
990 msm_ehci_vbus_power(mhcd, 1);
Manu Gautam91223e02011-11-08 15:27:22 +0530991
992 device_init_wakeup(&pdev->dev, 1);
993 wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev));
994 wake_lock(&mhcd->wlock);
995 /*
996 * This pdev->dev is assigned parent of root-hub by USB core,
997 * hence, runtime framework automatically calls this driver's
998 * runtime APIs based on root-hub's state.
999 */
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +05301000 /* configure pmic_gpio_irq for D+ change */
1001 if (pdata && pdata->pmic_gpio_dp_irq)
1002 mhcd->pmic_gpio_dp_irq = pdata->pmic_gpio_dp_irq;
1003 if (mhcd->pmic_gpio_dp_irq) {
1004 ret = request_threaded_irq(mhcd->pmic_gpio_dp_irq, NULL,
1005 msm_ehci_host_wakeup_irq,
1006 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
1007 "msm_ehci_host_wakeup", mhcd);
1008 if (!ret) {
1009 disable_irq_nosync(mhcd->pmic_gpio_dp_irq);
1010 } else {
1011 dev_err(&pdev->dev, "request_irq(%d) failed: %d\n",
1012 mhcd->pmic_gpio_dp_irq, ret);
1013 mhcd->pmic_gpio_dp_irq = 0;
1014 }
1015 }
Manu Gautam91223e02011-11-08 15:27:22 +05301016 pm_runtime_set_active(&pdev->dev);
1017 pm_runtime_enable(&pdev->dev);
1018
1019 return 0;
1020
1021vbus_deinit:
1022 msm_ehci_init_vbus(mhcd, 0);
1023disable_ldo:
1024 msm_ehci_ldo_enable(mhcd, 0);
1025deinit_ldo:
1026 msm_ehci_ldo_init(mhcd, 0);
1027deinit_vddcx:
1028 msm_ehci_init_vddcx(mhcd, 0);
1029deinit_clocks:
1030 msm_ehci_init_clocks(mhcd, 0);
Hemant Kumar8c0f2a82012-05-03 19:17:26 -07001031devote_xo_handle:
1032 msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_OFF);
1033free_xo_handle:
1034 msm_xo_put(mhcd->xo_handle);
Manu Gautam91223e02011-11-08 15:27:22 +05301035unmap:
1036 iounmap(hcd->regs);
1037put_hcd:
1038 usb_put_hcd(hcd);
1039
1040 return ret;
1041}
1042
1043static int __devexit ehci_msm2_remove(struct platform_device *pdev)
1044{
1045 struct usb_hcd *hcd = platform_get_drvdata(pdev);
1046 struct msm_hcd *mhcd = hcd_to_mhcd(hcd);
1047
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +05301048 if (mhcd->pmic_gpio_dp_irq) {
1049 if (mhcd->pmic_gpio_dp_irq_enabled)
1050 disable_irq_wake(mhcd->pmic_gpio_dp_irq);
1051 free_irq(mhcd->pmic_gpio_dp_irq, mhcd);
1052 }
Manu Gautam91223e02011-11-08 15:27:22 +05301053 device_init_wakeup(&pdev->dev, 0);
1054 pm_runtime_disable(&pdev->dev);
1055 pm_runtime_set_suspended(&pdev->dev);
1056
1057 usb_remove_hcd(hcd);
Hemant Kumar56925352012-02-13 16:59:52 -08001058
Hemant Kumar8c0f2a82012-05-03 19:17:26 -07001059 msm_xo_put(mhcd->xo_handle);
Manu Gautam91223e02011-11-08 15:27:22 +05301060 msm_ehci_vbus_power(mhcd, 0);
1061 msm_ehci_init_vbus(mhcd, 0);
1062 msm_ehci_ldo_enable(mhcd, 0);
1063 msm_ehci_ldo_init(mhcd, 0);
1064 msm_ehci_init_vddcx(mhcd, 0);
1065
1066 msm_ehci_init_clocks(mhcd, 0);
1067 wake_lock_destroy(&mhcd->wlock);
1068 iounmap(hcd->regs);
1069 usb_put_hcd(hcd);
1070
1071 return 0;
1072}
1073
1074#ifdef CONFIG_PM_SLEEP
1075static int ehci_msm2_pm_suspend(struct device *dev)
1076{
1077 struct usb_hcd *hcd = dev_get_drvdata(dev);
1078 struct msm_hcd *mhcd = hcd_to_mhcd(hcd);
1079
1080 dev_dbg(dev, "ehci-msm2 PM suspend\n");
1081
1082 if (device_may_wakeup(dev))
1083 enable_irq_wake(hcd->irq);
1084
1085 return msm_ehci_suspend(mhcd);
1086
1087}
1088
1089static int ehci_msm2_pm_resume(struct device *dev)
1090{
1091 int ret;
1092 struct usb_hcd *hcd = dev_get_drvdata(dev);
1093 struct msm_hcd *mhcd = hcd_to_mhcd(hcd);
1094
1095 dev_dbg(dev, "ehci-msm2 PM resume\n");
1096
1097 if (device_may_wakeup(dev))
1098 disable_irq_wake(hcd->irq);
1099
1100 ret = msm_ehci_resume(mhcd);
1101 if (ret)
1102 return ret;
1103
1104 /* Bring the device to full powered state upon system resume */
1105 pm_runtime_disable(dev);
1106 pm_runtime_set_active(dev);
1107 pm_runtime_enable(dev);
1108
1109 return 0;
1110}
1111#endif
1112
1113#ifdef CONFIG_PM_RUNTIME
1114static int ehci_msm2_runtime_idle(struct device *dev)
1115{
1116 dev_dbg(dev, "EHCI runtime idle\n");
1117
1118 return 0;
1119}
1120
1121static int ehci_msm2_runtime_suspend(struct device *dev)
1122{
1123 struct usb_hcd *hcd = dev_get_drvdata(dev);
1124 struct msm_hcd *mhcd = hcd_to_mhcd(hcd);
1125
1126 dev_dbg(dev, "EHCI runtime suspend\n");
1127 return msm_ehci_suspend(mhcd);
1128}
1129
1130static int ehci_msm2_runtime_resume(struct device *dev)
1131{
1132 struct usb_hcd *hcd = dev_get_drvdata(dev);
1133 struct msm_hcd *mhcd = hcd_to_mhcd(hcd);
1134
1135 dev_dbg(dev, "EHCI runtime resume\n");
1136 return msm_ehci_resume(mhcd);
1137}
1138#endif
1139
1140#ifdef CONFIG_PM
1141static const struct dev_pm_ops ehci_msm2_dev_pm_ops = {
1142 SET_SYSTEM_SLEEP_PM_OPS(ehci_msm2_pm_suspend, ehci_msm2_pm_resume)
1143 SET_RUNTIME_PM_OPS(ehci_msm2_runtime_suspend, ehci_msm2_runtime_resume,
1144 ehci_msm2_runtime_idle)
1145};
1146#endif
1147
1148static struct platform_driver ehci_msm2_driver = {
1149 .probe = ehci_msm2_probe,
1150 .remove = __devexit_p(ehci_msm2_remove),
1151 .driver = {
1152 .name = "msm_ehci_host",
1153#ifdef CONFIG_PM
1154 .pm = &ehci_msm2_dev_pm_ops,
1155#endif
1156 },
1157};