[PATCH RFC RFT v3 07/13] clk: meson: gxbb: Model the PLL pre-divider as a divider clock
From: Jian Hu via B4 Relay
Date: Tue Dec 01 2026 - 03:57:02 EST
From: Jian Hu <jian.hu@xxxxxxxxxxx>
The pre-divider is currently described by a dedicated n parameter,
although it is a plain divider between the input clock and the DCO.
Model it as a regular divider clock and make it the parent of the DCO.
The GP0 PLL table lists contiguous multipliers, describe it with a
pll_mult_range instead of a table.
Signed-off-by: Jian Hu <jian.hu@xxxxxxxxxxx>
---
drivers/clk/meson/gxbb.c | 260 ++++++++++++++++++++++++++++-------------------
1 file changed, 158 insertions(+), 102 deletions(-)
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 2d5128c0bf9e..b7350788b73e 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -115,6 +115,29 @@
#define HHI_BT656_CLK_CNTL 0x3d4
#define HHI_SAR_CLK_CNTL 0x3d8
+static struct clk_regmap gxbb_fixed_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HHI_MPLL_CNTL,
+ .shift = 9,
+ .width = 5,
+ /*
+ * CLK_DIVIDER_ONE_BASED: the register value is the divisor
+ * itself, so a value of 3 gives a divisor of 3.
+ * The hardware design sets the division factor of this prescaler
+ * to 3 to produce a 2G output.
+ */
+ .flags = CLK_DIVIDER_ONE_BASED,
+ },
+ .hw.init = &(struct clk_init_data){
+ .name = "fixed_prediv",
+ .ops = &clk_regmap_divider_ro_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "xtal",
+ },
+ .num_parents = 1,
+ },
+};
+
static struct clk_regmap gxbb_fixed_pll_dco = {
.data = &(struct meson_clk_pll_data){
.en = {
@@ -127,11 +150,6 @@ static struct clk_regmap gxbb_fixed_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HHI_MPLL_CNTL,
- .shift = 9,
- .width = 5,
- },
.frac = {
.reg_off = HHI_MPLL_CNTL2,
.shift = 0,
@@ -151,8 +169,8 @@ static struct clk_regmap gxbb_fixed_pll_dco = {
.hw.init = &(struct clk_init_data){
.name = "fixed_pll_dco",
.ops = &meson_clk_pll_ro_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "xtal",
+ .parent_hws = (const struct clk_hw *[]) {
+ &gxbb_fixed_prediv.hw
},
.num_parents = 1,
},
@@ -192,6 +210,28 @@ static struct clk_fixed_factor gxbb_hdmi_pll_pre_mult = {
},
};
+static struct clk_regmap gxbb_hdmi_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HHI_HDMI_PLL_CNTL,
+ .shift = 9,
+ .width = 5,
+ .flags = CLK_DIVIDER_ONE_BASED,
+ },
+ .hw.init = &(struct clk_init_data){
+ .name = "hdmi_prediv",
+ .ops = &clk_regmap_divider_ro_ops,
+ .parent_hws = (const struct clk_hw *[]) {
+ &gxbb_hdmi_pll_pre_mult.hw
+ },
+ .num_parents = 1,
+ /*
+ * Display directly handle hdmi pll registers ATM, we need
+ * NOCACHE to keep our view of the clock as accurate as possible
+ */
+ .flags = CLK_GET_RATE_NOCACHE,
+ },
+};
+
static struct clk_regmap gxbb_hdmi_pll_dco = {
.data = &(struct meson_clk_pll_data){
.en = {
@@ -204,11 +244,6 @@ static struct clk_regmap gxbb_hdmi_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HHI_HDMI_PLL_CNTL,
- .shift = 9,
- .width = 5,
- },
.frac = {
.reg_off = HHI_HDMI_PLL_CNTL2,
.shift = 0,
@@ -229,7 +264,29 @@ static struct clk_regmap gxbb_hdmi_pll_dco = {
.name = "hdmi_pll_dco",
.ops = &meson_clk_pll_ro_ops,
.parent_hws = (const struct clk_hw *[]) {
- &gxbb_hdmi_pll_pre_mult.hw
+ &gxbb_hdmi_prediv.hw
+ },
+ .num_parents = 1,
+ /*
+ * Display directly handle hdmi pll registers ATM, we need
+ * NOCACHE to keep our view of the clock as accurate as possible
+ */
+ .flags = CLK_GET_RATE_NOCACHE,
+ },
+};
+
+static struct clk_regmap gxl_hdmi_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HHI_HDMI_PLL_CNTL,
+ .shift = 9,
+ .width = 5,
+ .flags = CLK_DIVIDER_ONE_BASED,
+ },
+ .hw.init = &(struct clk_init_data){
+ .name = "hdmi_prediv",
+ .ops = &clk_regmap_divider_ro_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "xtal",
},
.num_parents = 1,
/*
@@ -252,11 +309,6 @@ static struct clk_regmap gxl_hdmi_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HHI_HDMI_PLL_CNTL,
- .shift = 9,
- .width = 5,
- },
/*
* On gxl, there is a register shift due to
* HHI_HDMI_PLL_CNTL1 which does not exist on gxbb,
@@ -282,8 +334,8 @@ static struct clk_regmap gxl_hdmi_pll_dco = {
.hw.init = &(struct clk_init_data){
.name = "hdmi_pll_dco",
.ops = &meson_clk_pll_ro_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "xtal",
+ .parent_hws = (const struct clk_hw *[]) {
+ &gxl_hdmi_prediv.hw
},
.num_parents = 1,
/*
@@ -414,6 +466,23 @@ static struct clk_regmap gxl_hdmi_pll = {
},
};
+static struct clk_regmap gxbb_sys_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HHI_SYS_PLL_CNTL,
+ .shift = 9,
+ .width = 5,
+ .flags = CLK_DIVIDER_ONE_BASED,
+ },
+ .hw.init = &(struct clk_init_data){
+ .name = "sys_prediv",
+ .ops = &clk_regmap_divider_ro_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "xtal",
+ },
+ .num_parents = 1,
+ },
+};
+
static struct clk_regmap gxbb_sys_pll_dco = {
.data = &(struct meson_clk_pll_data){
.en = {
@@ -426,11 +495,6 @@ static struct clk_regmap gxbb_sys_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HHI_SYS_PLL_CNTL,
- .shift = 9,
- .width = 5,
- },
.l = {
.reg_off = HHI_SYS_PLL_CNTL,
.shift = 31,
@@ -445,8 +509,8 @@ static struct clk_regmap gxbb_sys_pll_dco = {
.hw.init = &(struct clk_init_data){
.name = "sys_pll_dco",
.ops = &meson_clk_pll_ro_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "xtal",
+ .parent_hws = (const struct clk_hw *[]) {
+ &gxbb_sys_prediv.hw
},
.num_parents = 1,
},
@@ -470,39 +534,37 @@ static struct clk_regmap gxbb_sys_pll = {
},
};
-static const struct pll_params_table gxbb_gp0_pll_params_table[] = {
- PLL_PARAMS(32, 1),
- PLL_PARAMS(33, 1),
- PLL_PARAMS(34, 1),
- PLL_PARAMS(35, 1),
- PLL_PARAMS(36, 1),
- PLL_PARAMS(37, 1),
- PLL_PARAMS(38, 1),
- PLL_PARAMS(39, 1),
- PLL_PARAMS(40, 1),
- PLL_PARAMS(41, 1),
- PLL_PARAMS(42, 1),
- PLL_PARAMS(43, 1),
- PLL_PARAMS(44, 1),
- PLL_PARAMS(45, 1),
- PLL_PARAMS(46, 1),
- PLL_PARAMS(47, 1),
- PLL_PARAMS(48, 1),
- PLL_PARAMS(49, 1),
- PLL_PARAMS(50, 1),
- PLL_PARAMS(51, 1),
- PLL_PARAMS(52, 1),
- PLL_PARAMS(53, 1),
- PLL_PARAMS(54, 1),
- PLL_PARAMS(55, 1),
- PLL_PARAMS(56, 1),
- PLL_PARAMS(57, 1),
- PLL_PARAMS(58, 1),
- PLL_PARAMS(59, 1),
- PLL_PARAMS(60, 1),
- PLL_PARAMS(61, 1),
- PLL_PARAMS(62, 1),
- { /* sentinel */ },
+/* Force the pre-divider at 1 to minimize PLL jitter */
+static const struct clk_div_table gxbb_gp0_pll_prediv_div_table[] = {
+ { .val = 1, .div = 1 },
+ { /* sentinel */ }
+};
+
+static struct clk_regmap gxbb_gp0_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HHI_GP0_PLL_CNTL,
+ .shift = 9,
+ .width = 5,
+ .table = gxbb_gp0_pll_prediv_div_table,
+ /*
+ * CLK_DIVIDER_INVALID_ZERO to report 0 Hz during registration.
+ * The same applies below.
+ */
+ .flags = CLK_DIVIDER_INVALID_ZERO,
+ },
+ .hw.init = &(struct clk_init_data){
+ .name = "gp0_prediv",
+ .ops = &clk_regmap_divider_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "xtal",
+ },
+ .num_parents = 1,
+ },
+};
+
+static const struct pll_mult_range gxbb_gp0_pll_mult_range = {
+ .min = 32,
+ .max = 62,
};
static const struct reg_sequence gxbb_gp0_pll_init_regs[] = {
@@ -523,11 +585,6 @@ static struct clk_regmap gxbb_gp0_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HHI_GP0_PLL_CNTL,
- .shift = 9,
- .width = 5,
- },
.l = {
.reg_off = HHI_GP0_PLL_CNTL,
.shift = 31,
@@ -538,13 +595,32 @@ static struct clk_regmap gxbb_gp0_pll_dco = {
.shift = 29,
.width = 1,
},
- .table = gxbb_gp0_pll_params_table,
+ .range = &gxbb_gp0_pll_mult_range,
.init_regs = gxbb_gp0_pll_init_regs,
.init_count = ARRAY_SIZE(gxbb_gp0_pll_init_regs),
},
.hw.init = &(struct clk_init_data){
.name = "gp0_pll_dco",
.ops = &meson_clk_pll_ops,
+ .parent_hws = (const struct clk_hw *[]) {
+ &gxbb_gp0_prediv.hw
+ },
+ .num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
+ },
+};
+
+static struct clk_regmap gxl_gp0_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HHI_GP0_PLL_CNTL,
+ .shift = 9,
+ .width = 5,
+ .table = gxbb_gp0_pll_prediv_div_table,
+ .flags = CLK_DIVIDER_INVALID_ZERO,
+ },
+ .hw.init = &(struct clk_init_data){
+ .name = "gp0_prediv",
+ .ops = &clk_regmap_divider_ops,
.parent_data = &(const struct clk_parent_data) {
.fw_name = "xtal",
},
@@ -552,33 +628,9 @@ static struct clk_regmap gxbb_gp0_pll_dco = {
},
};
-static const struct pll_params_table gxl_gp0_pll_params_table[] = {
- PLL_PARAMS(42, 1),
- PLL_PARAMS(43, 1),
- PLL_PARAMS(44, 1),
- PLL_PARAMS(45, 1),
- PLL_PARAMS(46, 1),
- PLL_PARAMS(47, 1),
- PLL_PARAMS(48, 1),
- PLL_PARAMS(49, 1),
- PLL_PARAMS(50, 1),
- PLL_PARAMS(51, 1),
- PLL_PARAMS(52, 1),
- PLL_PARAMS(53, 1),
- PLL_PARAMS(54, 1),
- PLL_PARAMS(55, 1),
- PLL_PARAMS(56, 1),
- PLL_PARAMS(57, 1),
- PLL_PARAMS(58, 1),
- PLL_PARAMS(59, 1),
- PLL_PARAMS(60, 1),
- PLL_PARAMS(61, 1),
- PLL_PARAMS(62, 1),
- PLL_PARAMS(63, 1),
- PLL_PARAMS(64, 1),
- PLL_PARAMS(65, 1),
- PLL_PARAMS(66, 1),
- { /* sentinel */ },
+static const struct pll_mult_range gxl_gp0_pll_mult_range = {
+ .min = 42,
+ .max = 66,
};
static const struct reg_sequence gxl_gp0_pll_init_regs[] = {
@@ -601,11 +653,6 @@ static struct clk_regmap gxl_gp0_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HHI_GP0_PLL_CNTL,
- .shift = 9,
- .width = 5,
- },
.frac = {
.reg_off = HHI_GP0_PLL_CNTL1,
.shift = 0,
@@ -621,17 +668,18 @@ static struct clk_regmap gxl_gp0_pll_dco = {
.shift = 29,
.width = 1,
},
- .table = gxl_gp0_pll_params_table,
+ .range = &gxl_gp0_pll_mult_range,
.init_regs = gxl_gp0_pll_init_regs,
.init_count = ARRAY_SIZE(gxl_gp0_pll_init_regs),
},
.hw.init = &(struct clk_init_data){
.name = "gp0_pll_dco",
.ops = &meson_clk_pll_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "xtal",
+ .parent_hws = (const struct clk_hw *[]) {
+ &gxl_gp0_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -2371,7 +2419,7 @@ static struct clk_regmap gxbb_cts_encp_sel = {
.data = &(struct clk_regmap_mux_data){
.offset = HHI_VID_CLK_DIV,
.mask = 0xf,
- .shift = 24,
+ .shift = 20,
.table = gxbb_cts_parents_val_table,
},
.hw.init = &(struct clk_init_data){
@@ -3007,11 +3055,15 @@ static struct clk_hw *gxbb_hw_clks[] = {
[CLKID_GEN_CLK_SEL] = &gxbb_gen_clk_sel.hw,
[CLKID_GEN_CLK_DIV] = &gxbb_gen_clk_div.hw,
[CLKID_GEN_CLK] = &gxbb_gen_clk.hw,
+ [CLKID_FIXED_PREDIV] = &gxbb_fixed_prediv.hw,
[CLKID_FIXED_PLL_DCO] = &gxbb_fixed_pll_dco.hw,
+ [CLKID_HDMI_PREDIV] = &gxbb_hdmi_prediv.hw,
[CLKID_HDMI_PLL_DCO] = &gxbb_hdmi_pll_dco.hw,
[CLKID_HDMI_PLL_OD] = &gxbb_hdmi_pll_od.hw,
[CLKID_HDMI_PLL_OD2] = &gxbb_hdmi_pll_od2.hw,
+ [CLKID_SYS_PREDIV] = &gxbb_sys_prediv.hw,
[CLKID_SYS_PLL_DCO] = &gxbb_sys_pll_dco.hw,
+ [CLKID_GP0_PREDIV] = &gxbb_gp0_prediv.hw,
[CLKID_GP0_PLL_DCO] = &gxbb_gp0_pll_dco.hw,
[CLKID_VID_PLL_DIV] = &gxbb_vid_pll_div.hw,
[CLKID_VID_PLL_SEL] = &gxbb_vid_pll_sel.hw,
@@ -3214,11 +3266,15 @@ static struct clk_hw *gxl_hw_clks[] = {
[CLKID_GEN_CLK_SEL] = &gxbb_gen_clk_sel.hw,
[CLKID_GEN_CLK_DIV] = &gxbb_gen_clk_div.hw,
[CLKID_GEN_CLK] = &gxbb_gen_clk.hw,
+ [CLKID_FIXED_PREDIV] = &gxbb_fixed_prediv.hw,
[CLKID_FIXED_PLL_DCO] = &gxbb_fixed_pll_dco.hw,
+ [CLKID_HDMI_PREDIV] = &gxl_hdmi_prediv.hw,
[CLKID_HDMI_PLL_DCO] = &gxl_hdmi_pll_dco.hw,
[CLKID_HDMI_PLL_OD] = &gxl_hdmi_pll_od.hw,
[CLKID_HDMI_PLL_OD2] = &gxl_hdmi_pll_od2.hw,
+ [CLKID_SYS_PREDIV] = &gxbb_sys_prediv.hw,
[CLKID_SYS_PLL_DCO] = &gxbb_sys_pll_dco.hw,
+ [CLKID_GP0_PREDIV] = &gxl_gp0_prediv.hw,
[CLKID_GP0_PLL_DCO] = &gxl_gp0_pll_dco.hw,
[CLKID_VID_PLL_DIV] = &gxbb_vid_pll_div.hw,
[CLKID_VID_PLL_SEL] = &gxbb_vid_pll_sel.hw,
--
2.47.1