11// SPDX-License-Identifier: GPL-2.0-only
22/*
3- * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
3+ * Copyright (c) 2023-2024 , Qualcomm Innovation Center, Inc. All rights reserved.
44 */
55
66#include <linux/clk-provider.h>
@@ -35,7 +35,7 @@ static const struct pll_vco lucid_ole_vco[] = {
3535 { 249600000 , 2300000000 , 0 },
3636};
3737
38- static const struct alpha_pll_config video_cc_pll0_config = {
38+ static struct alpha_pll_config video_cc_pll0_config = {
3939 .l = 0x25 ,
4040 .alpha = 0x8000 ,
4141 .config_ctl_val = 0x20485699 ,
@@ -66,7 +66,7 @@ static struct clk_alpha_pll video_cc_pll0 = {
6666 },
6767};
6868
69- static const struct alpha_pll_config video_cc_pll1_config = {
69+ static struct alpha_pll_config video_cc_pll1_config = {
7070 .l = 0x36 ,
7171 .alpha = 0xb000 ,
7272 .config_ctl_val = 0x20485699 ,
@@ -117,6 +117,14 @@ static const struct clk_parent_data video_cc_parent_data_1[] = {
117117 { .hw = & video_cc_pll1 .clkr .hw },
118118};
119119
120+ static const struct parent_map video_cc_parent_map_2 [] = {
121+ { P_BI_TCXO , 0 },
122+ };
123+
124+ static const struct clk_parent_data video_cc_parent_data_2 [] = {
125+ { .index = DT_BI_TCXO },
126+ };
127+
120128static const struct freq_tbl ftbl_video_cc_mvs0_clk_src [] = {
121129 F (720000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
122130 F (1014000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
@@ -126,6 +134,16 @@ static const struct freq_tbl ftbl_video_cc_mvs0_clk_src[] = {
126134 { }
127135};
128136
137+ static const struct freq_tbl ftbl_video_cc_mvs0_clk_src_sm8650 [] = {
138+ F (588000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
139+ F (900000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
140+ F (1140000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
141+ F (1305000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
142+ F (1440000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
143+ F (1600000000 , P_VIDEO_CC_PLL0_OUT_MAIN , 1 , 0 , 0 ),
144+ { }
145+ };
146+
129147static struct clk_rcg2 video_cc_mvs0_clk_src = {
130148 .cmd_rcgr = 0x8000 ,
131149 .mnd_width = 0 ,
@@ -149,6 +167,15 @@ static const struct freq_tbl ftbl_video_cc_mvs1_clk_src[] = {
149167 { }
150168};
151169
170+ static const struct freq_tbl ftbl_video_cc_mvs1_clk_src_sm8650 [] = {
171+ F (840000000 , P_VIDEO_CC_PLL1_OUT_MAIN , 1 , 0 , 0 ),
172+ F (1110000000 , P_VIDEO_CC_PLL1_OUT_MAIN , 1 , 0 , 0 ),
173+ F (1350000000 , P_VIDEO_CC_PLL1_OUT_MAIN , 1 , 0 , 0 ),
174+ F (1500000000 , P_VIDEO_CC_PLL1_OUT_MAIN , 1 , 0 , 0 ),
175+ F (1650000000 , P_VIDEO_CC_PLL1_OUT_MAIN , 1 , 0 , 0 ),
176+ { }
177+ };
178+
152179static struct clk_rcg2 video_cc_mvs1_clk_src = {
153180 .cmd_rcgr = 0x8018 ,
154181 .mnd_width = 0 ,
@@ -164,6 +191,26 @@ static struct clk_rcg2 video_cc_mvs1_clk_src = {
164191 },
165192};
166193
194+ static const struct freq_tbl ftbl_video_cc_xo_clk_src [] = {
195+ F (19200000 , P_BI_TCXO , 1 , 0 , 0 ),
196+ { }
197+ };
198+
199+ static struct clk_rcg2 video_cc_xo_clk_src = {
200+ .cmd_rcgr = 0x810c ,
201+ .mnd_width = 0 ,
202+ .hid_width = 5 ,
203+ .parent_map = video_cc_parent_map_2 ,
204+ .freq_tbl = ftbl_video_cc_xo_clk_src ,
205+ .clkr .hw .init = & (const struct clk_init_data ) {
206+ .name = "video_cc_xo_clk_src" ,
207+ .parent_data = video_cc_parent_data_2 ,
208+ .num_parents = ARRAY_SIZE (video_cc_parent_data_2 ),
209+ .flags = CLK_SET_RATE_PARENT ,
210+ .ops = & clk_rcg2_shared_ops ,
211+ },
212+ };
213+
167214static struct clk_regmap_div video_cc_mvs0_div_clk_src = {
168215 .reg = 0x80c4 ,
169216 .shift = 0 ,
@@ -244,6 +291,26 @@ static struct clk_branch video_cc_mvs0_clk = {
244291 },
245292};
246293
294+ static struct clk_branch video_cc_mvs0_shift_clk = {
295+ .halt_reg = 0x8128 ,
296+ .halt_check = BRANCH_HALT_VOTED ,
297+ .hwcg_reg = 0x8128 ,
298+ .hwcg_bit = 1 ,
299+ .clkr = {
300+ .enable_reg = 0x8128 ,
301+ .enable_mask = BIT (0 ),
302+ .hw .init = & (const struct clk_init_data ) {
303+ .name = "video_cc_mvs0_shift_clk" ,
304+ .parent_hws = (const struct clk_hw * []) {
305+ & video_cc_xo_clk_src .clkr .hw ,
306+ },
307+ .num_parents = 1 ,
308+ .flags = CLK_SET_RATE_PARENT ,
309+ .ops = & clk_branch2_ops ,
310+ },
311+ },
312+ };
313+
247314static struct clk_branch video_cc_mvs0c_clk = {
248315 .halt_reg = 0x8064 ,
249316 .halt_check = BRANCH_HALT ,
@@ -262,6 +329,26 @@ static struct clk_branch video_cc_mvs0c_clk = {
262329 },
263330};
264331
332+ static struct clk_branch video_cc_mvs0c_shift_clk = {
333+ .halt_reg = 0x812c ,
334+ .halt_check = BRANCH_HALT_VOTED ,
335+ .hwcg_reg = 0x812c ,
336+ .hwcg_bit = 1 ,
337+ .clkr = {
338+ .enable_reg = 0x812c ,
339+ .enable_mask = BIT (0 ),
340+ .hw .init = & (const struct clk_init_data ) {
341+ .name = "video_cc_mvs0c_shift_clk" ,
342+ .parent_hws = (const struct clk_hw * []) {
343+ & video_cc_xo_clk_src .clkr .hw ,
344+ },
345+ .num_parents = 1 ,
346+ .flags = CLK_SET_RATE_PARENT ,
347+ .ops = & clk_branch2_ops ,
348+ },
349+ },
350+ };
351+
265352static struct clk_branch video_cc_mvs1_clk = {
266353 .halt_reg = 0x80e0 ,
267354 .halt_check = BRANCH_HALT_SKIP ,
@@ -282,6 +369,26 @@ static struct clk_branch video_cc_mvs1_clk = {
282369 },
283370};
284371
372+ static struct clk_branch video_cc_mvs1_shift_clk = {
373+ .halt_reg = 0x8130 ,
374+ .halt_check = BRANCH_HALT_VOTED ,
375+ .hwcg_reg = 0x8130 ,
376+ .hwcg_bit = 1 ,
377+ .clkr = {
378+ .enable_reg = 0x8130 ,
379+ .enable_mask = BIT (0 ),
380+ .hw .init = & (const struct clk_init_data ) {
381+ .name = "video_cc_mvs1_shift_clk" ,
382+ .parent_hws = (const struct clk_hw * []) {
383+ & video_cc_xo_clk_src .clkr .hw ,
384+ },
385+ .num_parents = 1 ,
386+ .flags = CLK_SET_RATE_PARENT ,
387+ .ops = & clk_branch2_ops ,
388+ },
389+ },
390+ };
391+
285392static struct clk_branch video_cc_mvs1c_clk = {
286393 .halt_reg = 0x8090 ,
287394 .halt_check = BRANCH_HALT ,
@@ -300,6 +407,26 @@ static struct clk_branch video_cc_mvs1c_clk = {
300407 },
301408};
302409
410+ static struct clk_branch video_cc_mvs1c_shift_clk = {
411+ .halt_reg = 0x8134 ,
412+ .halt_check = BRANCH_HALT_VOTED ,
413+ .hwcg_reg = 0x8134 ,
414+ .hwcg_bit = 1 ,
415+ .clkr = {
416+ .enable_reg = 0x8134 ,
417+ .enable_mask = BIT (0 ),
418+ .hw .init = & (const struct clk_init_data ) {
419+ .name = "video_cc_mvs1c_shift_clk" ,
420+ .parent_hws = (const struct clk_hw * []) {
421+ & video_cc_xo_clk_src .clkr .hw ,
422+ },
423+ .num_parents = 1 ,
424+ .flags = CLK_SET_RATE_PARENT ,
425+ .ops = & clk_branch2_ops ,
426+ },
427+ },
428+ };
429+
303430static struct gdsc video_cc_mvs0c_gdsc = {
304431 .gdscr = 0x804c ,
305432 .en_rest_wait_val = 0x2 ,
@@ -363,6 +490,7 @@ static struct clk_regmap *video_cc_sm8550_clocks[] = {
363490 [VIDEO_CC_MVS1C_DIV2_DIV_CLK_SRC ] = & video_cc_mvs1c_div2_div_clk_src .clkr ,
364491 [VIDEO_CC_PLL0 ] = & video_cc_pll0 .clkr ,
365492 [VIDEO_CC_PLL1 ] = & video_cc_pll1 .clkr ,
493+ [VIDEO_CC_XO_CLK_SRC ] = NULL ,
366494};
367495
368496static struct gdsc * video_cc_sm8550_gdscs [] = {
@@ -403,6 +531,7 @@ static struct qcom_cc_desc video_cc_sm8550_desc = {
403531
404532static const struct of_device_id video_cc_sm8550_match_table [] = {
405533 { .compatible = "qcom,sm8550-videocc" },
534+ { .compatible = "qcom,sm8650-videocc" },
406535 { }
407536};
408537MODULE_DEVICE_TABLE (of , video_cc_sm8550_match_table );
@@ -411,6 +540,7 @@ static int video_cc_sm8550_probe(struct platform_device *pdev)
411540{
412541 struct regmap * regmap ;
413542 int ret ;
543+ u32 sleep_clk_offset = 0x8140 ;
414544
415545 ret = devm_pm_runtime_enable (& pdev -> dev );
416546 if (ret )
@@ -426,12 +556,27 @@ static int video_cc_sm8550_probe(struct platform_device *pdev)
426556 return PTR_ERR (regmap );
427557 }
428558
559+ if (of_device_is_compatible (pdev -> dev .of_node , "qcom,sm8650-videocc" )) {
560+ sleep_clk_offset = 0x8150 ;
561+ video_cc_pll0_config .l = 0x1e ;
562+ video_cc_pll0_config .alpha = 0xa000 ;
563+ video_cc_pll1_config .l = 0x2b ;
564+ video_cc_pll1_config .alpha = 0xc000 ;
565+ video_cc_mvs0_clk_src .freq_tbl = ftbl_video_cc_mvs0_clk_src_sm8650 ;
566+ video_cc_mvs1_clk_src .freq_tbl = ftbl_video_cc_mvs1_clk_src_sm8650 ;
567+ video_cc_sm8550_clocks [VIDEO_CC_MVS0_SHIFT_CLK ] = & video_cc_mvs0_shift_clk .clkr ;
568+ video_cc_sm8550_clocks [VIDEO_CC_MVS0C_SHIFT_CLK ] = & video_cc_mvs0c_shift_clk .clkr ;
569+ video_cc_sm8550_clocks [VIDEO_CC_MVS1_SHIFT_CLK ] = & video_cc_mvs1_shift_clk .clkr ;
570+ video_cc_sm8550_clocks [VIDEO_CC_MVS1C_SHIFT_CLK ] = & video_cc_mvs1c_shift_clk .clkr ;
571+ video_cc_sm8550_clocks [VIDEO_CC_XO_CLK_SRC ] = & video_cc_xo_clk_src .clkr ;
572+ }
573+
429574 clk_lucid_ole_pll_configure (& video_cc_pll0 , regmap , & video_cc_pll0_config );
430575 clk_lucid_ole_pll_configure (& video_cc_pll1 , regmap , & video_cc_pll1_config );
431576
432577 /* Keep some clocks always-on */
433578 qcom_branch_set_clk_en (regmap , 0x80f4 ); /* VIDEO_CC_AHB_CLK */
434- qcom_branch_set_clk_en (regmap , 0x8140 ); /* VIDEO_CC_SLEEP_CLK */
579+ qcom_branch_set_clk_en (regmap , sleep_clk_offset ); /* VIDEO_CC_SLEEP_CLK */
435580 qcom_branch_set_clk_en (regmap , 0x8124 ); /* VIDEO_CC_XO_CLK */
436581
437582 ret = qcom_cc_really_probe (pdev , & video_cc_sm8550_desc , regmap );
0 commit comments