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

Jian Hu via B4 Relay devnull+jian.hu.amlogic.com at kernel.org
Tue Dec 1 00:56:23 PST 2026


From: Jian Hu <jian.hu at amlogic.com>

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 at amlogic.com>
---
 drivers/clk/meson/s4-pll.c | 130 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 102 insertions(+), 28 deletions(-)

diff --git a/drivers/clk/meson/s4-pll.c b/drivers/clk/meson/s4-pll.c
index 56ce6f566e53..52c1836a53d3 100644
--- a/drivers/clk/meson/s4-pll.c
+++ b/drivers/clk/meson/s4-pll.c
@@ -51,6 +51,29 @@
  * Meanwhile, these clock won't ever change at runtime.
  * For the above reasons, we can only use ro_ops for fixed PLL related clocks.
  */
+static struct clk_regmap s4_fixed_prediv = {
+	.data = &(struct clk_regmap_div_data){
+		.offset = ANACTRL_FIXPLL_CTRL0,
+		.shift	= 10,
+		.width	= 5,
+		/*
+		 * CLK_DIVIDER_ONE_BASED: the register value is the divisor
+		 * itself, so a value of 1 gives a divisor of 1 and the PLL
+		 * input is not divided. The hardware keeps this pre-divider
+		 * at 1, which minimizes the PLL jitter.
+		 */
+		.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 s4_fixed_pll_dco = {
 	.data = &(struct meson_clk_pll_data){
 		.en = {
@@ -68,11 +91,6 @@ static struct clk_regmap s4_fixed_pll_dco = {
 			.shift   = 0,
 			.width   = 17,
 		},
-		.n = {
-			.reg_off = ANACTRL_FIXPLL_CTRL0,
-			.shift   = 10,
-			.width   = 5,
-		},
 		.l = {
 			.reg_off = ANACTRL_FIXPLL_CTRL0,
 			.shift   = 31,
@@ -87,8 +105,8 @@ static struct clk_regmap s4_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 *[]) {
+			&s4_fixed_prediv.hw
 		},
 		.num_parents = 1,
 	},
@@ -273,6 +291,34 @@ static struct clk_regmap s4_fclk_div2p5 = {
 	},
 };
 
+/* Force the pre-divider at 1 to minimize PLL jitter */
+static const struct clk_div_table s4_pll_prediv_div_table[] = {
+	{ .val = 1, .div = 1 },
+	{ /* sentinel */ }
+};
+
+static struct clk_regmap s4_gp0_prediv = {
+	.data = &(struct clk_regmap_div_data){
+		.offset = ANACTRL_GP0PLL_CTRL0,
+		.shift	= 10,
+		.width	= 5,
+		.table	= s4_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 s4_gp0_pll_mult_range = {
 	.min = 125,
 	.max = 250,
@@ -302,11 +348,6 @@ static struct clk_regmap s4_gp0_pll_dco = {
 			.shift   = 0,
 			.width   = 8,
 		},
-		.n = {
-			.reg_off = ANACTRL_GP0PLL_CTRL0,
-			.shift   = 10,
-			.width   = 5,
-		},
 		.l = {
 			.reg_off = ANACTRL_GP0PLL_CTRL0,
 			.shift   = 31,
@@ -324,10 +365,11 @@ static struct clk_regmap s4_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 = "xtal", }
+		.parent_hws = (const struct clk_hw *[]) {
+			&s4_gp0_prediv.hw
 		},
 		.num_parents = 1,
+		.flags = CLK_SET_RATE_PARENT,
 	},
 };
 
@@ -350,6 +392,24 @@ static struct clk_regmap s4_gp0_pll = {
 	},
 };
 
+static struct clk_regmap s4_hifi_prediv = {
+	.data = &(struct clk_regmap_div_data){
+		.offset = ANACTRL_HIFIPLL_CTRL0,
+		.shift	= 10,
+		.width	= 5,
+		.table	= s4_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 = "xtal", }
+		},
+		.num_parents = 1,
+	},
+};
+
 /*
  * Internal hifi pll emulation configuration parameters
  */
@@ -373,11 +433,6 @@ static struct clk_regmap s4_hifi_pll_dco = {
 			.shift   = 0,
 			.width   = 8,
 		},
-		.n = {
-			.reg_off = ANACTRL_HIFIPLL_CTRL0,
-			.shift   = 10,
-			.width   = 5,
-		},
 		.frac = {
 			.reg_off = ANACTRL_HIFIPLL_CTRL1,
 			.shift   = 0,
@@ -402,10 +457,11 @@ static struct clk_regmap s4_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 = "xtal", }
+		.parent_hws = (const struct clk_hw *[]) {
+			&s4_hifi_prediv.hw
 		},
 		.num_parents = 1,
+		.flags = CLK_SET_RATE_PARENT,
 	},
 };
 
@@ -428,6 +484,24 @@ static struct clk_regmap s4_hifi_pll = {
 	},
 };
 
+static struct clk_regmap s4_hdmi_prediv = {
+	.data = &(struct clk_regmap_div_data){
+		.offset = ANACTRL_HDMIPLL_CTRL0,
+		.shift	= 10,
+		.width	= 5,
+		.table	= s4_pll_prediv_div_table,
+		.flags	= CLK_DIVIDER_INVALID_ZERO,
+	},
+	.hw.init = &(struct clk_init_data){
+		.name = "hdmi_prediv",
+		.ops = &clk_regmap_divider_ops,
+		.parent_data = (const struct clk_parent_data []) {
+			{ .fw_name = "xtal", }
+		},
+		.num_parents = 1,
+	},
+};
+
 static struct clk_regmap s4_hdmi_pll_dco = {
 	.data = &(struct meson_clk_pll_data){
 		.en = {
@@ -440,11 +514,6 @@ static struct clk_regmap s4_hdmi_pll_dco = {
 			.shift   = 0,
 			.width   = 8,
 		},
-		.n = {
-			.reg_off = ANACTRL_HDMIPLL_CTRL0,
-			.shift   = 10,
-			.width   = 5,
-		},
 		.l = {
 			.reg_off = ANACTRL_HDMIPLL_CTRL0,
 			.shift   = 31,
@@ -460,10 +529,11 @@ static struct clk_regmap s4_hdmi_pll_dco = {
 	.hw.init = &(struct clk_init_data){
 		.name = "hdmi_pll_dco",
 		.ops = &meson_clk_pll_ops,
-		.parent_data = (const struct clk_parent_data []) {
-			{ .fw_name = "xtal", }
+		.parent_hws = (const struct clk_hw *[]) {
+			&s4_hdmi_prediv.hw
 		},
 		.num_parents = 1,
+		.flags = CLK_SET_RATE_PARENT,
 	},
 };
 
@@ -760,6 +830,7 @@ static struct clk_regmap s4_mpll3 = {
 
 /* Array of all clocks provided by this provider */
 static struct clk_hw *s4_pll_hw_clks[] = {
+	[CLKID_FIXED_PREDIV]		= &s4_fixed_prediv.hw,
 	[CLKID_FIXED_PLL_DCO]		= &s4_fixed_pll_dco.hw,
 	[CLKID_FIXED_PLL]		= &s4_fixed_pll.hw,
 	[CLKID_FCLK_DIV2_DIV]		= &s4_fclk_div2_div.hw,
@@ -774,10 +845,13 @@ static struct clk_hw *s4_pll_hw_clks[] = {
 	[CLKID_FCLK_DIV7]		= &s4_fclk_div7.hw,
 	[CLKID_FCLK_DIV2P5_DIV]		= &s4_fclk_div2p5_div.hw,
 	[CLKID_FCLK_DIV2P5]		= &s4_fclk_div2p5.hw,
+	[CLKID_GP0_PREDIV]		= &s4_gp0_prediv.hw,
 	[CLKID_GP0_PLL_DCO]		= &s4_gp0_pll_dco.hw,
 	[CLKID_GP0_PLL]			= &s4_gp0_pll.hw,
+	[CLKID_HIFI_PREDIV]		= &s4_hifi_prediv.hw,
 	[CLKID_HIFI_PLL_DCO]		= &s4_hifi_pll_dco.hw,
 	[CLKID_HIFI_PLL]		= &s4_hifi_pll.hw,
+	[CLKID_HDMI_PREDIV]		= &s4_hdmi_prediv.hw,
 	[CLKID_HDMI_PLL_DCO]		= &s4_hdmi_pll_dco.hw,
 	[CLKID_HDMI_PLL_OD]		= &s4_hdmi_pll_od.hw,
 	[CLKID_HDMI_PLL]		= &s4_hdmi_pll.hw,

-- 
2.47.1





More information about the linux-arm-kernel mailing list