1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
4 * Copyright (c) 2023, Linaro Limited
7 #include <linux/clk-provider.h>
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/regmap.h>
13 #include <dt-bindings/clock/qcom,x1e80100-tcsr.h>
15 #include "clk-branch.h"
16 #include "clk-regmap.h"
24 static struct clk_branch tcsr_edp_clkref_en
= {
26 .halt_check
= BRANCH_HALT_DELAY
,
28 .enable_reg
= 0x15130,
29 .enable_mask
= BIT(0),
30 .hw
.init
= &(const struct clk_init_data
) {
31 .name
= "tcsr_edp_clkref_en",
32 .ops
= &clk_branch2_ops
,
37 static struct clk_branch tcsr_pcie_2l_4_clkref_en
= {
39 .halt_check
= BRANCH_HALT_DELAY
,
41 .enable_reg
= 0x15100,
42 .enable_mask
= BIT(0),
43 .hw
.init
= &(struct clk_init_data
){
44 .name
= "tcsr_pcie_2l_4_clkref_en",
45 .parent_data
= &(const struct clk_parent_data
){
46 .index
= DT_BI_TCXO_PAD
,
49 .ops
= &clk_branch2_ops
,
54 static struct clk_branch tcsr_pcie_2l_5_clkref_en
= {
56 .halt_check
= BRANCH_HALT_DELAY
,
58 .enable_reg
= 0x15104,
59 .enable_mask
= BIT(0),
60 .hw
.init
= &(struct clk_init_data
){
61 .name
= "tcsr_pcie_2l_5_clkref_en",
62 .parent_data
= &(const struct clk_parent_data
){
63 .index
= DT_BI_TCXO_PAD
,
66 .ops
= &clk_branch2_ops
,
71 static struct clk_branch tcsr_pcie_8l_clkref_en
= {
73 .halt_check
= BRANCH_HALT_DELAY
,
75 .enable_reg
= 0x15108,
76 .enable_mask
= BIT(0),
77 .hw
.init
= &(struct clk_init_data
){
78 .name
= "tcsr_pcie_8l_clkref_en",
79 .parent_data
= &(const struct clk_parent_data
){
80 .index
= DT_BI_TCXO_PAD
,
83 .ops
= &clk_branch2_ops
,
88 static struct clk_branch tcsr_usb3_mp0_clkref_en
= {
90 .halt_check
= BRANCH_HALT_DELAY
,
92 .enable_reg
= 0x1510c,
93 .enable_mask
= BIT(0),
94 .hw
.init
= &(struct clk_init_data
){
95 .name
= "tcsr_usb3_mp0_clkref_en",
96 .parent_data
= &(const struct clk_parent_data
){
97 .index
= DT_BI_TCXO_PAD
,
100 .ops
= &clk_branch2_ops
,
105 static struct clk_branch tcsr_usb3_mp1_clkref_en
= {
107 .halt_check
= BRANCH_HALT_DELAY
,
109 .enable_reg
= 0x15110,
110 .enable_mask
= BIT(0),
111 .hw
.init
= &(struct clk_init_data
){
112 .name
= "tcsr_usb3_mp1_clkref_en",
113 .parent_data
= &(const struct clk_parent_data
){
114 .index
= DT_BI_TCXO_PAD
,
117 .ops
= &clk_branch2_ops
,
122 static struct clk_branch tcsr_usb2_1_clkref_en
= {
124 .halt_check
= BRANCH_HALT_DELAY
,
126 .enable_reg
= 0x15114,
127 .enable_mask
= BIT(0),
128 .hw
.init
= &(struct clk_init_data
){
129 .name
= "tcsr_usb2_1_clkref_en",
130 .parent_data
= &(const struct clk_parent_data
){
131 .index
= DT_BI_TCXO_PAD
,
134 .ops
= &clk_branch2_ops
,
139 static struct clk_branch tcsr_ufs_phy_clkref_en
= {
141 .halt_check
= BRANCH_HALT_DELAY
,
143 .enable_reg
= 0x15118,
144 .enable_mask
= BIT(0),
145 .hw
.init
= &(struct clk_init_data
){
146 .name
= "tcsr_ufs_phy_clkref_en",
147 .parent_data
= &(const struct clk_parent_data
){
148 .index
= DT_BI_TCXO_PAD
,
151 .ops
= &clk_branch2_ops
,
156 static struct clk_branch tcsr_usb4_1_clkref_en
= {
158 .halt_check
= BRANCH_HALT_DELAY
,
160 .enable_reg
= 0x15120,
161 .enable_mask
= BIT(0),
162 .hw
.init
= &(struct clk_init_data
){
163 .name
= "tcsr_usb4_1_clkref_en",
164 .parent_data
= &(const struct clk_parent_data
){
165 .index
= DT_BI_TCXO_PAD
,
168 .ops
= &clk_branch2_ops
,
173 static struct clk_branch tcsr_usb4_2_clkref_en
= {
175 .halt_check
= BRANCH_HALT_DELAY
,
177 .enable_reg
= 0x15124,
178 .enable_mask
= BIT(0),
179 .hw
.init
= &(struct clk_init_data
){
180 .name
= "tcsr_usb4_2_clkref_en",
181 .parent_data
= &(const struct clk_parent_data
){
182 .index
= DT_BI_TCXO_PAD
,
185 .ops
= &clk_branch2_ops
,
190 static struct clk_branch tcsr_usb2_2_clkref_en
= {
192 .halt_check
= BRANCH_HALT_DELAY
,
194 .enable_reg
= 0x15128,
195 .enable_mask
= BIT(0),
196 .hw
.init
= &(struct clk_init_data
){
197 .name
= "tcsr_usb2_2_clkref_en",
198 .parent_data
= &(const struct clk_parent_data
){
199 .index
= DT_BI_TCXO_PAD
,
202 .ops
= &clk_branch2_ops
,
207 static struct clk_branch tcsr_pcie_4l_clkref_en
= {
209 .halt_check
= BRANCH_HALT_DELAY
,
211 .enable_reg
= 0x1512c,
212 .enable_mask
= BIT(0),
213 .hw
.init
= &(struct clk_init_data
){
214 .name
= "tcsr_pcie_4l_clkref_en",
215 .parent_data
= &(const struct clk_parent_data
){
216 .index
= DT_BI_TCXO_PAD
,
219 .ops
= &clk_branch2_ops
,
224 static struct clk_regmap
*tcsr_cc_x1e80100_clocks
[] = {
225 [TCSR_EDP_CLKREF_EN
] = &tcsr_edp_clkref_en
.clkr
,
226 [TCSR_PCIE_2L_4_CLKREF_EN
] = &tcsr_pcie_2l_4_clkref_en
.clkr
,
227 [TCSR_PCIE_2L_5_CLKREF_EN
] = &tcsr_pcie_2l_5_clkref_en
.clkr
,
228 [TCSR_PCIE_8L_CLKREF_EN
] = &tcsr_pcie_8l_clkref_en
.clkr
,
229 [TCSR_USB3_MP0_CLKREF_EN
] = &tcsr_usb3_mp0_clkref_en
.clkr
,
230 [TCSR_USB3_MP1_CLKREF_EN
] = &tcsr_usb3_mp1_clkref_en
.clkr
,
231 [TCSR_USB2_1_CLKREF_EN
] = &tcsr_usb2_1_clkref_en
.clkr
,
232 [TCSR_UFS_PHY_CLKREF_EN
] = &tcsr_ufs_phy_clkref_en
.clkr
,
233 [TCSR_USB4_1_CLKREF_EN
] = &tcsr_usb4_1_clkref_en
.clkr
,
234 [TCSR_USB4_2_CLKREF_EN
] = &tcsr_usb4_2_clkref_en
.clkr
,
235 [TCSR_USB2_2_CLKREF_EN
] = &tcsr_usb2_2_clkref_en
.clkr
,
236 [TCSR_PCIE_4L_CLKREF_EN
] = &tcsr_pcie_4l_clkref_en
.clkr
,
239 static const struct regmap_config tcsr_cc_x1e80100_regmap_config
= {
243 .max_register
= 0x2f000,
247 static const struct qcom_cc_desc tcsr_cc_x1e80100_desc
= {
248 .config
= &tcsr_cc_x1e80100_regmap_config
,
249 .clks
= tcsr_cc_x1e80100_clocks
,
250 .num_clks
= ARRAY_SIZE(tcsr_cc_x1e80100_clocks
),
253 static const struct of_device_id tcsr_cc_x1e80100_match_table
[] = {
254 { .compatible
= "qcom,x1e80100-tcsr" },
257 MODULE_DEVICE_TABLE(of
, tcsr_cc_x1e80100_match_table
);
259 static int tcsr_cc_x1e80100_probe(struct platform_device
*pdev
)
261 return qcom_cc_probe(pdev
, &tcsr_cc_x1e80100_desc
);
264 static struct platform_driver tcsr_cc_x1e80100_driver
= {
265 .probe
= tcsr_cc_x1e80100_probe
,
267 .name
= "tcsrcc-x1e80100",
268 .of_match_table
= tcsr_cc_x1e80100_match_table
,
272 static int __init
tcsr_cc_x1e80100_init(void)
274 return platform_driver_register(&tcsr_cc_x1e80100_driver
);
276 subsys_initcall(tcsr_cc_x1e80100_init
);
278 static void __exit
tcsr_cc_x1e80100_exit(void)
280 platform_driver_unregister(&tcsr_cc_x1e80100_driver
);
282 module_exit(tcsr_cc_x1e80100_exit
);
284 MODULE_DESCRIPTION("QTI TCSR Clock Controller X1E80100 Driver");
285 MODULE_LICENSE("GPL");