From: Jian Hu via B4 Relay <devnull+jian.hu.amlogic.com@kernel.org>
To: Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Jerome Brunet <jbrunet@baylibre.com>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: Carlo Caione <ccaione@baylibre.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, Jian Hu <jian.hu@amlogic.com>
Subject: [PATCH RFC RFT v3 12/13] clk: meson: t7: Model the PLL pre-divider as a divider clock
Date: Tue, 01 Dec 2026 16:56:25 +0800 [thread overview]
Message-ID: <20261201-meson_refactor_n-v3-12-f85a4460fd80@amlogic.com> (raw)
In-Reply-To: <20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com>
From: Jian Hu <jian.hu@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@amlogic.com>
---
drivers/clk/meson/t7-pll.c | 192 +++++++++++++++++++++++++++++++++++----------
1 file changed, 150 insertions(+), 42 deletions(-)
diff --git a/drivers/clk/meson/t7-pll.c b/drivers/clk/meson/t7-pll.c
index 0a622f45fa36..fb20e9e5f991 100644
--- a/drivers/clk/meson/t7-pll.c
+++ b/drivers/clk/meson/t7-pll.c
@@ -71,6 +71,34 @@
#define MCLK_PLL_CNTL4 0x10
#define MCLK_PLL_STS 0x14
+/* Force the pre-divider at 1 to minimize PLL jitter */
+static const struct clk_div_table t7_pll_prediv_div_table[] = {
+ { .val = 1, .div = 1 },
+ { /* sentinel */ }
+};
+
+static struct clk_regmap t7_gp0_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = GP0PLL_CTRL0,
+ .shift = 10,
+ .width = 5,
+ .table = t7_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 = "in0",
+ },
+ .num_parents = 1,
+ },
+};
+
static const struct pll_mult_range t7_media_pll_mult_range = {
.min = 125,
.max = 250,
@@ -97,11 +125,6 @@ static struct clk_regmap t7_gp0_pll_dco = {
.shift = 0,
.width = 8,
},
- .n = {
- .reg_off = GP0PLL_CTRL0,
- .shift = 10,
- .width = 5,
- },
.l = {
.reg_off = GP0PLL_STS,
.shift = 31,
@@ -119,10 +142,11 @@ static struct clk_regmap t7_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 = "in0",
+ .parent_hws = (const struct clk_hw *[]) {
+ &t7_gp0_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -144,6 +168,24 @@ static struct clk_regmap t7_gp0_pll = {
},
};
+static struct clk_regmap t7_gp1_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = GP1PLL_CTRL0,
+ .shift = 16,
+ .width = 5,
+ .table = t7_pll_prediv_div_table,
+ .flags = CLK_DIVIDER_INVALID_ZERO,
+ },
+ .hw.init = &(struct clk_init_data) {
+ .name = "gp1_prediv",
+ .ops = &clk_regmap_divider_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "in0",
+ },
+ .num_parents = 1,
+ },
+};
+
/*
* Compared with GP0 PLL, GP1 PLL is a newly designed PLL with
* a DCO range of 1.6GHz to 3.2GHz.
@@ -171,11 +213,6 @@ static struct clk_regmap t7_gp1_pll_dco = {
.shift = 0,
.width = 8,
},
- .n = {
- .reg_off = GP1PLL_CTRL0,
- .shift = 16,
- .width = 5,
- },
.l = {
.reg_off = GP1PLL_STS,
.shift = 31,
@@ -193,10 +230,11 @@ static struct clk_regmap t7_gp1_pll_dco = {
.hw.init = &(struct clk_init_data){
.name = "gp1_pll_dco",
.ops = &meson_clk_pll_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "in0",
+ .parent_hws = (const struct clk_hw *[]) {
+ &t7_gp1_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -218,6 +256,24 @@ static struct clk_regmap t7_gp1_pll = {
},
};
+static struct clk_regmap t7_hifi_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HIFIPLL_CTRL0,
+ .shift = 10,
+ .width = 5,
+ .table = t7_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 = "in0",
+ },
+ .num_parents = 1,
+ },
+};
+
static const struct reg_sequence t7_hifi_init_regs[] = {
{ .reg = HIFIPLL_CTRL1, .def = 0x00000000 },
{ .reg = HIFIPLL_CTRL2, .def = 0x00000000 },
@@ -239,11 +295,6 @@ static struct clk_regmap t7_hifi_pll_dco = {
.shift = 0,
.width = 8,
},
- .n = {
- .reg_off = HIFIPLL_CTRL0,
- .shift = 10,
- .width = 5,
- },
.frac = {
.reg_off = HIFIPLL_CTRL1,
.shift = 0,
@@ -267,10 +318,11 @@ static struct clk_regmap t7_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 = "in0",
+ .parent_hws = (const struct clk_hw *[]) {
+ &t7_hifi_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -292,6 +344,32 @@ static struct clk_regmap t7_hifi_pll = {
},
};
+static struct clk_regmap t7_pcie_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = PCIEPLL_CTRL0,
+ .shift = 10,
+ .width = 5,
+ .table = t7_pll_prediv_div_table,
+ .flags = CLK_DIVIDER_INVALID_ZERO,
+ },
+ .hw.init = &(struct clk_init_data) {
+ .name = "pcie_prediv",
+ .ops = &clk_regmap_divider_ops,
+ .parent_data = &(const struct clk_parent_data) {
+ .fw_name = "in0",
+ },
+ .num_parents = 1,
+ /*
+ * The PCIe prediv register reads zero on power-on.
+ * CLK_DIVIDER_INVALID_ZERO makes the first rate return 0 Hz,
+ * which gets cached by CCF. The PCIe PLL enable callback
+ * later writes a valid non-zero divider value. Use
+ * CLK_GET_RATE_NOCACHE to avoid stale cached rate.
+ */
+ .flags = CLK_GET_RATE_NOCACHE,
+ },
+};
+
/*
* The T7 PCIE PLL is fined tuned to deliver a very precise
* 100MHz reference clock for the PCIe Analog PHY, and thus requires
@@ -324,11 +402,6 @@ static struct clk_regmap t7_pcie_pll_dco = {
.shift = 0,
.width = 8,
},
- .n = {
- .reg_off = PCIEPLL_CTRL0,
- .shift = 10,
- .width = 5,
- },
.l = {
.reg_off = PCIEPLL_CTRL0,
.shift = 31,
@@ -345,10 +418,11 @@ static struct clk_regmap t7_pcie_pll_dco = {
.hw.init = &(struct clk_init_data){
.name = "pcie_pll_dco",
.ops = &meson_clk_pcie_pll_ops,
- .parent_data = &(const struct clk_parent_data) {
- .fw_name = "in0",
+ .parent_hws = (const struct clk_hw *[]) {
+ &t7_pcie_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -624,6 +698,24 @@ static struct clk_regmap t7_mpll3 = {
},
};
+static struct clk_regmap t7_hdmi_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = HDMIPLL_CTRL0,
+ .shift = 10,
+ .width = 5,
+ .table = t7_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 = "in0",
+ },
+ .num_parents = 1,
+ },
+};
+
static const struct reg_sequence t7_hdmi_init_regs[] = {
{ .reg = HDMIPLL_CTRL1, .def = 0x00000000 },
{ .reg = HDMIPLL_CTRL2, .def = 0x00000000 },
@@ -645,11 +737,6 @@ static struct clk_regmap t7_hdmi_pll_dco = {
.shift = 0,
.width = 9,
},
- .n = {
- .reg_off = HDMIPLL_CTRL0,
- .shift = 10,
- .width = 5,
- },
.l = {
.reg_off = HDMIPLL_CTRL0,
.shift = 31,
@@ -667,10 +754,11 @@ static struct clk_regmap t7_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 = "in0", }
+ .parent_hws = (const struct clk_hw *[]) {
+ &t7_hdmi_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -722,6 +810,24 @@ static const struct reg_sequence t7_mclk_init_regs[] = {
{ .reg = MCLK_PLL_CNTL4, .def = 0x00180303 },
};
+static struct clk_regmap t7_mclk_prediv = {
+ .data = &(struct clk_regmap_div_data){
+ .offset = MCLK_PLL_CNTL0,
+ .shift = 16,
+ .width = 5,
+ .table = t7_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 = "in0",
+ },
+ .num_parents = 1,
+ },
+};
+
static struct clk_regmap t7_mclk_pll_dco = {
.data = &(struct meson_clk_pll_data){
.en = {
@@ -734,11 +840,6 @@ static struct clk_regmap t7_mclk_pll_dco = {
.shift = 0,
.width = 8,
},
- .n = {
- .reg_off = MCLK_PLL_CNTL0,
- .shift = 16,
- .width = 5,
- },
.l = {
.reg_off = MCLK_PLL_CNTL0,
.shift = 31,
@@ -761,10 +862,11 @@ static struct clk_regmap t7_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 = "in0",
+ .parent_hws = (const struct clk_hw *[]) {
+ &t7_mclk_prediv.hw
},
.num_parents = 1,
+ .flags = CLK_SET_RATE_PARENT,
},
};
@@ -939,21 +1041,25 @@ static struct clk_regmap t7_mclk_1 = {
};
static struct clk_hw *t7_gp0_hw_clks[] = {
+ [CLKID_GP0_PREDIV] = &t7_gp0_prediv.hw,
[CLKID_GP0_PLL_DCO] = &t7_gp0_pll_dco.hw,
[CLKID_GP0_PLL] = &t7_gp0_pll.hw,
};
static struct clk_hw *t7_gp1_hw_clks[] = {
+ [CLKID_GP1_PREDIV] = &t7_gp1_prediv.hw,
[CLKID_GP1_PLL_DCO] = &t7_gp1_pll_dco.hw,
[CLKID_GP1_PLL] = &t7_gp1_pll.hw,
};
static struct clk_hw *t7_hifi_hw_clks[] = {
+ [CLKID_HIFI_PREDIV] = &t7_hifi_prediv.hw,
[CLKID_HIFI_PLL_DCO] = &t7_hifi_pll_dco.hw,
[CLKID_HIFI_PLL] = &t7_hifi_pll.hw,
};
static struct clk_hw *t7_pcie_hw_clks[] = {
+ [CLKID_PCIE_PREDIV] = &t7_pcie_prediv.hw,
[CLKID_PCIE_PLL_DCO] = &t7_pcie_pll_dco.hw,
[CLKID_PCIE_PLL_DCO_DIV2] = &t7_pcie_pll_dco_div2.hw,
[CLKID_PCIE_PLL_OD] = &t7_pcie_pll_od.hw,
@@ -973,12 +1079,14 @@ static struct clk_hw *t7_mpll_hw_clks[] = {
};
static struct clk_hw *t7_hdmi_hw_clks[] = {
+ [CLKID_HDMI_PREDIV] = &t7_hdmi_prediv.hw,
[CLKID_HDMI_PLL_DCO] = &t7_hdmi_pll_dco.hw,
[CLKID_HDMI_PLL_OD] = &t7_hdmi_pll_od.hw,
[CLKID_HDMI_PLL] = &t7_hdmi_pll.hw,
};
static struct clk_hw *t7_mclk_hw_clks[] = {
+ [CLKID_MCLK_PREDIV] = &t7_mclk_prediv.hw,
[CLKID_MCLK_PLL_DCO] = &t7_mclk_pll_dco.hw,
[CLKID_MCLK_PRE] = &t7_mclk_pre_od.hw,
[CLKID_MCLK_PLL] = &t7_mclk_pll.hw,
--
2.47.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-12-01 8:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 8:56 [PATCH RFC RFT v3 00/13] clk: meson: Refactor " Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 01/13] clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag Jian Hu via B4 Relay
2026-12-01 9:10 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 02/13] clk: meson: clk-regmap: Widen the divider flags to 16 bits Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 03/13] dt-bindings: clock: amlogic: Add PLL pre-divider clock IDs Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 04/13] clk: meson: axg: Model the PLL pre-divider as a divider clock Jian Hu via B4 Relay
2026-12-01 9:11 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 05/13] clk: meson: a1: " Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 06/13] clk: meson: c3: " Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 07/13] clk: meson: gxbb: " Jian Hu via B4 Relay
2026-12-01 9:16 ` sashiko-bot
2026-12-02 9:19 ` Jian Hu
2026-12-01 8:56 ` [PATCH RFC RFT v3 08/13] clk: meson: g12a: " Jian Hu via B4 Relay
2026-12-01 9:19 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 09/13] clk: meson: meson8: " Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 10/13] clk: meson: s4: " Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 11/13] clk: meson: s7: " Jian Hu via B4 Relay
2026-12-01 11:37 ` Carlo Caione
2026-12-01 8:56 ` Jian Hu via B4 Relay [this message]
2026-12-01 8:56 ` [PATCH RFC RFT v3 13/13] clk: meson: pll: Remove the dedicated n parameter Jian Hu via B4 Relay
2026-12-01 9:28 ` sashiko-bot
2026-12-01 13:16 ` Carlo Caione
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201-meson_refactor_n-v3-12-f85a4460fd80@amlogic.com \
--to=devnull+jian.hu.amlogic.com@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=ccaione@baylibre.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jbrunet+clk@baylibre.com \
--cc=jbrunet@baylibre.com \
--cc=jian.hu@amlogic.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®