From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796115413; b=jrp3F17y9j4ZckoFpLQtEFgfpSKg5Uhf3YcHnegvcXgPGnUL9sZGMrYjLnYcV+PmgNvd AFYhUCENXM7O506r76vHa407AgIPjUYSdiWycuNyeiLgWzvLnSjPB65m36hQhsT/scDEK YIFS6LFsZ/plQauwvrbFogDyM4vNRBKoLK1v98yQzubQw6MbrlJg9qmfHpN5et6Rew1mB WhFhPyGjjJys9QqqU8BqlaeP45qQHwitr+CjnkwaGHLkvIc4k8onBswxe+gNrah977Rsy c9CqY7j/nZpNqywvmpkQPYKUeZr9osT32JwtqlAixFWZqTrYVpiFnOW+L3K3E2sqsDw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115413; h=Received: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=U2Wb9ibsjhzoY/ecFGLwf+khT3Zj2Y6mlBH9lJ0G4J0=; b=IemY67ML+ldnP1PY7UXKfonaxuv/TQsBfvnbkHoKxRStJhIpVAPX1RyB5741rcqvLLLH f4OIqGt7xEp5gsJR/+LlyjpGFd6sC/uWE40XHxWTK9oU+paFykmNh2d7DGUTiK/WRyByI eD0EZGn4fndq+viGQVuFh16mdJ6ZYTK8NxKrjDpTm0JmBDzDIshFj/eqnj5Bat1QwDYub 0tf60HhePJuFY1+ENgQoGOF2YqiqJxKF2zlwIyFe8xHZtXoYpQ5tJ5LLVTMx5GwrbBRWD DoAQ7RAs6jII6tLtKTUOwpZU3Xmguj86PeP7M8KH1D8mhdqcMkY0oY6dz+D45XdAxuQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YVz1Zf3W; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2A5A606A32E; Tue, 1 Dec 2026 08:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YVz1Zf3W 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=1796115413; b=t1gFVUElN5kd2cPaCAPAXR8OyZ0Zl5faf8WD8ru6maeZPtM4JHurRbtYPfm04YMSwhJY deMc7zcRsm+UiXvvk5wgtuFFeyTdAQYBp8cgRoeX6Lqjav62avCeDoZcgudslYOF9tx62 1yzgXZEWxLh8YTUps77f8PxFCZTmfHGXdhrQvZf02eCmTDOWX58PxHveg2+06PD7Cl85j d26YBx2WhYlAOM8ksdI8rIPfH7lCfm/EVEQLvRKNRWULGzXePcVqtBrkSY9HiL6KUcdMB jlCshZQyhjor5bs/uuDTIMZozi3laVWwLgo44YgAgdZollRbq2AidCmpXXcxi95738A== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796115413; 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=U2Wb9ibsjhzoY/ecFGLwf+khT3Zj2Y6mlBH9lJ0G4J0=; b=KtdZ2w8NzgmmSSDLEMvEnIWG8mHhZLBRN93ALsXMrMpd5rkr69Aa1BHtGwT8lyB+p0mp Vj40kY7pZ/zxYt5AscGWwe8NNZh1YBI2QDaTigqAxXsmb2ej16Pu2V5Pv+rZyZMW4jwWE nuHDsGvE9vdULaDEvwq0tCJ7MtV2/qyRMdsC0HLjQiQiIOwxv0T3TS4z1HXFdDUd4lGtI P1JDV8s3ZVxg/4DNccZWNmUOLmsDfjgXlnJr24ozruY3sYuPUtxEzyM3CFOlpUT6KC3Pm RkDgpC/u2M7rozIb2IoDDl+vucKDeQdoAaTmGiONzRn0TbP2+gwCBjwF4fr1zwiCKzA== 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 2F66D1F0089F; Tue, 1 Dec 2026 08:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115413; bh=U2Wb9ibsjhzoY/ecFGLwf+khT3Zj2Y6mlBH9lJ0G4J0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=YVz1Zf3WPROQmWP3PIeMA9+qxjwF8+A8ZXP72EEckcCIagbUosZrR691r9qxwo+6J DTQa4chwC9Nf0ovdHxHBXWH/EQSK38Nq9tlky2j6uopmsgaRLljbL7dil9szaKyMMT 7ROnWgNNeiKeWlyGBiL+pV3di4lNCsCaNNYZyyNTJNeb6mp8PJ8jWlEkl1sT2zh4wX J08V9R/KZiPot3BoBk821K0ro0yTqwpBtxi+Mq6+ZPoiS7nSNEGz9whbH/eejoRRd5 3LbPcjtirdFp+whuxmQbkUGbftAJaqpPaeyxYZgIksfsFWbrcZhXtKcaIu3+eGqUYm 9vzNVpQQHrfrQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id AD7C34EC8E; Tue, 1 Dec 2026 08:56:41 +0000 (UTC) From: Jian Hu via B4 Relay Date: Tue, 01 Dec 2026 16:56:17 +0800 Subject: [PATCH RFC RFT v3 04/13] clk: meson: axg: Model the PLL pre-divider as a divider clock X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261201-meson_refactor_n-v3-4-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=1796115398; l=10001; i=jian.hu@amlogic.com; s=20260415; h=from:subject:message-id; bh=2jcA6/eOaRGiczUp8lF7Nn/ZxJZpVjg/QQ7qaZmPiRk=; b=xjbMi+iZMltERadftLQlOwT1GnzwoeDigC6SwsQYpebuEUlRuGngJ012nyVa54cBzXbJ/N4Uy oHtga4uZiC1Bzg1t/ReB5LEexF5IHVADcZDDNs7bAp+LvmmibCvt3we 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 Reply-To: jian.hu@amlogic.com Content-Transfer-Encoding: 7bit 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. The GP1 PLL table lists contiguous multipliers, describe it with a pll_mult_range instead of a table. Signed-off-by: Jian Hu --- drivers/clk/meson/axg.c | 204 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 136 insertions(+), 68 deletions(-) diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c index 280842e9cb37..8c5a2640324c 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c @@ -107,6 +107,30 @@ #define HHI_DPLL_TOP_I 0x318 #define HHI_DPLL_TOP2_I 0x31C +static struct clk_regmap axg_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 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. + * The same applies to sys_prediv. + */ + .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 axg_fixed_pll_dco = { .data = &(struct meson_clk_pll_data){ .en = { @@ -119,11 +143,6 @@ static struct clk_regmap axg_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, @@ -143,8 +162,8 @@ static struct clk_regmap axg_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 *[]) { + &axg_fixed_prediv.hw }, .num_parents = 1, }, @@ -171,6 +190,23 @@ static struct clk_regmap axg_fixed_pll = { }, }; +static struct clk_regmap axg_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 axg_sys_pll_dco = { .data = &(struct meson_clk_pll_data){ .en = { @@ -183,11 +219,6 @@ static struct clk_regmap axg_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, @@ -202,8 +233,8 @@ static struct clk_regmap axg_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 *[]) { + &axg_sys_prediv.hw }, .num_parents = 1, }, @@ -227,37 +258,37 @@ static struct clk_regmap axg_sys_pll = { }, }; -static const struct pll_params_table axg_gp0_pll_params_table[] = { - 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), - PLL_PARAMS(63, 1), - PLL_PARAMS(64, 1), - PLL_PARAMS(65, 1), - PLL_PARAMS(66, 1), - PLL_PARAMS(67, 1), - PLL_PARAMS(68, 1), - { /* sentinel */ }, +/* Force the pre-divider at 1 to minimize PLL jitter */ +static const struct clk_div_table axg_pll_prediv_div_table[] = { + { .val = 1, .div = 1 }, + { /* sentinel */ } +}; + +static struct clk_regmap axg_gp0_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_GP0_PLL_CNTL, + .shift = 9, + .width = 5, + .table = axg_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 axg_gp0_pll_mult_range = { + .min = 40, + .max = 68, }; static const struct reg_sequence axg_gp0_init_regs[] = { @@ -280,11 +311,6 @@ static struct clk_regmap axg_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, @@ -300,17 +326,18 @@ static struct clk_regmap axg_gp0_pll_dco = { .shift = 29, .width = 1, }, - .table = axg_gp0_pll_params_table, + .range = &axg_gp0_pll_mult_range, .init_regs = axg_gp0_init_regs, .init_count = ARRAY_SIZE(axg_gp0_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 *[]) { + &axg_gp0_prediv.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -332,6 +359,24 @@ static struct clk_regmap axg_gp0_pll = { }, }; +static struct clk_regmap axg_hifi_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_HIFI_PLL_CNTL, + .shift = 9, + .width = 5, + .table = axg_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, + }, +}; + static const struct reg_sequence axg_hifi_pll_init_regs[] = { { .reg = HHI_HIFI_PLL_CNTL1, .def = 0xc084b000 }, { .reg = HHI_HIFI_PLL_CNTL2, .def = 0xb75020be }, @@ -352,11 +397,6 @@ static struct clk_regmap axg_hifi_pll_dco = { .shift = 0, .width = 9, }, - .n = { - .reg_off = HHI_HIFI_PLL_CNTL, - .shift = 9, - .width = 5, - }, .frac = { .reg_off = HHI_HIFI_PLL_CNTL5, .shift = 0, @@ -372,7 +412,7 @@ static struct clk_regmap axg_hifi_pll_dco = { .shift = 29, .width = 1, }, - .table = axg_gp0_pll_params_table, + .range = &axg_gp0_pll_mult_range, .init_regs = axg_hifi_pll_init_regs, .init_count = ARRAY_SIZE(axg_hifi_pll_init_regs), .flags = CLK_MESON_PLL_ROUND_CLOSEST, @@ -380,10 +420,11 @@ static struct clk_regmap axg_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 *[]) { + &axg_hifi_prediv.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -771,6 +812,32 @@ static struct clk_regmap axg_mpll3 = { }, }; +/* + * This AXG PCIe PLL needs pre-divider 3 to hit the target frequency 100Mhz. + */ +static const struct clk_div_table axg_pcie_pll_prediv_div_table[] = { + { .val = 3, .div = 3 }, + { /* sentinel */ } +}; + +static struct clk_regmap axg_pcie_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_PCIE_PLL_CNTL, + .shift = 9, + .width = 5, + .table = axg_pcie_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 = "xtal", + }, + .num_parents = 1, + }, +}; + static const struct pll_params_table axg_pcie_pll_params_table[] = { { .m = 200, @@ -801,11 +868,6 @@ static struct clk_regmap axg_pcie_pll_dco = { .shift = 0, .width = 9, }, - .n = { - .reg_off = HHI_PCIE_PLL_CNTL, - .shift = 9, - .width = 5, - }, .frac = { .reg_off = HHI_PCIE_PLL_CNTL1, .shift = 0, @@ -828,10 +890,11 @@ static struct clk_regmap axg_pcie_pll_dco = { .hw.init = &(struct clk_init_data){ .name = "pcie_pll_dco", .ops = &meson_clk_pll_ops, - .parent_data = &(const struct clk_parent_data) { - .fw_name = "xtal", + .parent_hws = (const struct clk_hw *[]) { + &axg_pcie_prediv.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -2067,10 +2130,15 @@ static struct clk_hw *axg_hw_clks[] = { [CLKID_GEN_CLK_SEL] = &axg_gen_clk_sel.hw, [CLKID_GEN_CLK_DIV] = &axg_gen_clk_div.hw, [CLKID_GEN_CLK] = &axg_gen_clk.hw, + [CLKID_SYS_PREDIV] = &axg_sys_prediv.hw, [CLKID_SYS_PLL_DCO] = &axg_sys_pll_dco.hw, + [CLKID_FIXED_PREDIV] = &axg_fixed_prediv.hw, [CLKID_FIXED_PLL_DCO] = &axg_fixed_pll_dco.hw, + [CLKID_GP0_PREDIV] = &axg_gp0_prediv.hw, [CLKID_GP0_PLL_DCO] = &axg_gp0_pll_dco.hw, + [CLKID_HIFI_PREDIV] = &axg_hifi_prediv.hw, [CLKID_HIFI_PLL_DCO] = &axg_hifi_pll_dco.hw, + [CLKID_PCIE_PREDIV] = &axg_pcie_prediv.hw, [CLKID_PCIE_PLL_DCO] = &axg_pcie_pll_dco.hw, [CLKID_PCIE_PLL_OD] = &axg_pcie_pll_od.hw, [CLKID_VPU_0_DIV] = &axg_vpu_0_div.hw, -- 2.47.1