1 /* Copyright (c) 2013-2014, The Linux Foundation. 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.
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.
13 #include <linux/clk.h>
14 #include <linux/err.h>
16 #include <linux/module.h>
18 #include <linux/of_platform.h>
19 #include <linux/platform_device.h>
25 struct clk
*iface_clk
;
26 struct clk
*sleep_clk
;
29 static int dwc3_qcom_probe(struct platform_device
*pdev
)
31 struct device_node
*node
= pdev
->dev
.of_node
;
32 struct dwc3_qcom
*qdwc
;
35 qdwc
= devm_kzalloc(&pdev
->dev
, sizeof(*qdwc
), GFP_KERNEL
);
39 platform_set_drvdata(pdev
, qdwc
);
41 qdwc
->dev
= &pdev
->dev
;
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
);
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
;
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
;
61 ret
= clk_prepare_enable(qdwc
->core_clk
);
63 dev_err(qdwc
->dev
, "failed to enable core clock\n");
67 ret
= clk_prepare_enable(qdwc
->iface_clk
);
69 dev_err(qdwc
->dev
, "failed to enable optional iface clock\n");
73 ret
= clk_prepare_enable(qdwc
->sleep_clk
);
75 dev_err(qdwc
->dev
, "failed to enable optional sleep clock\n");
79 ret
= of_platform_populate(node
, NULL
, NULL
, qdwc
->dev
);
81 dev_err(qdwc
->dev
, "failed to register core - %d\n", ret
);
88 clk_disable_unprepare(qdwc
->sleep_clk
);
90 clk_disable_unprepare(qdwc
->iface_clk
);
92 clk_disable_unprepare(qdwc
->core_clk
);
97 static int dwc3_qcom_remove(struct platform_device
*pdev
)
99 struct dwc3_qcom
*qdwc
= platform_get_drvdata(pdev
);
101 of_platform_depopulate(&pdev
->dev
);
103 clk_disable_unprepare(qdwc
->sleep_clk
);
104 clk_disable_unprepare(qdwc
->iface_clk
);
105 clk_disable_unprepare(qdwc
->core_clk
);
110 static const struct of_device_id of_dwc3_match
[] = {
111 { .compatible
= "qcom,dwc3" },
114 MODULE_DEVICE_TABLE(of
, of_dwc3_match
);
116 static struct platform_driver dwc3_qcom_driver
= {
117 .probe
= dwc3_qcom_probe
,
118 .remove
= dwc3_qcom_remove
,
121 .of_match_table
= of_dwc3_match
,
125 module_platform_driver(dwc3_qcom_driver
);
127 MODULE_ALIAS("platform:qcom-dwc3");
128 MODULE_LICENSE("GPL v2");
129 MODULE_DESCRIPTION("DesignWare USB3 QCOM Glue Layer");
130 MODULE_AUTHOR("Ivan T. Ivanov <iivanov@mm-sol.com>");