Merge branch 'for-3.11' of git://linux-nfs.org/~bfields/linux
[linux-2.6.git] / drivers / usb / chipidea / ci_hdrc_msm.c
blobfb657ef50a9c1f3c0924d35308b66a05686a9a6d
1 /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 */
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/pm_runtime.h>
11 #include <linux/usb/msm_hsusb_hw.h>
12 #include <linux/usb/ulpi.h>
13 #include <linux/usb/gadget.h>
14 #include <linux/usb/chipidea.h>
16 #include "ci.h"
18 #define MSM_USB_BASE (ci->hw_bank.abs)
20 static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
22 struct device *dev = ci->gadget.dev.parent;
23 int val;
25 switch (event) {
26 case CI_HDRC_CONTROLLER_RESET_EVENT:
27 dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n");
28 writel(0, USB_AHBBURST);
29 writel(0, USB_AHBMODE);
30 break;
31 case CI_HDRC_CONTROLLER_STOPPED_EVENT:
32 dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n");
34 * Put the transceiver in non-driving mode. Otherwise host
35 * may not detect soft-disconnection.
37 val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL);
38 val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
39 val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
40 usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL);
41 break;
42 default:
43 dev_dbg(dev, "unknown ci_hdrc event\n");
44 break;
48 static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
49 .name = "ci_hdrc_msm",
50 .flags = CI_HDRC_REGS_SHARED |
51 CI_HDRC_REQUIRE_TRANSCEIVER |
52 CI_HDRC_PULLUP_ON_VBUS |
53 CI_HDRC_DISABLE_STREAMING,
55 .notify_event = ci_hdrc_msm_notify_event,
58 static int ci_hdrc_msm_probe(struct platform_device *pdev)
60 struct platform_device *plat_ci;
62 dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n");
64 plat_ci = ci_hdrc_add_device(&pdev->dev,
65 pdev->resource, pdev->num_resources,
66 &ci_hdrc_msm_platdata);
67 if (IS_ERR(plat_ci)) {
68 dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n");
69 return PTR_ERR(plat_ci);
72 platform_set_drvdata(pdev, plat_ci);
74 pm_runtime_no_callbacks(&pdev->dev);
75 pm_runtime_enable(&pdev->dev);
77 return 0;
80 static int ci_hdrc_msm_remove(struct platform_device *pdev)
82 struct platform_device *plat_ci = platform_get_drvdata(pdev);
84 pm_runtime_disable(&pdev->dev);
85 ci_hdrc_remove_device(plat_ci);
87 return 0;
90 static struct platform_driver ci_hdrc_msm_driver = {
91 .probe = ci_hdrc_msm_probe,
92 .remove = ci_hdrc_msm_remove,
93 .driver = { .name = "msm_hsusb", },
96 module_platform_driver(ci_hdrc_msm_driver);
98 MODULE_ALIAS("platform:msm_hsusb");
99 MODULE_ALIAS("platform:ci13xxx_msm");
100 MODULE_LICENSE("GPL v2");