aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorIvan T. Ivanov <iivanov@mm-sol.com>2014-09-12 15:28:07 -0400
committerFelipe Balbi <balbi@ti.com>2014-09-12 16:43:48 -0400
commitd9152161b4bfd131a8253a5b9fcd8ba9b10277c4 (patch)
tree85a3099ad4ec5c20cce93501b5bc3a10c40c1c25 /drivers/usb
parentbbfc6cb720df16b0c3895ac75c9804dd8c728ba4 (diff)
usb: dwc3: Add Qualcomm DWC3 glue layer driver
DWC3 glue layer is hardware layer around Synopsys DesignWare USB3 core. Its purpose is to supply Synopsys IP with required clocks, voltages and interface it with the rest of the SoC. Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> Signed-off-by: Andy Gross <agross@codeaurora.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/dwc3/Kconfig8
-rw-r--r--drivers/usb/dwc3/Makefile1
-rw-r--r--drivers/usb/dwc3/dwc3-qcom.c131
3 files changed, 140 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 5238251ec653..f4e5cc60db0b 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -89,6 +89,14 @@ config USB_DWC3_ST
89 inside (i.e. STiH407). 89 inside (i.e. STiH407).
90 Say 'Y' or 'M' if you have one such device. 90 Say 'Y' or 'M' if you have one such device.
91 91
92config USB_DWC3_QCOM
93 tristate "Qualcomm Platforms"
94 depends on ARCH_QCOM || COMPILE_TEST
95 default USB_DWC3
96 help
97 Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside,
98 say 'Y' or 'M' if you have one such device.
99
92comment "Debugging features" 100comment "Debugging features"
93 101
94config USB_DWC3_DEBUG 102config USB_DWC3_DEBUG
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 3e88c77483c1..bb34fbcfeab3 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -36,4 +36,5 @@ obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o
36obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o 36obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o
37obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o 37obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
38obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o 38obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o
39obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o
39obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o 40obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
new file mode 100644
index 000000000000..611f8e7e8299
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -0,0 +1,131 @@
1/* Copyright (c) 2013-2014, The Linux Foundation. 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.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/clk.h>
14#include <linux/err.h>
15#include <linux/io.h>
16#include <linux/module.h>
17#include <linux/of.h>
18#include <linux/of_platform.h>
19#include <linux/platform_device.h>
20
21struct dwc3_qcom {
22 struct device *dev;
23
24 struct clk *core_clk;
25 struct clk *iface_clk;
26 struct clk *sleep_clk;
27};
28
29static int dwc3_qcom_probe(struct platform_device *pdev)
30{
31 struct device_node *node = pdev->dev.of_node;
32 struct dwc3_qcom *qdwc;
33 int ret;
34
35 qdwc = devm_kzalloc(&pdev->dev, sizeof(*qdwc), GFP_KERNEL);
36 if (!qdwc)
37 return -ENOMEM;
38
39 platform_set_drvdata(pdev, qdwc);
40
41 qdwc->dev = &pdev->dev;
42
43 qdwc->core_clk = devm_clk_get(qdwc->dev, "core");
44 if (IS_ERR(qdwc->core_clk)) {
45 dev_err(qdwc->dev, "failed to get core clock\n");
46 return PTR_ERR(qdwc->core_clk);
47 }
48
49 qdwc->iface_clk = devm_clk_get(qdwc->dev, "iface");
50 if (IS_ERR(qdwc->iface_clk)) {
51 dev_dbg(qdwc->dev, "failed to get optional iface clock\n");
52 qdwc->iface_clk = NULL;
53 }
54
55 qdwc->sleep_clk = devm_clk_get(qdwc->dev, "sleep");
56 if (IS_ERR(qdwc->sleep_clk)) {
57 dev_dbg(qdwc->dev, "failed to get optional sleep clock\n");
58 qdwc->sleep_clk = NULL;
59 }
60
61 ret = clk_prepare_enable(qdwc->core_clk);
62 if (ret) {
63 dev_err(qdwc->dev, "failed to enable core clock\n");
64 goto err_core;
65 }
66
67 ret = clk_prepare_enable(qdwc->iface_clk);
68 if (ret) {
69 dev_err(qdwc->dev, "failed to enable optional iface clock\n");
70 goto err_iface;
71 }
72
73 ret = clk_prepare_enable(qdwc->sleep_clk);
74 if (ret) {
75 dev_err(qdwc->dev, "failed to enable optional sleep clock\n");
76 goto err_sleep;
77 }
78
79 ret = of_platform_populate(node, NULL, NULL, qdwc->dev);
80 if (ret) {
81 dev_err(qdwc->dev, "failed to register core - %d\n", ret);
82 goto err_clks;
83 }
84
85 return 0;
86
87err_clks:
88 clk_disable_unprepare(qdwc->sleep_clk);
89err_sleep:
90 clk_disable_unprepare(qdwc->iface_clk);
91err_iface:
92 clk_disable_unprepare(qdwc->core_clk);
93err_core:
94 return ret;
95}
96
97static int dwc3_qcom_remove(struct platform_device *pdev)
98{
99 struct dwc3_qcom *qdwc = platform_get_drvdata(pdev);
100
101 of_platform_depopulate(&pdev->dev);
102
103 clk_disable_unprepare(qdwc->sleep_clk);
104 clk_disable_unprepare(qdwc->iface_clk);
105 clk_disable_unprepare(qdwc->core_clk);
106
107 return 0;
108}
109
110static const struct of_device_id of_dwc3_match[] = {
111 { .compatible = "qcom,dwc3" },
112 { /* Sentinel */ }
113};
114MODULE_DEVICE_TABLE(of, of_dwc3_match);
115
116static struct platform_driver dwc3_qcom_driver = {
117 .probe = dwc3_qcom_probe,
118 .remove = dwc3_qcom_remove,
119 .driver = {
120 .name = "qcom-dwc3",
121 .owner = THIS_MODULE,
122 .of_match_table = of_dwc3_match,
123 },
124};
125
126module_platform_driver(dwc3_qcom_driver);
127
128MODULE_ALIAS("platform:qcom-dwc3");
129MODULE_LICENSE("GPL v2");
130MODULE_DESCRIPTION("DesignWare USB3 QCOM Glue Layer");
131MODULE_AUTHOR("Ivan T. Ivanov <iivanov@mm-sol.com>");