From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA088606A320 for ; Tue, 1 Dec 2026 08:57:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=bqrKdLlL; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KcuSO/gb DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References: Message-Id:MIME-Version:Subject:Date:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=MdBpk2riEmwQWmLGBw5PBsWuX/KQtykXtZYkym1BHsw=; b=bqrKdLlLGBK7sDesiSXl2qs8q6 mFjiOwXqJhSuGU3OknuS0wGV57ww/2H7X5YTFmbWYEYSfbDxvqoH7ZRqzWQqZvlVtMQY7Xj1TuSgM hKUad0iDlPnVyRBLv1mqO2mv0QflQs1AD16uneKyCTM0po4CC4dh8QFd4MTl39rYW3viPlvr3LdK/ Z1hgoiEGSGmf8zinCHcMeuDH6C3K5TJfFPZ1TDBveHkonoDXj+pNmWVNmDodGv4a8vtOvQCnn6JvT FwPNEyOrP98UMckKvB6YEiW4SIAuXfqTEnN6e0NeHlyltdrrU05bgV/PYVNrGbbenezSnby1fcR3L h3YB/9cA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYJfh-000000076RK-1xOM; Tue, 01 Dec 2026 08:57:09 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYJfW-0000000765j-3MTn; Tue, 01 Dec 2026 08:56:58 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 164EC623D7; Tue, 1 Dec 2026 08:56:58 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796115417; b=mJwZhslDrAXm3ePey4Jr2iHip+YDzulpfyvEWUlqLGanWd8ZF96fohQrUSg5cCJHZHpC 22frk6wYJaXr52/K0jKsfI999jK0T9JUk1FtJANA5B9qkHJywUapHp10TJimdrl9nzFfT FrSH795JpmYts7VIStGw8OAcrRyekONWmtVDdGD73tGntAp3/GCBqQjyHgoXPxPpKb2dm hY4xGfZJM3sGkLTVF6AaHosqj4d8o7/MZ4zzKE7l84fZndoGqy0tko9jhmVQZB88ovjlj y3Mvex7GzGmU/c2Ute5Ywa+QO+0YKWQWrBsnq6tWz2DcK9TRLtBjaJwDJcWltt0d3Bg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796115417; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=XA3BIGVVmK6x0Jll0p8pD3THTJaGRTGlvkdQhXk/PK0=; b=ia3KcC+dEFWuxJRpSM1UfK0vns3eWnQs4PnaIrkOdNDtbf315rbF9h/8JZTrmqb5/7OO IBVRHjNFHKmAeyG2qPWL6nqe9UDpW/ESjJ99lQ4+E4YzuD27wu5UvaWtZDnvkVQHLVmnC N9ZdvNI81chsDpoPxVe7pCleTsITqIU6EmsMH6X1StRNi6WPhssAIa7pbfeO78bzQxhGM 2B1w7W5xnMbgfPdnpIjglZ6Yk444Y0BdX7jW12NK8alQqqYnxkb1/gVNi54UsXu9NQgLJ JMfhbUZeKeofE1eXDb2Jb9n4eznuRt+OMvAn8sOLmk3UWL7oxz6RUBeO14pDUN0lTwg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 070261F00A1D; Tue, 1 Dec 2026 08:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115417; bh=XA3BIGVVmK6x0Jll0p8pD3THTJaGRTGlvkdQhXk/PK0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=KcuSO/gbNCLbS+r4xTbBKGllytqCLmcfPDlNEqSmxN98UtCujE4kdO3BTvn60wyoi m/RnEYB4pvfFqOnb0fACZss4m462uc4zYP0+6zkcP+FpgROwAwYvo2tQmJ2dQhUDtg U7aj5JT/+G+O1SVHPocryOatflNmcP+ZsSvvC/8HMmhPyLQzj1TURcKFGs7KGGKDq0 JUs5gW4u0r9J8HKGCt1I8cy6WJruOdLU1NORTpgUC+kb5MoebIib6wPrcrq/3F+ov4 do37vmFh3bu4nkzuTuUhhDgqi2JxHud1o5JYbVyir/GY7wWbWfKsF/jcknm8tQNuou GSwF2GfRFnlxw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id D4BE64ECAD; Tue, 1 Dec 2026 08:56:42 +0000 (UTC) From: Jian Hu via B4 Relay Date: Tue, 01 Dec 2026 16:56:25 +0800 Subject: [PATCH RFC RFT v3 12/13] clk: meson: t7: Model the PLL pre-divider as a divider clock X-Archived-By: MIME-Version: 1.0 Message-Id: <20261201-meson_refactor_n-v3-12-f85a4460fd80@amlogic.com> References: <20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com> In-Reply-To: <20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com> To: Stephen Boyd , Brian Masney , Jerome Brunet , Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Carlo Caione , 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 X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796115399; l=10536; i=jian.hu@amlogic.com; s=20260415; h=from:subject:message-id; bh=Pj1fqq+kjHTwKtpagr+t4eJLYhOnZR/skh0yx2/1FnA=; b=rFGUxPE0ccxwjj5WCAN49iJQUtt6NXSOF7OhGATn3VY7eKpCMb9C28LvmVZVZSbIy1Q8Mh6bc KOfZ0u3nXjvA3f31XkP8A2BgnsZe3TYXwVEtCyHOs+3coa7gqC8U4t3 X-Developer-Key: i=jian.hu@amlogic.com; a=ed25519; pk=zHUE+rNtH9z+Sb8au1/elWknjFQmy5QDVkBoxleuOIA= X-Endpoint-Received: by B4 Relay for jian.hu@amlogic.com/20260415 with auth_id=735 X-Original-From: Jian Hu X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: jian.hu@amlogic.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Jian Hu 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 --- 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