Skip to content

Commit 8def929

Browse files
Taniya Dasbebarino
authored andcommitted
clk: qcom: Add modem clock controller driver for SC7180
Add support for the modem clock controller found on SC7180 based devices. This would allow modem drivers to probe and control their clocks. Signed-off-by: Taniya Das <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Tested-by: Sibi Sankar <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 253a0af commit 8def929

File tree

3 files changed

+153
-0
lines changed

3 files changed

+153
-0
lines changed

drivers/clk/qcom/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ config SC_GPUCC_7180
280280
Say Y if you want to support graphics controller devices and
281281
functionality such as 3D graphics.
282282

283+
config SC_MSS_7180
284+
tristate "SC7180 Modem Clock Controller"
285+
select SC_GCC_7180
286+
help
287+
Support for the Modem Subsystem clock controller on Qualcomm
288+
Technologies, Inc on SC7180 devices.
289+
Say Y if you want to use the Modem branch clocks of the Modem
290+
subsystem clock controller to reset the MSS subsystem.
291+
283292
config SC_VIDEOCC_7180
284293
tristate "SC7180 Video Clock Controller"
285294
select SC_GCC_7180

drivers/clk/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ obj-$(CONFIG_QCS_TURING_404) += turingcc-qcs404.o
5050
obj-$(CONFIG_SC_DISPCC_7180) += dispcc-sc7180.o
5151
obj-$(CONFIG_SC_GCC_7180) += gcc-sc7180.o
5252
obj-$(CONFIG_SC_GPUCC_7180) += gpucc-sc7180.o
53+
obj-$(CONFIG_SC_MSS_7180) += mss-sc7180.o
5354
obj-$(CONFIG_SC_VIDEOCC_7180) += videocc-sc7180.o
5455
obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o
5556
obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o

drivers/clk/qcom/mss-sc7180.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
4+
*/
5+
6+
#include <linux/clk-provider.h>
7+
#include <linux/platform_device.h>
8+
#include <linux/module.h>
9+
#include <linux/pm_clock.h>
10+
#include <linux/pm_runtime.h>
11+
#include <linux/regmap.h>
12+
13+
#include <dt-bindings/clock/qcom,mss-sc7180.h>
14+
15+
#include "clk-regmap.h"
16+
#include "clk-branch.h"
17+
#include "common.h"
18+
19+
static struct clk_branch mss_axi_nav_clk = {
20+
.halt_reg = 0x20bc,
21+
.halt_check = BRANCH_HALT,
22+
.clkr = {
23+
.enable_reg = 0x20bc,
24+
.enable_mask = BIT(0),
25+
.hw.init = &(struct clk_init_data){
26+
.name = "mss_axi_nav_clk",
27+
.parent_data = &(const struct clk_parent_data){
28+
.fw_name = "gcc_mss_nav_axi",
29+
},
30+
.num_parents = 1,
31+
.ops = &clk_branch2_ops,
32+
},
33+
},
34+
};
35+
36+
static struct clk_branch mss_axi_crypto_clk = {
37+
.halt_reg = 0x20cc,
38+
.halt_check = BRANCH_HALT,
39+
.clkr = {
40+
.enable_reg = 0x20cc,
41+
.enable_mask = BIT(0),
42+
.hw.init = &(struct clk_init_data){
43+
.name = "mss_axi_crypto_clk",
44+
.parent_data = &(const struct clk_parent_data){
45+
.fw_name = "gcc_mss_mfab_axis",
46+
},
47+
.num_parents = 1,
48+
.ops = &clk_branch2_ops,
49+
},
50+
},
51+
};
52+
53+
static const struct regmap_config mss_regmap_config = {
54+
.reg_bits = 32,
55+
.reg_stride = 4,
56+
.val_bits = 32,
57+
.fast_io = true,
58+
.max_register = 0x41aa0cc,
59+
};
60+
61+
static struct clk_regmap *mss_sc7180_clocks[] = {
62+
[MSS_AXI_CRYPTO_CLK] = &mss_axi_crypto_clk.clkr,
63+
[MSS_AXI_NAV_CLK] = &mss_axi_nav_clk.clkr,
64+
};
65+
66+
static const struct qcom_cc_desc mss_sc7180_desc = {
67+
.config = &mss_regmap_config,
68+
.clks = mss_sc7180_clocks,
69+
.num_clks = ARRAY_SIZE(mss_sc7180_clocks),
70+
};
71+
72+
static int mss_sc7180_probe(struct platform_device *pdev)
73+
{
74+
int ret;
75+
76+
pm_runtime_enable(&pdev->dev);
77+
ret = pm_clk_create(&pdev->dev);
78+
if (ret)
79+
goto disable_pm_runtime;
80+
81+
ret = pm_clk_add(&pdev->dev, "cfg_ahb");
82+
if (ret < 0) {
83+
dev_err(&pdev->dev, "failed to acquire iface clock\n");
84+
goto destroy_pm_clk;
85+
}
86+
87+
ret = qcom_cc_probe(pdev, &mss_sc7180_desc);
88+
if (ret < 0)
89+
goto destroy_pm_clk;
90+
91+
return 0;
92+
93+
destroy_pm_clk:
94+
pm_clk_destroy(&pdev->dev);
95+
96+
disable_pm_runtime:
97+
pm_runtime_disable(&pdev->dev);
98+
99+
return ret;
100+
}
101+
102+
static int mss_sc7180_remove(struct platform_device *pdev)
103+
{
104+
pm_clk_destroy(&pdev->dev);
105+
pm_runtime_disable(&pdev->dev);
106+
107+
return 0;
108+
}
109+
110+
static const struct dev_pm_ops mss_sc7180_pm_ops = {
111+
SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL)
112+
};
113+
114+
static const struct of_device_id mss_sc7180_match_table[] = {
115+
{ .compatible = "qcom,sc7180-mss" },
116+
{ }
117+
};
118+
MODULE_DEVICE_TABLE(of, mss_sc7180_match_table);
119+
120+
static struct platform_driver mss_sc7180_driver = {
121+
.probe = mss_sc7180_probe,
122+
.remove = mss_sc7180_remove,
123+
.driver = {
124+
.name = "sc7180-mss",
125+
.of_match_table = mss_sc7180_match_table,
126+
.pm = &mss_sc7180_pm_ops,
127+
},
128+
};
129+
130+
static int __init mss_sc7180_init(void)
131+
{
132+
return platform_driver_register(&mss_sc7180_driver);
133+
}
134+
subsys_initcall(mss_sc7180_init);
135+
136+
static void __exit mss_sc7180_exit(void)
137+
{
138+
platform_driver_unregister(&mss_sc7180_driver);
139+
}
140+
module_exit(mss_sc7180_exit);
141+
142+
MODULE_DESCRIPTION("QTI MSS SC7180 Driver");
143+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)