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=1796115416; b=KSNMSUvNlZMbF7UM4KdhQFs6yNkxh7xXHj0hcFnOYEHSbdqRuKZjq8eHFOiUlqsrVdwH A5EAwQ7rYptLi/Oh19UwUTBDj/g77TkSp8bFz0BP0FijWEgTzXNns0UaQQ3fwgsOlkuFX WL3gZhSHsoH9+KjIDU8R723zD5tyLXxFocE1h/EZdf6BB32jcTT5fXgRDZgu7hpq2OtC0 1F3Ly5WNJJH9yx2lge+qoKJ0hGOZCMt5kxRkhMdw56PJw+4mNEfu3w7O1OdZ1ZdTx8bER sBn4rPTAxOcUVxmiLtwpGYzydxtD8UDGOjukFlC07XB3B4QiqW4CR7Ca4iUrPhFV7pA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115416; 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=yCxxIgD31mGTyqxnjw8yyUXkQlIwiX9xEEU9lQ5zBSA=; b=QMz4iR0QHGTTwa2MRouatrV4t4GvkghQcPASbZPuTHiF/636/dRFcIEmZoEhDL3R3a9B 9P7576xi4rwuNwDRozCKKLcwqkG6AANzu//mzhKnsuC8o1X1A5ZbLn1A9TxzwogEJLn4v B7UeAQA8dYQYlAobqgCw3WVEcpCDQZlbunnW4K7PSzOcbDqYk9rPIRSOdgS2+ug6urki+ hXI2wuXahvrUBM/2rUwvLX35ZZBDMly4TXK1pC/4V/Qp2sVi6r/okQGLa+EpVQmXydwVE 2uhzlZKMRRsBs/Y/Hf++boKB5E/MNlxEA1Epkl3d1+O4oaE5JpEIXo6fXHSp3beJycQ== 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=OnWHJw4A; 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 B8635606A6AC; Tue, 1 Dec 2026 08:56:56 +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=OnWHJw4A 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=1796115416; b=RjmcOM/KqFXA4iWjQ/wQ3I/Jlt/Wfkmt5jgPl6wCQPFL60nha6WkpvOlmzXo7oS51KdW 3auirw+sKA6jnsvWlvvxVIAfk2BTpDkSTRulTE/+SPlXfNjSg9/dNXT008pmbEoQybDf3 mgPZYubYjy42GYPnKMEhJG74dtylVU3XU5/aXRqvM6A+Y7MNsvMq/hXnXIm+QY80C15Tn Ak1Iz4SWJxoBSzXlFHy0nKDCFdq5mX1TYcSENtDdWYoa2F6NM24TvDGEaE1+y3K0s3T4I Jm+vi5aATCUmSjsuxgm09Kf/lUBTOCtiscgvjGc/V9vJciPEerFPvBpfIO0k9Lpa5vg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796115416; 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=yCxxIgD31mGTyqxnjw8yyUXkQlIwiX9xEEU9lQ5zBSA=; b=j7Pl4wAN7JkPE/GpxpaUasczzuMWvUUjg+aqtJ+Nht9SowTU4ObxkI9XMQpUGS3vwtT4 M7LkPWh/YsN62XlGhvEqivuZBJVovzS0lF9cGS+hQNtqS2eONOupc3KrKcso4MhPi9nRy BAgcjHfnC3BZspLNiuCtmDr4noNTN2IAFNw7TN8RE2DcK1HgQO05lJxfaEMmELzdXiJJS d+olrK0gGGo+D+HCYiI8Cz6gNGGFDdJ13/qTLnatWrdZ2FAGfklYvv4uxllLuEOkgnlRC nSVrzIp/M6HTxD4QbpZD4kDDZ3K1g61ZDbxpr7WdT4gicTlHZf2Ti3p/iN4K/8+/0RA== 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 22A261F00897; Tue, 1 Dec 2026 08:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115416; bh=yCxxIgD31mGTyqxnjw8yyUXkQlIwiX9xEEU9lQ5zBSA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=OnWHJw4AMEqmufnnJ7FFyPW0rnWYepKz7/ZrBXBdhe28dJVaRX7fVlwvIorPvAoRw K3CDGTlG7MrA7n2M+jV9PzQauIqOO7NNC0lkNWwFTV8Rw59HLQ0nNgJVDJPhp+RZQJ qOAyvO4Ca7PmyH3oVkUYuzChuiVTQI1mn+77HZGIbXDYJkAL8mgg9XtPUCOOMhkka6 uwUd8SPfHVObFDnOBE9vw7mL00L2S0rUT3EsokvlMF6cpQgcgYlxYl6am0SnecwKIs Dg5sY5rzgmr95jpHXyvG+2R5tmnB/w49Lplcndxb2g2j59j9h3Unnk10mCU9AYkUf/ J06OEh0TpDdCA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 6AD714ECA2; Tue, 1 Dec 2026 08:56:42 +0000 (UTC) From: Jian Hu via B4 Relay Date: Tue, 01 Dec 2026 16:56:22 +0800 Subject: [PATCH RFC RFT v3 09/13] clk: meson: meson8: 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-9-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=11313; i=jian.hu@amlogic.com; s=20260415; h=from:subject:message-id; bh=P7A7N7oNojznn7Aufr5SQIOPTDWUK+YB2vLaO0I4DTc=; b=E/jQvswEFZaOsTnQZGYV5whFvwDhHQArCd9NC+syyoXQuxXrPYpoNkM5u0t9uYy4qYcHYYBM8 JIS8cAd8eoDAYJrhyuO3Rr388IPgMCOHXhPm3pzZQRJiXECU4OQ4ZcX 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. Signed-off-by: Jian Hu --- drivers/clk/meson/meson8-ddr.c | 33 +++++++-- drivers/clk/meson/meson8b.c | 153 +++++++++++++++++++++++++++++++---------- 2 files changed, 144 insertions(+), 42 deletions(-) diff --git a/drivers/clk/meson/meson8-ddr.c b/drivers/clk/meson/meson8-ddr.c index 0f93774f7371..4bf40fb86dbe 100644 --- a/drivers/clk/meson/meson8-ddr.c +++ b/drivers/clk/meson/meson8-ddr.c @@ -23,6 +23,29 @@ #define DDR_CLK_CNTL 0x18 #define DDR_CLK_STS 0x1c +static struct clk_regmap meson8_ddr_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = AM_DDR_PLL_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. + */ + .flags = CLK_DIVIDER_ONE_BASED, + }, + .hw.init = &(struct clk_init_data){ + .name = "ddr_prediv", + .ops = &clk_regmap_divider_ro_ops, + .parent_data = &(const struct clk_parent_data) { + .fw_name = "xtal", + }, + .num_parents = 1, + }, +}; + static struct clk_regmap meson8_ddr_pll_dco = { .data = &(struct meson_clk_pll_data){ .en = { @@ -35,11 +58,6 @@ static struct clk_regmap meson8_ddr_pll_dco = { .shift = 0, .width = 9, }, - .n = { - .reg_off = AM_DDR_PLL_CNTL, - .shift = 9, - .width = 5, - }, .l = { .reg_off = AM_DDR_PLL_CNTL, .shift = 31, @@ -54,8 +72,8 @@ static struct clk_regmap meson8_ddr_pll_dco = { .hw.init = &(struct clk_init_data){ .name = "ddr_pll_dco", .ops = &meson_clk_pll_ro_ops, - .parent_data = &(const struct clk_parent_data) { - .fw_name = "xtal", + .parent_hws = (const struct clk_hw *[]) { + &meson8_ddr_prediv.hw }, .num_parents = 1, }, @@ -79,6 +97,7 @@ static struct clk_regmap meson8_ddr_pll = { }; static struct clk_hw *meson8_ddr_hw_clks[] = { + [DDR_CLKID_DDR_PREDIV] = &meson8_ddr_prediv.hw, [DDR_CLKID_DDR_PLL_DCO] = &meson8_ddr_pll_dco.hw, [DDR_CLKID_DDR_PLL] = &meson8_ddr_pll.hw, }; diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c index bc029c6ab622..ae2bab501597 100644 --- a/drivers/clk/meson/meson8b.c +++ b/drivers/clk/meson/meson8b.c @@ -119,6 +119,31 @@ static const struct pll_params_table sys_pll_params_table[] = { { /* sentinel */ }, }; +static struct clk_regmap meson8b_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 4 gives a divisor of 4. + * The hardware design sets the division factor of this prescaler + * to 4 to produce a 2.55G output. + */ + .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", + .name = "xtal", + .index = -1, + }, + .num_parents = 1, + }, +}; + static struct clk_regmap meson8b_fixed_pll_dco = { .data = &(struct meson_clk_pll_data){ .en = { @@ -131,11 +156,6 @@ static struct clk_regmap meson8b_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, @@ -155,10 +175,8 @@ static struct clk_regmap meson8b_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", - .name = "xtal", - .index = -1, + .parent_hws = (const struct clk_hw *[]) { + &meson8b_fixed_prediv.hw }, .num_parents = 1, }, @@ -185,17 +203,42 @@ static struct clk_regmap meson8b_fixed_pll = { }, }; +/* Force the pre-divider at 1 to minimize PLL jitter */ +static const struct clk_div_table meson8b_pll_prediv_div_table[] = { + { .val = 1, .div = 1 }, + { /* sentinel */ } +}; + +static struct clk_regmap meson8b_hdmi_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_VID_PLL_CNTL, + .shift = 10, + .width = 5, + .table = meson8b_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", + .index = -1, + }, + .num_parents = 1, + }, +}; + static struct clk_fixed_factor hdmi_pll_dco_in = { .mult = 2, .div = 1, .hw.init = &(struct clk_init_data){ .name = "hdmi_pll_dco_in", .ops = &clk_fixed_factor_ops, - .parent_data = &(const struct clk_parent_data) { - .fw_name = "xtal", - .index = -1, + .parent_hws = (const struct clk_hw *[]) { + &meson8b_hdmi_prediv.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -247,11 +290,6 @@ static struct clk_regmap meson8b_hdmi_pll_dco = { .shift = 0, .width = 9, }, - .n = { - .reg_off = HHI_VID_PLL_CNTL, - .shift = 10, - .width = 5, - }, .frac = { .reg_off = HHI_VID_PLL_CNTL2, .shift = 0, @@ -279,6 +317,7 @@ static struct clk_regmap meson8b_hdmi_pll_dco = { &hdmi_pll_dco_in.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -318,6 +357,26 @@ static struct clk_regmap meson8b_hdmi_pll_hdmi_out = { }, }; +static struct clk_regmap meson8b_sys_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_SYS_PLL_CNTL, + .shift = 9, + .width = 5, + .table = meson8b_pll_prediv_div_table, + .flags = CLK_DIVIDER_INVALID_ZERO, + }, + .hw.init = &(struct clk_init_data){ + .name = "sys_prediv", + .ops = &clk_regmap_divider_ops, + .parent_data = &(const struct clk_parent_data) { + .fw_name = "xtal", + .name = "xtal", + .index = -1, + }, + .num_parents = 1, + }, +}; + static struct clk_regmap meson8b_sys_pll_dco = { .data = &(struct meson_clk_pll_data){ .en = { @@ -330,11 +389,6 @@ static struct clk_regmap meson8b_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, @@ -350,12 +404,11 @@ static struct clk_regmap meson8b_sys_pll_dco = { .hw.init = &(struct clk_init_data){ .name = "sys_pll_dco", .ops = &meson_clk_pll_ops, - .parent_data = &(const struct clk_parent_data) { - .fw_name = "xtal", - .name = "xtal", - .index = -1, + .parent_hws = (const struct clk_hw *[]) { + &meson8b_sys_prediv.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -2035,6 +2088,32 @@ static struct clk_regmap meson8b_mali = { }, }; +/* The GP PLL needs pre-divider 3 to achieve the target frequency 364Mhz */ +static const struct clk_div_table meson8b_gp_prediv_div_table[] = { + { .val = 3, .div = 3 }, + { /* sentinel */ } +}; + +static struct clk_regmap meson8m2_gp_prediv = { + .data = &(struct clk_regmap_div_data){ + .offset = HHI_GP_PLL_CNTL, + .shift = 9, + .width = 5, + .table = meson8b_gp_prediv_div_table, + .flags = CLK_DIVIDER_INVALID_ZERO, + }, + .hw.init = &(struct clk_init_data){ + .name = "gp_prediv", + .ops = &clk_regmap_divider_ops, + .parent_data = &(const struct clk_parent_data) { + .fw_name = "xtal", + .name = "xtal", + .index = -1, + }, + .num_parents = 1, + }, +}; + static const struct reg_sequence meson8m2_gp_pll_init_regs[] = { { .reg = HHI_GP_PLL_CNTL2, .def = 0x59c88000 }, { .reg = HHI_GP_PLL_CNTL3, .def = 0xca463823 }, @@ -2059,11 +2138,6 @@ static struct clk_regmap meson8m2_gp_pll_dco = { .shift = 0, .width = 9, }, - .n = { - .reg_off = HHI_GP_PLL_CNTL, - .shift = 9, - .width = 5, - }, .l = { .reg_off = HHI_GP_PLL_CNTL, .shift = 31, @@ -2081,12 +2155,11 @@ static struct clk_regmap meson8m2_gp_pll_dco = { .hw.init = &(struct clk_init_data){ .name = "gp_pll_dco", .ops = &meson_clk_pll_ops, - .parent_data = &(const struct clk_parent_data) { - .fw_name = "xtal", - .name = "xtal", - .index = -1, + .parent_hws = (const struct clk_hw *[]) { + &meson8m2_gp_prediv.hw }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -2920,8 +2993,11 @@ static struct clk_hw *meson8_hw_clks[] = { [CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw, [CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw, [CLKID_NAND_CLK] = &meson8b_nand_clk.hw, + [CLKID_PLL_FIXED_PREDIV] = &meson8b_fixed_prediv.hw, [CLKID_PLL_FIXED_DCO] = &meson8b_fixed_pll_dco.hw, + [CLKID_HDMI_PREDIV] = &meson8b_hdmi_prediv.hw, [CLKID_HDMI_PLL_DCO] = &meson8b_hdmi_pll_dco.hw, + [CLKID_PLL_SYS_PREDIV] = &meson8b_sys_prediv.hw, [CLKID_PLL_SYS_DCO] = &meson8b_sys_pll_dco.hw, [CLKID_CPU_CLK_DIV2] = &meson8b_cpu_clk_div2.hw, [CLKID_CPU_CLK_DIV3] = &meson8b_cpu_clk_div3.hw, @@ -3124,8 +3200,11 @@ static struct clk_hw *meson8b_hw_clks[] = { [CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw, [CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw, [CLKID_NAND_CLK] = &meson8b_nand_clk.hw, + [CLKID_PLL_FIXED_PREDIV] = &meson8b_fixed_prediv.hw, [CLKID_PLL_FIXED_DCO] = &meson8b_fixed_pll_dco.hw, + [CLKID_HDMI_PREDIV] = &meson8b_hdmi_prediv.hw, [CLKID_HDMI_PLL_DCO] = &meson8b_hdmi_pll_dco.hw, + [CLKID_PLL_SYS_PREDIV] = &meson8b_sys_prediv.hw, [CLKID_PLL_SYS_DCO] = &meson8b_sys_pll_dco.hw, [CLKID_CPU_CLK_DIV2] = &meson8b_cpu_clk_div2.hw, [CLKID_CPU_CLK_DIV3] = &meson8b_cpu_clk_div3.hw, @@ -3339,8 +3418,11 @@ static struct clk_hw *meson8m2_hw_clks[] = { [CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw, [CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw, [CLKID_NAND_CLK] = &meson8b_nand_clk.hw, + [CLKID_PLL_FIXED_PREDIV] = &meson8b_fixed_prediv.hw, [CLKID_PLL_FIXED_DCO] = &meson8b_fixed_pll_dco.hw, + [CLKID_HDMI_PREDIV] = &meson8b_hdmi_prediv.hw, [CLKID_HDMI_PLL_DCO] = &meson8b_hdmi_pll_dco.hw, + [CLKID_PLL_SYS_PREDIV] = &meson8b_sys_prediv.hw, [CLKID_PLL_SYS_DCO] = &meson8b_sys_pll_dco.hw, [CLKID_CPU_CLK_DIV2] = &meson8b_cpu_clk_div2.hw, [CLKID_CPU_CLK_DIV3] = &meson8b_cpu_clk_div3.hw, @@ -3410,6 +3492,7 @@ static struct clk_hw *meson8m2_hw_clks[] = { [CLKID_MALI_1_DIV] = &meson8b_mali_1_div.hw, [CLKID_MALI_1] = &meson8b_mali_1.hw, [CLKID_MALI] = &meson8b_mali.hw, + [CLKID_GP_PREDIV] = &meson8m2_gp_prediv.hw, [CLKID_GP_PLL_DCO] = &meson8m2_gp_pll_dco.hw, [CLKID_GP_PLL] = &meson8m2_gp_pll.hw, [CLKID_VPU_0_SEL] = &meson8m2_vpu_0_sel.hw, -- 2.47.1