[PATCH RFC RFT v3 06/13] clk: meson: c3: Model the PLL pre-divider as a divider clock

From: Jian Hu via B4 Relay

Date: Tue Dec 01 2026 - 03:57:20 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.

Signed-off-by: Jian Hu <jian.hu@xxxxxxxxxxx>
---
drivers/clk/meson/c3-pll.c | 97 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 76 insertions(+), 21 deletions(-)

diff --git a/drivers/clk/meson/c3-pll.c b/drivers/clk/meson/c3-pll.c
index dd047d17488c..984f43f1c76c 100644
--- a/drivers/clk/meson/c3-pll.c
+++ b/drivers/clk/meson/c3-pll.c
@@ -230,6 +230,34 @@ static struct clk_regmap c3_fclk_div7 = {
},
};

+/* Force the pre-divider at 1 to minimize PLL jitter */
+static const struct clk_div_table c3_pll_prediv_div_table[] = {
+ { .val = 1, .div = 1 },
+ { /* sentinel */ }
+};
+
+static struct clk_regmap c3_gp0_prediv = {
+ .data = &(struct clk_regmap_div_data) {
+ .offset = ANACTRL_GP0PLL_CTRL0,
+ .shift = 10,
+ .width = 5,
+ .table = c3_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 = "top",
+ },
+ .num_parents = 1,
+ },
+};
+
static const struct reg_sequence c3_gp0_pll_init_regs[] = {
{ .reg = ANACTRL_GP0PLL_CTRL2, .def = 0x0 },
{ .reg = ANACTRL_GP0PLL_CTRL3, .def = 0x48681c00 },
@@ -260,11 +288,6 @@ static struct clk_regmap c3_gp0_pll_dco = {
.shift = 0,
.width = 19,
},
- .n = {
- .reg_off = ANACTRL_GP0PLL_CTRL0,
- .shift = 10,
- .width = 5,
- },
.l = {
.reg_off = ANACTRL_GP0PLL_CTRL0,
.shift = 31,
@@ -282,10 +305,11 @@ static struct clk_regmap c3_gp0_pll_dco = {
.hw.init = &(struct clk_init_data) {
.name = "gp0_pll_dco",
.ops = &meson_clk_pll_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "top",
+ .parent_hws = (const struct clk_hw *[]) {
+ &c3_gp0_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};

@@ -318,6 +342,24 @@ static struct clk_regmap c3_gp0_pll = {
},
};

+static struct clk_regmap c3_hifi_prediv = {
+ .data = &(struct clk_regmap_div_data) {
+ .offset = ANACTRL_HIFIPLL_CTRL0,
+ .shift = 10,
+ .width = 5,
+ .table = c3_pll_prediv_div_table,
+ .flags = CLK_DIVIDER_INVALID_ZERO,
+ },
+ .hw.init = &(struct clk_init_data) {
+ .name = "hifi_prediv",
+ .ops = &clk_regmap_divider_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "top",
+ },
+ .num_parents = 1,
+ },
+};
+
static const struct reg_sequence c3_hifi_pll_init_regs[] = {
{ .reg = ANACTRL_HIFIPLL_CTRL2, .def = 0x0 },
{ .reg = ANACTRL_HIFIPLL_CTRL3, .def = 0x6a285c00 },
@@ -343,11 +385,6 @@ static struct clk_regmap c3_hifi_pll_dco = {
.shift = 0,
.width = 19,
},
- .n = {
- .reg_off = ANACTRL_HIFIPLL_CTRL0,
- .shift = 10,
- .width = 5,
- },
.l = {
.reg_off = ANACTRL_HIFIPLL_CTRL0,
.shift = 31,
@@ -366,10 +403,11 @@ static struct clk_regmap c3_hifi_pll_dco = {
.hw.init = &(struct clk_init_data) {
.name = "hifi_pll_dco",
.ops = &meson_clk_pll_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "top",
+ .parent_hws = (const struct clk_hw *[]) {
+ &c3_hifi_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};

@@ -391,6 +429,24 @@ static struct clk_regmap c3_hifi_pll = {
},
};

+static struct clk_regmap c3_mclk_prediv = {
+ .data = &(struct clk_regmap_div_data) {
+ .offset = ANACTRL_MPLL_CTRL0,
+ .shift = 16,
+ .width = 5,
+ .table = c3_pll_prediv_div_table,
+ .flags = CLK_DIVIDER_INVALID_ZERO,
+ },
+ .hw.init = &(struct clk_init_data) {
+ .name = "mclk_prediv",
+ .ops = &clk_regmap_divider_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "mclk",
+ },
+ .num_parents = 1,
+ },
+};
+
static const struct reg_sequence c3_mclk_pll_init_regs[] = {
{ .reg = ANACTRL_MPLL_CTRL1, .def = 0x1420500f },
{ .reg = ANACTRL_MPLL_CTRL2, .def = 0x00023041 },
@@ -415,11 +471,6 @@ static struct clk_regmap c3_mclk_pll_dco = {
.shift = 0,
.width = 8,
},
- .n = {
- .reg_off = ANACTRL_MPLL_CTRL0,
- .shift = 16,
- .width = 5,
- },
.l = {
.reg_off = ANACTRL_MPLL_CTRL0,
.shift = 31,
@@ -437,10 +488,11 @@ static struct clk_regmap c3_mclk_pll_dco = {
.hw.init = &(struct clk_init_data) {
.name = "mclk_pll_dco",
.ops = &meson_clk_pll_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "mclk",
+ .parent_hws = (const struct clk_hw *[]) {
+ &c3_mclk_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};

@@ -636,10 +688,13 @@ static struct clk_hw *c3_pll_hw_clks[] = {
[CLKID_FCLK_DIV5] = &c3_fclk_div5.hw,
[CLKID_FCLK_DIV7_DIV] = &c3_fclk_div7_div.hw,
[CLKID_FCLK_DIV7] = &c3_fclk_div7.hw,
+ [CLKID_GP0_PREDIV] = &c3_gp0_prediv.hw,
[CLKID_GP0_PLL_DCO] = &c3_gp0_pll_dco.hw,
[CLKID_GP0_PLL] = &c3_gp0_pll.hw,
+ [CLKID_HIFI_PREDIV] = &c3_hifi_prediv.hw,
[CLKID_HIFI_PLL_DCO] = &c3_hifi_pll_dco.hw,
[CLKID_HIFI_PLL] = &c3_hifi_pll.hw,
+ [CLKID_MCLK_PREDIV] = &c3_mclk_prediv.hw,
[CLKID_MCLK_PLL_DCO] = &c3_mclk_pll_dco.hw,
[CLKID_MCLK_PLL_OD] = &c3_mclk_pll_od.hw,
[CLKID_MCLK_PLL] = &c3_mclk_pll.hw,

--
2.47.1