Commit | Line | Data |
---|---|---|
33f82f38 PK |
1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. |
2 | * | |
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. | |
33f82f38 PK |
6 | */ |
7 | ||
8 | #include <linux/module.h> | |
9 | #include <linux/platform_device.h> | |
2d0cdcc5 | 10 | #include <linux/pm_runtime.h> |
33f82f38 PK |
11 | #include <linux/usb/msm_hsusb_hw.h> |
12 | #include <linux/usb/ulpi.h> | |
62bb84ed | 13 | #include <linux/usb/gadget.h> |
e443b333 | 14 | #include <linux/usb/chipidea.h> |
33f82f38 | 15 | |
e443b333 | 16 | #include "ci.h" |
33f82f38 | 17 | |
26c696c6 | 18 | #define MSM_USB_BASE (ci->hw_bank.abs) |
33f82f38 | 19 | |
8e22978c | 20 | static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) |
33f82f38 | 21 | { |
26c696c6 | 22 | struct device *dev = ci->gadget.dev.parent; |
33f82f38 PK |
23 | int val; |
24 | ||
25 | switch (event) { | |
8e22978c AS |
26 | case CI_HDRC_CONTROLLER_RESET_EVENT: |
27 | dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n"); | |
33f82f38 PK |
28 | writel(0, USB_AHBBURST); |
29 | writel(0, USB_AHBMODE); | |
30 | break; | |
8e22978c AS |
31 | case CI_HDRC_CONTROLLER_STOPPED_EVENT: |
32 | dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n"); | |
33f82f38 PK |
33 | /* |
34 | * Put the transceiver in non-driving mode. Otherwise host | |
35 | * may not detect soft-disconnection. | |
36 | */ | |
26c696c6 | 37 | val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL); |
33f82f38 PK |
38 | val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; |
39 | val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | |
26c696c6 | 40 | usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL); |
33f82f38 PK |
41 | break; |
42 | default: | |
8e22978c | 43 | dev_dbg(dev, "unknown ci_hdrc event\n"); |
33f82f38 PK |
44 | break; |
45 | } | |
46 | } | |
47 | ||
8e22978c AS |
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 | | |
8e22978c | 52 | CI_HDRC_DISABLE_STREAMING, |
33f82f38 | 53 | |
8e22978c | 54 | .notify_event = ci_hdrc_msm_notify_event, |
33f82f38 PK |
55 | }; |
56 | ||
8e22978c | 57 | static int ci_hdrc_msm_probe(struct platform_device *pdev) |
33f82f38 | 58 | { |
62bb84ed | 59 | struct platform_device *plat_ci; |
33f82f38 | 60 | |
8e22978c | 61 | dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n"); |
33f82f38 | 62 | |
8e22978c | 63 | plat_ci = ci_hdrc_add_device(&pdev->dev, |
cbc6dc2a | 64 | pdev->resource, pdev->num_resources, |
8e22978c | 65 | &ci_hdrc_msm_platdata); |
cbc6dc2a | 66 | if (IS_ERR(plat_ci)) { |
8e22978c | 67 | dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); |
cbc6dc2a | 68 | return PTR_ERR(plat_ci); |
33f82f38 PK |
69 | } |
70 | ||
6bf83594 FB |
71 | platform_set_drvdata(pdev, plat_ci); |
72 | ||
2d0cdcc5 PK |
73 | pm_runtime_no_callbacks(&pdev->dev); |
74 | pm_runtime_enable(&pdev->dev); | |
75 | ||
33f82f38 | 76 | return 0; |
33f82f38 PK |
77 | } |
78 | ||
8e22978c | 79 | static int ci_hdrc_msm_remove(struct platform_device *pdev) |
6bf83594 FB |
80 | { |
81 | struct platform_device *plat_ci = platform_get_drvdata(pdev); | |
82 | ||
83 | pm_runtime_disable(&pdev->dev); | |
8e22978c | 84 | ci_hdrc_remove_device(plat_ci); |
6bf83594 FB |
85 | |
86 | return 0; | |
87 | } | |
88 | ||
8e22978c AS |
89 | static struct platform_driver ci_hdrc_msm_driver = { |
90 | .probe = ci_hdrc_msm_probe, | |
91 | .remove = ci_hdrc_msm_remove, | |
33f82f38 PK |
92 | .driver = { .name = "msm_hsusb", }, |
93 | }; | |
94 | ||
8e22978c | 95 | module_platform_driver(ci_hdrc_msm_driver); |
4703d2e9 | 96 | |
6bf83594 | 97 | MODULE_ALIAS("platform:msm_hsusb"); |
8e22978c | 98 | MODULE_ALIAS("platform:ci13xxx_msm"); |
4703d2e9 | 99 | MODULE_LICENSE("GPL v2"); |