Skip to content

Commit b70cb1a

Browse files
superna9999jbrun3t
authored andcommitted
clk: meson: g12a: make VCLK2 and ENCL clock path configurable by CCF
In order to setup the DSI clock, let's make the unused VCLK2 clock path configuration via CCF. The nocache option is removed from following clocks: - vclk2_sel - vclk2_input - vclk2_div - vclk2 - vclk_div1 - vclk2_div2_en - vclk2_div4_en - vclk2_div6_en - vclk2_div12_en - vclk2_div2 - vclk2_div4 - vclk2_div6 - vclk2_div12 - cts_encl_sel vclk2 and vclk2_div uses the newly introduced vclk regmap driver to handle the enable and reset bits. In order to set a rate on cts_encl via the vclk2 clock path, the NO_REPARENT flag is set on cts_encl_sel & vclk2_sel in order to keep CCF from selection a parent. The parents of cts_encl_sel & vclk2_sel are expected to be defined in DT or manually set by the display driver at some point. The following clock scheme is to be used for DSI: xtal \_ gp0_pll_dco \_ gp0_pll |- vclk2_sel | \_ vclk2_input | \_ vclk2_div | \_ vclk2 | \_ vclk2_div1 | \_ cts_encl_sel | \_ cts_encl -> to VPU LCD Encoder |- mipi_dsi_pxclk_sel \_ mipi_dsi_pxclk_div \_ mipi_dsi_pxclk -> to DSI controller The mipi_dsi_pxclk_div is set as bypass with a single /1 entry in div_table in order to use the same GP0 for mipi_dsi_pxclk and vclk2_input. The SET_RATE_PARENT is only set on the mipi_dsi_pxclk_sel clock so the DSI bitclock is the reference base clock to calculate the vclk2_div value when pixel clock is set on the cts_encl endpoint. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20240403-amlogic-v6-4-upstream-dsi-ccf-vim3-v12-3-99ecdfdc87fc@linaro.org Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
1 parent bb5aa08 commit b70cb1a

File tree

2 files changed

+57
-20
lines changed

2 files changed

+57
-20
lines changed

drivers/clk/meson/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ config COMMON_CLK_G12A
144144
select COMMON_CLK_MESON_EE_CLKC
145145
select COMMON_CLK_MESON_CPU_DYNDIV
146146
select COMMON_CLK_MESON_VID_PLL_DIV
147+
select COMMON_CLK_MESON_VCLK
147148
select MFD_SYSCON
148149
help
149150
Support for the clock controller on Amlogic S905D2, S905X2 and S905Y2

drivers/clk/meson/g12a.c

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "clk-regmap.h"
2323
#include "clk-cpu-dyndiv.h"
2424
#include "vid-pll-div.h"
25+
#include "vclk.h"
2526
#include "meson-eeclk.h"
2627
#include "g12a.h"
2728

@@ -3165,7 +3166,7 @@ static struct clk_regmap g12a_vclk2_sel = {
31653166
.ops = &clk_regmap_mux_ops,
31663167
.parent_hws = g12a_vclk_parent_hws,
31673168
.num_parents = ARRAY_SIZE(g12a_vclk_parent_hws),
3168-
.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3169+
.flags = CLK_SET_RATE_NO_REPARENT,
31693170
},
31703171
};
31713172

@@ -3193,7 +3194,6 @@ static struct clk_regmap g12a_vclk2_input = {
31933194
.ops = &clk_regmap_gate_ops,
31943195
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_sel.hw },
31953196
.num_parents = 1,
3196-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
31973197
},
31983198
};
31993199

@@ -3215,19 +3215,32 @@ static struct clk_regmap g12a_vclk_div = {
32153215
};
32163216

32173217
static struct clk_regmap g12a_vclk2_div = {
3218-
.data = &(struct clk_regmap_div_data){
3219-
.offset = HHI_VIID_CLK_DIV,
3220-
.shift = 0,
3221-
.width = 8,
3218+
.data = &(struct meson_vclk_div_data){
3219+
.div = {
3220+
.reg_off = HHI_VIID_CLK_DIV,
3221+
.shift = 0,
3222+
.width = 8,
3223+
},
3224+
.enable = {
3225+
.reg_off = HHI_VIID_CLK_DIV,
3226+
.shift = 16,
3227+
.width = 1,
3228+
},
3229+
.reset = {
3230+
.reg_off = HHI_VIID_CLK_DIV,
3231+
.shift = 17,
3232+
.width = 1,
3233+
},
3234+
.flags = CLK_DIVIDER_ROUND_CLOSEST,
32223235
},
32233236
.hw.init = &(struct clk_init_data){
32243237
.name = "vclk2_div",
3225-
.ops = &clk_regmap_divider_ops,
3238+
.ops = &meson_vclk_div_ops,
32263239
.parent_hws = (const struct clk_hw *[]) {
32273240
&g12a_vclk2_input.hw
32283241
},
32293242
.num_parents = 1,
3230-
.flags = CLK_GET_RATE_NOCACHE,
3243+
.flags = CLK_SET_RATE_GATE,
32313244
},
32323245
};
32333246

@@ -3246,16 +3259,24 @@ static struct clk_regmap g12a_vclk = {
32463259
};
32473260

32483261
static struct clk_regmap g12a_vclk2 = {
3249-
.data = &(struct clk_regmap_gate_data){
3250-
.offset = HHI_VIID_CLK_CNTL,
3251-
.bit_idx = 19,
3262+
.data = &(struct meson_vclk_gate_data){
3263+
.enable = {
3264+
.reg_off = HHI_VIID_CLK_CNTL,
3265+
.shift = 19,
3266+
.width = 1,
3267+
},
3268+
.reset = {
3269+
.reg_off = HHI_VIID_CLK_CNTL,
3270+
.shift = 15,
3271+
.width = 1,
3272+
},
32523273
},
32533274
.hw.init = &(struct clk_init_data) {
32543275
.name = "vclk2",
3255-
.ops = &clk_regmap_gate_ops,
3276+
.ops = &meson_vclk_gate_ops,
32563277
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_div.hw },
32573278
.num_parents = 1,
3258-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3279+
.flags = CLK_SET_RATE_PARENT,
32593280
},
32603281
};
32613282

@@ -3339,7 +3360,7 @@ static struct clk_regmap g12a_vclk2_div1 = {
33393360
.ops = &clk_regmap_gate_ops,
33403361
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
33413362
.num_parents = 1,
3342-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3363+
.flags = CLK_SET_RATE_PARENT,
33433364
},
33443365
};
33453366

@@ -3353,7 +3374,7 @@ static struct clk_regmap g12a_vclk2_div2_en = {
33533374
.ops = &clk_regmap_gate_ops,
33543375
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
33553376
.num_parents = 1,
3356-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3377+
.flags = CLK_SET_RATE_PARENT,
33573378
},
33583379
};
33593380

@@ -3367,7 +3388,7 @@ static struct clk_regmap g12a_vclk2_div4_en = {
33673388
.ops = &clk_regmap_gate_ops,
33683389
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
33693390
.num_parents = 1,
3370-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3391+
.flags = CLK_SET_RATE_PARENT,
33713392
},
33723393
};
33733394

@@ -3381,7 +3402,7 @@ static struct clk_regmap g12a_vclk2_div6_en = {
33813402
.ops = &clk_regmap_gate_ops,
33823403
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
33833404
.num_parents = 1,
3384-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3405+
.flags = CLK_SET_RATE_PARENT,
33853406
},
33863407
};
33873408

@@ -3395,7 +3416,7 @@ static struct clk_regmap g12a_vclk2_div12_en = {
33953416
.ops = &clk_regmap_gate_ops,
33963417
.parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
33973418
.num_parents = 1,
3398-
.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3419+
.flags = CLK_SET_RATE_PARENT,
33993420
},
34003421
};
34013422

@@ -3461,6 +3482,7 @@ static struct clk_fixed_factor g12a_vclk2_div2 = {
34613482
&g12a_vclk2_div2_en.hw
34623483
},
34633484
.num_parents = 1,
3485+
.flags = CLK_SET_RATE_PARENT,
34643486
},
34653487
};
34663488

@@ -3474,6 +3496,7 @@ static struct clk_fixed_factor g12a_vclk2_div4 = {
34743496
&g12a_vclk2_div4_en.hw
34753497
},
34763498
.num_parents = 1,
3499+
.flags = CLK_SET_RATE_PARENT,
34773500
},
34783501
};
34793502

@@ -3487,6 +3510,7 @@ static struct clk_fixed_factor g12a_vclk2_div6 = {
34873510
&g12a_vclk2_div6_en.hw
34883511
},
34893512
.num_parents = 1,
3513+
.flags = CLK_SET_RATE_PARENT,
34903514
},
34913515
};
34923516

@@ -3500,6 +3524,7 @@ static struct clk_fixed_factor g12a_vclk2_div12 = {
35003524
&g12a_vclk2_div12_en.hw
35013525
},
35023526
.num_parents = 1,
3527+
.flags = CLK_SET_RATE_PARENT,
35033528
},
35043529
};
35053530

@@ -3561,7 +3586,7 @@ static struct clk_regmap g12a_cts_encl_sel = {
35613586
.ops = &clk_regmap_mux_ops,
35623587
.parent_hws = g12a_cts_parent_hws,
35633588
.num_parents = ARRAY_SIZE(g12a_cts_parent_hws),
3564-
.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3589+
.flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
35653590
},
35663591
};
35673592

@@ -3717,15 +3742,26 @@ static struct clk_regmap g12a_mipi_dsi_pxclk_sel = {
37173742
.ops = &clk_regmap_mux_ops,
37183743
.parent_hws = g12a_mipi_dsi_pxclk_parent_hws,
37193744
.num_parents = ARRAY_SIZE(g12a_mipi_dsi_pxclk_parent_hws),
3720-
.flags = CLK_SET_RATE_NO_REPARENT,
3745+
.flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT,
37213746
},
37223747
};
37233748

3749+
/*
3750+
* FIXME: Force as bypass by forcing a single /1 table entry, and doensn't on boot value
3751+
* when setting a clock whith this node in the clock path, but doesn't garantee the divider
3752+
* is at /1 at boot until a rate is set.
3753+
*/
3754+
static const struct clk_div_table g12a_mipi_dsi_pxclk_div_table[] = {
3755+
{ .val = 0, .div = 1 },
3756+
{ /* sentinel */ },
3757+
};
3758+
37243759
static struct clk_regmap g12a_mipi_dsi_pxclk_div = {
37253760
.data = &(struct clk_regmap_div_data){
37263761
.offset = HHI_MIPIDSI_PHY_CLK_CNTL,
37273762
.shift = 0,
37283763
.width = 7,
3764+
.table = g12a_mipi_dsi_pxclk_div_table,
37293765
},
37303766
.hw.init = &(struct clk_init_data){
37313767
.name = "mipi_dsi_pxclk_div",

0 commit comments

Comments
 (0)