Skip to content

Commit 8067618

Browse files
Taniya Dasandersson
authored andcommitted
clk: qcom: Add TCSR clock driver for SM8750
The TCSR clock controller found on SM8750 provides refclks for PCIE, USB and UFS. Add clock driver for it. Signed-off-by: Melody Olvera <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Taniya Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 3267c77 commit 8067618

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

drivers/clk/qcom/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,14 @@ config SM_TCSRCC_8650
12741274
Support for the TCSR clock controller on SM8650 devices.
12751275
Say Y if you want to use peripheral devices such as SD/UFS.
12761276

1277+
config SM_TCSRCC_8750
1278+
tristate "SM8750 TCSR Clock Controller"
1279+
depends on ARM64 || COMPILE_TEST
1280+
select QCOM_GDSC
1281+
help
1282+
Support for the TCSR clock controller on SM8750 devices.
1283+
Say Y if you want to use peripheral devices such as UFS/USB/PCIe.
1284+
12771285
config SA_VIDEOCC_8775P
12781286
tristate "SA8775P Video Clock Controller"
12791287
depends on ARM64 || COMPILE_TEST

drivers/clk/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ obj-$(CONFIG_SM_GPUCC_8550) += gpucc-sm8550.o
159159
obj-$(CONFIG_SM_GPUCC_8650) += gpucc-sm8650.o
160160
obj-$(CONFIG_SM_TCSRCC_8550) += tcsrcc-sm8550.o
161161
obj-$(CONFIG_SM_TCSRCC_8650) += tcsrcc-sm8650.o
162+
obj-$(CONFIG_SM_TCSRCC_8750) += tcsrcc-sm8750.o
162163
obj-$(CONFIG_SM_VIDEOCC_7150) += videocc-sm7150.o
163164
obj-$(CONFIG_SM_VIDEOCC_8150) += videocc-sm8150.o
164165
obj-$(CONFIG_SM_VIDEOCC_8250) += videocc-sm8250.o

drivers/clk/qcom/tcsrcc-sm8750.c

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
/*
3+
* Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
4+
*/
5+
6+
#include <linux/clk-provider.h>
7+
#include <linux/module.h>
8+
#include <linux/of.h>
9+
#include <linux/platform_device.h>
10+
#include <linux/regmap.h>
11+
12+
#include <dt-bindings/clock/qcom,sm8750-tcsr.h>
13+
14+
#include "clk-branch.h"
15+
#include "clk-regmap.h"
16+
#include "clk-regmap-divider.h"
17+
#include "clk-regmap-mux.h"
18+
#include "common.h"
19+
20+
enum {
21+
DT_BI_TCXO_PAD,
22+
};
23+
24+
static struct clk_branch tcsr_pcie_0_clkref_en = {
25+
.halt_reg = 0x0,
26+
.halt_check = BRANCH_HALT_DELAY,
27+
.clkr = {
28+
.enable_reg = 0x0,
29+
.enable_mask = BIT(0),
30+
.hw.init = &(const struct clk_init_data) {
31+
.name = "tcsr_pcie_0_clkref_en",
32+
.ops = &clk_branch2_ops,
33+
},
34+
},
35+
};
36+
37+
static struct clk_branch tcsr_ufs_clkref_en = {
38+
.halt_reg = 0x1000,
39+
.halt_check = BRANCH_HALT_DELAY,
40+
.clkr = {
41+
.enable_reg = 0x1000,
42+
.enable_mask = BIT(0),
43+
.hw.init = &(const struct clk_init_data) {
44+
.name = "tcsr_ufs_clkref_en",
45+
.parent_data = &(const struct clk_parent_data){
46+
.index = DT_BI_TCXO_PAD,
47+
},
48+
.num_parents = 1,
49+
.ops = &clk_branch2_ops,
50+
},
51+
},
52+
};
53+
54+
static struct clk_branch tcsr_usb2_clkref_en = {
55+
.halt_reg = 0x2000,
56+
.halt_check = BRANCH_HALT_DELAY,
57+
.clkr = {
58+
.enable_reg = 0x2000,
59+
.enable_mask = BIT(0),
60+
.hw.init = &(const struct clk_init_data) {
61+
.name = "tcsr_usb2_clkref_en",
62+
.parent_data = &(const struct clk_parent_data){
63+
.index = DT_BI_TCXO_PAD,
64+
},
65+
.num_parents = 1,
66+
.ops = &clk_branch2_ops,
67+
},
68+
},
69+
};
70+
71+
static struct clk_branch tcsr_usb3_clkref_en = {
72+
.halt_reg = 0x3000,
73+
.halt_check = BRANCH_HALT_DELAY,
74+
.clkr = {
75+
.enable_reg = 0x3000,
76+
.enable_mask = BIT(0),
77+
.hw.init = &(const struct clk_init_data) {
78+
.name = "tcsr_usb3_clkref_en",
79+
.parent_data = &(const struct clk_parent_data){
80+
.index = DT_BI_TCXO_PAD,
81+
},
82+
.num_parents = 1,
83+
.ops = &clk_branch2_ops,
84+
},
85+
},
86+
};
87+
88+
static struct clk_regmap *tcsr_cc_sm8750_clocks[] = {
89+
[TCSR_PCIE_0_CLKREF_EN] = &tcsr_pcie_0_clkref_en.clkr,
90+
[TCSR_UFS_CLKREF_EN] = &tcsr_ufs_clkref_en.clkr,
91+
[TCSR_USB2_CLKREF_EN] = &tcsr_usb2_clkref_en.clkr,
92+
[TCSR_USB3_CLKREF_EN] = &tcsr_usb3_clkref_en.clkr,
93+
};
94+
95+
static const struct regmap_config tcsr_cc_sm8750_regmap_config = {
96+
.reg_bits = 32,
97+
.reg_stride = 4,
98+
.val_bits = 32,
99+
.max_register = 0x3000,
100+
.fast_io = true,
101+
};
102+
103+
static const struct qcom_cc_desc tcsr_cc_sm8750_desc = {
104+
.config = &tcsr_cc_sm8750_regmap_config,
105+
.clks = tcsr_cc_sm8750_clocks,
106+
.num_clks = ARRAY_SIZE(tcsr_cc_sm8750_clocks),
107+
};
108+
109+
static const struct of_device_id tcsr_cc_sm8750_match_table[] = {
110+
{ .compatible = "qcom,sm8750-tcsr" },
111+
{ }
112+
};
113+
MODULE_DEVICE_TABLE(of, tcsr_cc_sm8750_match_table);
114+
115+
static int tcsr_cc_sm8750_probe(struct platform_device *pdev)
116+
{
117+
return qcom_cc_probe(pdev, &tcsr_cc_sm8750_desc);
118+
}
119+
120+
static struct platform_driver tcsr_cc_sm8750_driver = {
121+
.probe = tcsr_cc_sm8750_probe,
122+
.driver = {
123+
.name = "tcsr_cc-sm8750",
124+
.of_match_table = tcsr_cc_sm8750_match_table,
125+
},
126+
};
127+
128+
static int __init tcsr_cc_sm8750_init(void)
129+
{
130+
return platform_driver_register(&tcsr_cc_sm8750_driver);
131+
}
132+
subsys_initcall(tcsr_cc_sm8750_init);
133+
134+
static void __exit tcsr_cc_sm8750_exit(void)
135+
{
136+
platform_driver_unregister(&tcsr_cc_sm8750_driver);
137+
}
138+
module_exit(tcsr_cc_sm8750_exit);
139+
140+
MODULE_DESCRIPTION("QTI TCSR_CC SM8750 Driver");
141+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)