Skip to content

Commit 513b67a

Browse files
jbrun3tsuperna9999
authored andcommitted
clk: meson: add mpll pre-divider
mpll clocks parent can actually be divided by 1 or 2. So far, this divider has always been set to 1, so the calculation was correct. Now that we know it exists, model the tree correctly. If we ever get a platform where the divider is different, we won't get into trouble Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
1 parent 093c3fa commit 513b67a

File tree

6 files changed

+65
-13
lines changed

6 files changed

+65
-13
lines changed

drivers/clk/meson/axg.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,20 @@ static struct clk_fixed_factor axg_fclk_div7 = {
354354
},
355355
};
356356

357+
static struct clk_regmap axg_mpll_prediv = {
358+
.data = &(struct clk_regmap_div_data){
359+
.offset = HHI_MPLL_CNTL5,
360+
.shift = 12,
361+
.width = 1,
362+
},
363+
.hw.init = &(struct clk_init_data){
364+
.name = "mpll_prediv",
365+
.ops = &clk_regmap_divider_ro_ops,
366+
.parent_names = (const char *[]){ "fixed_pll" },
367+
.num_parents = 1,
368+
},
369+
};
370+
357371
static struct clk_regmap axg_mpll0_div = {
358372
.data = &(struct meson_clk_mpll_data){
359373
.sdm = {
@@ -386,7 +400,7 @@ static struct clk_regmap axg_mpll0_div = {
386400
.hw.init = &(struct clk_init_data){
387401
.name = "mpll0_div",
388402
.ops = &meson_clk_mpll_ops,
389-
.parent_names = (const char *[]){ "fixed_pll" },
403+
.parent_names = (const char *[]){ "mpll_prediv" },
390404
.num_parents = 1,
391405
},
392406
};
@@ -432,7 +446,7 @@ static struct clk_regmap axg_mpll1_div = {
432446
.hw.init = &(struct clk_init_data){
433447
.name = "mpll1_div",
434448
.ops = &meson_clk_mpll_ops,
435-
.parent_names = (const char *[]){ "fixed_pll" },
449+
.parent_names = (const char *[]){ "mpll_prediv" },
436450
.num_parents = 1,
437451
},
438452
};
@@ -478,7 +492,7 @@ static struct clk_regmap axg_mpll2_div = {
478492
.hw.init = &(struct clk_init_data){
479493
.name = "mpll2_div",
480494
.ops = &meson_clk_mpll_ops,
481-
.parent_names = (const char *[]){ "fixed_pll" },
495+
.parent_names = (const char *[]){ "mpll_prediv" },
482496
.num_parents = 1,
483497
},
484498
};
@@ -524,7 +538,7 @@ static struct clk_regmap axg_mpll3_div = {
524538
.hw.init = &(struct clk_init_data){
525539
.name = "mpll3_div",
526540
.ops = &meson_clk_mpll_ops,
527-
.parent_names = (const char *[]){ "fixed_pll" },
541+
.parent_names = (const char *[]){ "mpll_prediv" },
528542
.num_parents = 1,
529543
},
530544
};
@@ -821,6 +835,7 @@ static struct clk_hw_onecell_data axg_hw_onecell_data = {
821835
[CLKID_MPLL2_DIV] = &axg_mpll2_div.hw,
822836
[CLKID_MPLL3_DIV] = &axg_mpll3_div.hw,
823837
[CLKID_HIFI_PLL] = &axg_hifi_pll.hw,
838+
[CLKID_MPLL_PREDIV] = &axg_mpll_prediv.hw,
824839
[NR_CLKS] = NULL,
825840
},
826841
.num = NR_CLKS,
@@ -893,6 +908,7 @@ static struct clk_regmap *const axg_clk_regmaps[] = {
893908
&axg_sys_pll,
894909
&axg_gp0_pll,
895910
&axg_hifi_pll,
911+
&axg_mpll_prediv,
896912
};
897913

898914
static const struct of_device_id clkc_match_table[] = {

drivers/clk/meson/axg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@
121121
#define CLKID_MPLL1_DIV 66
122122
#define CLKID_MPLL2_DIV 67
123123
#define CLKID_MPLL3_DIV 68
124+
#define CLKID_MPLL_PREDIV 70
124125

125-
#define NR_CLKS 70
126+
#define NR_CLKS 71
126127

127128
/* include the CLKIDs that have been made part of the DT binding */
128129
#include <dt-bindings/clock/axg-clkc.h>

drivers/clk/meson/gxbb.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,20 @@ static struct clk_fixed_factor gxbb_fclk_div7 = {
545545
},
546546
};
547547

548+
static struct clk_regmap gxbb_mpll_prediv = {
549+
.data = &(struct clk_regmap_div_data){
550+
.offset = HHI_MPLL_CNTL5,
551+
.shift = 12,
552+
.width = 1,
553+
},
554+
.hw.init = &(struct clk_init_data){
555+
.name = "mpll_prediv",
556+
.ops = &clk_regmap_divider_ro_ops,
557+
.parent_names = (const char *[]){ "fixed_pll" },
558+
.num_parents = 1,
559+
},
560+
};
561+
548562
static struct clk_regmap gxbb_mpll0_div = {
549563
.data = &(struct meson_clk_mpll_data){
550564
.sdm = {
@@ -572,7 +586,7 @@ static struct clk_regmap gxbb_mpll0_div = {
572586
.hw.init = &(struct clk_init_data){
573587
.name = "mpll0_div",
574588
.ops = &meson_clk_mpll_ops,
575-
.parent_names = (const char *[]){ "fixed_pll" },
589+
.parent_names = (const char *[]){ "mpll_prediv" },
576590
.num_parents = 1,
577591
},
578592
};
@@ -613,7 +627,7 @@ static struct clk_regmap gxbb_mpll1_div = {
613627
.hw.init = &(struct clk_init_data){
614628
.name = "mpll1_div",
615629
.ops = &meson_clk_mpll_ops,
616-
.parent_names = (const char *[]){ "fixed_pll" },
630+
.parent_names = (const char *[]){ "mpll_prediv" },
617631
.num_parents = 1,
618632
},
619633
};
@@ -654,7 +668,7 @@ static struct clk_regmap gxbb_mpll2_div = {
654668
.hw.init = &(struct clk_init_data){
655669
.name = "mpll2_div",
656670
.ops = &meson_clk_mpll_ops,
657-
.parent_names = (const char *[]){ "fixed_pll" },
671+
.parent_names = (const char *[]){ "mpll_prediv" },
658672
.num_parents = 1,
659673
},
660674
};
@@ -1703,6 +1717,7 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = {
17031717
[CLKID_MPLL0_DIV] = &gxbb_mpll0_div.hw,
17041718
[CLKID_MPLL1_DIV] = &gxbb_mpll1_div.hw,
17051719
[CLKID_MPLL2_DIV] = &gxbb_mpll2_div.hw,
1720+
[CLKID_MPLL_PREDIV] = &gxbb_mpll_prediv.hw,
17061721
[NR_CLKS] = NULL,
17071722
},
17081723
.num = NR_CLKS,
@@ -1853,6 +1868,7 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = {
18531868
[CLKID_MPLL0_DIV] = &gxbb_mpll0_div.hw,
18541869
[CLKID_MPLL1_DIV] = &gxbb_mpll1_div.hw,
18551870
[CLKID_MPLL2_DIV] = &gxbb_mpll2_div.hw,
1871+
[CLKID_MPLL_PREDIV] = &gxbb_mpll_prediv.hw,
18561872
[NR_CLKS] = NULL,
18571873
},
18581874
.num = NR_CLKS,
@@ -2005,6 +2021,7 @@ static struct clk_regmap *const gx_clk_regmaps[] = {
20052021
&gxbb_cts_amclk_div,
20062022
&gxbb_fixed_pll,
20072023
&gxbb_sys_pll,
2024+
&gxbb_mpll_prediv,
20082025
};
20092026

20102027
struct clkc_data {

drivers/clk/meson/gxbb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@
198198
#define CLKID_MPLL0_DIV 142
199199
#define CLKID_MPLL1_DIV 143
200200
#define CLKID_MPLL2_DIV 144
201+
#define CLKID_MPLL_PREDIV 145
201202

202-
#define NR_CLKS 145
203+
#define NR_CLKS 146
203204

204205
/* include the CLKIDs that have been made part of the DT binding */
205206
#include <dt-bindings/clock/gxbb-clkc.h>

drivers/clk/meson/meson8b.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,20 @@ static struct clk_fixed_factor meson8b_fclk_div7 = {
280280
},
281281
};
282282

283+
static struct clk_regmap meson8b_mpll_prediv = {
284+
.data = &(struct clk_regmap_div_data){
285+
.offset = HHI_MPLL_CNTL5,
286+
.shift = 12,
287+
.width = 1,
288+
},
289+
.hw.init = &(struct clk_init_data){
290+
.name = "mpll_prediv",
291+
.ops = &clk_regmap_divider_ro_ops,
292+
.parent_names = (const char *[]){ "fixed_pll" },
293+
.num_parents = 1,
294+
},
295+
};
296+
283297
static struct clk_regmap meson8b_mpll0_div = {
284298
.data = &(struct meson_clk_mpll_data){
285299
.sdm = {
@@ -307,7 +321,7 @@ static struct clk_regmap meson8b_mpll0_div = {
307321
.hw.init = &(struct clk_init_data){
308322
.name = "mpll0_div",
309323
.ops = &meson_clk_mpll_ops,
310-
.parent_names = (const char *[]){ "fixed_pll" },
324+
.parent_names = (const char *[]){ "mpll_prediv" },
311325
.num_parents = 1,
312326
},
313327
};
@@ -348,7 +362,7 @@ static struct clk_regmap meson8b_mpll1_div = {
348362
.hw.init = &(struct clk_init_data){
349363
.name = "mpll1_div",
350364
.ops = &meson_clk_mpll_ops,
351-
.parent_names = (const char *[]){ "fixed_pll" },
365+
.parent_names = (const char *[]){ "mpll_prediv" },
352366
.num_parents = 1,
353367
},
354368
};
@@ -389,7 +403,7 @@ static struct clk_regmap meson8b_mpll2_div = {
389403
.hw.init = &(struct clk_init_data){
390404
.name = "mpll2_div",
391405
.ops = &meson_clk_mpll_ops,
392-
.parent_names = (const char *[]){ "fixed_pll" },
406+
.parent_names = (const char *[]){ "mpll_prediv" },
393407
.num_parents = 1,
394408
},
395409
};
@@ -751,6 +765,7 @@ static struct clk_hw_onecell_data meson8b_hw_onecell_data = {
751765
[CLKID_CPU_DIV3] = &meson8b_cpu_div3.hw,
752766
[CLKID_CPU_SCALE_DIV] = &meson8b_cpu_scale_div.hw,
753767
[CLKID_CPU_SCALE_OUT_SEL] = &meson8b_cpu_scale_out_sel.hw,
768+
[CLKID_MPLL_PREDIV] = &meson8b_mpll_prediv.hw,
754769
[CLK_NR_CLKS] = NULL,
755770
},
756771
.num = CLK_NR_CLKS,
@@ -850,6 +865,7 @@ static struct clk_regmap *const meson8b_clk_regmaps[] = {
850865
&meson8b_cpu_scale_div,
851866
&meson8b_cpu_scale_out_sel,
852867
&meson8b_cpu_clk,
868+
&meson8b_mpll_prediv,
853869
};
854870

855871
static const struct meson8b_clk_reset_line {

drivers/clk/meson/meson8b.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@
7777
#define CLKID_CPU_DIV3 101
7878
#define CLKID_CPU_SCALE_DIV 102
7979
#define CLKID_CPU_SCALE_OUT_SEL 103
80+
#define CLKID_MPLL_PREDIV 104
8081

81-
#define CLK_NR_CLKS 104
82+
#define CLK_NR_CLKS 105
8283

8384
/*
8485
* include the CLKID and RESETID that have

0 commit comments

Comments
 (0)