From patchwork Fri Jan 10 11:47:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuan Liu via B4 Relay X-Patchwork-Id: 13934356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4945AE77188 for ; Fri, 10 Jan 2025 11:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version: Subject:Date:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YJDQbifl3S3nXYi/s4G7WO8DDH38sOs3MfxUL+uTTjY=; b=wtRUcnX/lr++oB03iOW36B/J1b MK9NwctE6NOJjQGZgPFT5+OOHyn+PRr073IOt0BAzXpnfE2NGyASqY/O0IeKUCRXdyICnCAQVoodp eAJSMauWiPqm3DlrZWeH3y/dgK5dX7xcro9dY1g+nzsnW6t6fDjGEG7QZaxj7F8emYVGQw9WTWJ+b D/ilGDw4hk9Z6gEo08fPHzitRhq+95Z26KRzWqNrYUcAlTJ6Wj8wc/Q5/uSnqIx7JPITx+eaWfAE+ yxzbZF83RvgLI1Mia4YJmKwvcOHskbi3BCbj7dtFaG66IpIlp8hlqc7072uaq64lRW23GS6PoAbx2 WYqlhTvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tWDY5-0000000FAhl-1wMu; Fri, 10 Jan 2025 11:51:33 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tWDUU-0000000FA1f-1sCS; Fri, 10 Jan 2025 11:47:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id C44EEA419FB; Fri, 10 Jan 2025 11:46:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id E0FA1C4CEE0; Fri, 10 Jan 2025 11:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736509668; bh=2LuqfPJMjVZ/DDPyRk3omDydC7N76YqAGAm21Z7ZFXk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=i4Vye6nlN8OTpRoVDWqva4QwMK0gSKfbmkEu+tBlYAW2PNLgxS6E+lKjOCahPs7JU vVjDFpFTHUt9IUYjYveEE94LQrjRwbRSmw0T1e7Gc/S2NmFUiAcCdrh6GQNOR1YIFl Jcp9AXqs6t9rDKDC1+Kr+Y8IpqHd/6smiU/YQamWq37nX2aMBmvMv9DzrhKGZjgljK LCtMTQ54Q5+9BwQBhdx1Ld2P1c9R13dMp9wk0rZRpNShhV/H8cX0iiRtf00sxpmLDC SroI3TQODdVyTGUO9SZwAoX1s+8EWGwJ47gPQLTAkYLa1+MAJ+1FdroiJN9RHucD/k 52LIPFxKH/Piw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFB43E7719D; Fri, 10 Jan 2025 11:47:48 +0000 (UTC) From: Chuan Liu via B4 Relay Date: Fri, 10 Jan 2025 19:47:10 +0800 Subject: [PATCH 1/2] clk: Add initialize the rate boundaries of the clk provider MIME-Version: 1.0 Message-Id: <20250110-limit-rate-range-of-clk-v1-1-dd618adc4aa8@amlogic.com> References: <20250110-limit-rate-range-of-clk-v1-0-dd618adc4aa8@amlogic.com> In-Reply-To: <20250110-limit-rate-range-of-clk-v1-0-dd618adc4aa8@amlogic.com> To: Michael Turquette , Stephen Boyd , Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Chuan Liu X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736509666; l=1896; i=chuan.liu@amlogic.com; s=20240902; h=from:subject:message-id; bh=NLbcI+Nns/2o6n4G9nqU4NOW+TQbJwF6LoFvcGM+2I4=; b=/HIhXIBeMDoFfKkG+m2ONfOOFLZiafM1eyQll49aSyxL2rXP4aEC5eWqUqKBgLD+IC9SM+MwL MB/kqgbTb4DCcVAFh9ZPihXtnYXLBLiD4tVb9iZtoh0zjY6mcTxVxc9 X-Developer-Key: i=chuan.liu@amlogic.com; a=ed25519; pk=fnKDB+81SoWGKW2GJNFkKy/ULvsDmJZRGBE7pR5Xcpo= X-Endpoint-Received: by B4 Relay for chuan.liu@amlogic.com/20240902 with auth_id=203 X-Original-From: Chuan Liu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250110_034750_650298_10952C4F X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: chuan.liu@amlogic.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Chuan Liu The rate boundaries output by different clk providers vary due to hardware limitations. When registering the clk, limit the rate boundaries of the clk provider to prevent setting the rate of the clk provider beyond the design specifications and causing abnormal conditions. Signed-off-by: Chuan Liu --- drivers/clk/clk.c | 4 ++-- include/linux/clk-provider.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 9b45fa005030..36e4b4f16f1d 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4359,8 +4359,8 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw) core->hw = hw; core->flags = init->flags; core->num_parents = init->num_parents; - core->min_rate = 0; - core->max_rate = ULONG_MAX; + core->min_rate = init->min_rate ? init->min_rate : 0; + core->max_rate = init->max_rate ? init->max_rate : ULONG_MAX; ret = clk_core_populate_parent_map(core, init); if (ret) diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 2e6e603b7493..46cfc342819e 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -294,6 +294,8 @@ struct clk_parent_data { * @parent_hws: array of pointers to all possible parents (when all parents * are internal to the clk controller) * @num_parents: number of possible parents + * @min_rate: min rate provided by the clk provider + * @max_rate: max rate provided by the clk provider * @flags: framework-level hints and quirks */ struct clk_init_data { @@ -304,6 +306,8 @@ struct clk_init_data { const struct clk_parent_data *parent_data; const struct clk_hw **parent_hws; u8 num_parents; + unsigned long min_rate; + unsigned long max_rate; unsigned long flags; }; From patchwork Fri Jan 10 11:47:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuan Liu via B4 Relay X-Patchwork-Id: 13934355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2F7CE77188 for ; Fri, 10 Jan 2025 11:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version: Subject:Date:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SLRRk5zmDSV+fM1RFKO6OQEV4aHVddumQnCjWnaVyp8=; b=BbwtAlJLGS6Ybv1qJZJJIK2/7s MRwIer5DyS35P1uULRFzn7nuU6Jl+7fjawHq3vZVew8yHZMXsSnkVh+0JKLdJa0gpPoFQygAwhxgX UPIReTJu1dUrcgefA17LtQcfO/5nUVJUTzxL4Jpe3DlUB27j+0T2eljeUyh1b6crp/9xzxO3Vo6Ax zi3CmrULU45MapVtZycLqmi8MYSiaNrrsK2kZzxyZtziD8mvSl0euLYAWTtqdYC0TYOiFwxq7WNQs PwLOOvIm4/weeTmgOYkv6xwBxZa34LyYA7mh/4jz+31Mo4CNcGWCF8bnJqT5wuugBWRG9O0quHwkl vaWsu7vQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tWDWt-0000000FAVP-1tMy; Fri, 10 Jan 2025 11:50:19 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tWDUU-0000000FA1i-1H91; Fri, 10 Jan 2025 11:47:51 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id D5520A41DDC; Fri, 10 Jan 2025 11:46:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id F2423C4CEDF; Fri, 10 Jan 2025 11:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736509669; bh=+bBN7X5DoKL/XSHDmvrzqb3BA5dGzZ/fj7/IKqsTMjY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=iqF/c125JideKK2SjA3m8LpVhBYNBpUbZcmLoqSzRhNp3OKPBTuHX44dbcraWNB33 3mT8/wj+Dwr7F14pWce9F2MkpnMbTeTTFa+pxjdYTdlrVOWsmSFDwx0FnNE/p+7t/H HBh4nNyVh43v9/NOsus5TEtBJ96NRsvZia4Vgb1c9W1QTg02xq5Vevg2Pv2Y8FY5ex G9gNHGmhbicV/bUXvQ/bnbQSNsF64rAL0fBW/Wa1RSx+c7fXsP9aCUWgVBVqOYpfLS VmNy6l0Q2hr8FugV3R7z6o5I+W2/4EAzRuaKO1xCg/NYZH1sMkb2C6bqdFsEHEbCSV vB75dyDy4WHKg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E442AE7719E; Fri, 10 Jan 2025 11:47:48 +0000 (UTC) From: Chuan Liu via B4 Relay Date: Fri, 10 Jan 2025 19:47:11 +0800 Subject: [PATCH 2/2] clk: amlogic: c3: Limit the rate boundaries of clk_hw MIME-Version: 1.0 Message-Id: <20250110-limit-rate-range-of-clk-v1-2-dd618adc4aa8@amlogic.com> References: <20250110-limit-rate-range-of-clk-v1-0-dd618adc4aa8@amlogic.com> In-Reply-To: <20250110-limit-rate-range-of-clk-v1-0-dd618adc4aa8@amlogic.com> To: Michael Turquette , Stephen Boyd , Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Chuan Liu X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736509666; l=5184; i=chuan.liu@amlogic.com; s=20240902; h=from:subject:message-id; bh=8XGEQBOCJSgFZ2f2fpSkVtYBK8fi63dUXKYPxwN2M48=; b=1XANFRx0lswzvvpEbiIPFHJx220g4DleCItzkvN2v4pK958nuDuGFr6S5LbRx/TDf3QBtEYA9 dPCCRpv3EIxAvHymsuRLB4hc03O5pFj7q2xOLSPKf653xN1WxT4rHgr X-Developer-Key: i=chuan.liu@amlogic.com; a=ed25519; pk=fnKDB+81SoWGKW2GJNFkKy/ULvsDmJZRGBE7pR5Xcpo= X-Endpoint-Received: by B4 Relay for chuan.liu@amlogic.com/20240902 with auth_id=203 X-Original-From: Chuan Liu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250110_034750_507934_0CE9ADAE X-CRM114-Status: UNSURE ( 9.42 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: chuan.liu@amlogic.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Chuan Liu The PLL can only stably lock within a limited frequency range. Due to timing constraints, the maximum frequency of the peripheral clock cannot exceed the design specifications. Signed-off-by: Chuan Liu --- drivers/clk/meson/c3-peripherals.c | 21 +++++++++++++++++++++ drivers/clk/meson/c3-pll.c | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/drivers/clk/meson/c3-peripherals.c b/drivers/clk/meson/c3-peripherals.c index 7dcbf4ebee07..9f0a3990f0d6 100644 --- a/drivers/clk/meson/c3-peripherals.c +++ b/drivers/clk/meson/c3-peripherals.c @@ -568,6 +568,7 @@ static const struct clk_parent_data pwm_parent_data[] = { .ops = &clk_regmap_gate_ops, \ .parent_names = (const char *[]) { #_name "_div" },\ .num_parents = 1, \ + .max_rate = 200000000, \ .flags = CLK_SET_RATE_PARENT, \ }, \ } @@ -724,6 +725,7 @@ static struct clk_regmap spicc_a = { &spicc_a_div.hw }, .num_parents = 1, + .max_rate = 500000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -771,6 +773,7 @@ static struct clk_regmap spicc_b = { &spicc_b_div.hw }, .num_parents = 1, + .max_rate = 500000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -829,6 +832,7 @@ static struct clk_regmap spifc = { &spifc_div.hw }, .num_parents = 1, + .max_rate = 167000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -887,6 +891,7 @@ static struct clk_regmap sd_emmc_a = { &sd_emmc_a_div.hw }, .num_parents = 1, + .max_rate = 250000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -934,6 +939,7 @@ static struct clk_regmap sd_emmc_b = { &sd_emmc_b_div.hw }, .num_parents = 1, + .max_rate = 250000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -981,6 +987,7 @@ static struct clk_regmap sd_emmc_c = { &sd_emmc_c_div.hw }, .num_parents = 1, + .max_rate = 1200000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1074,6 +1081,7 @@ static struct clk_regmap eth_rmii = { ð_rmii_div.hw }, .num_parents = 1, + .max_rate = 50000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1132,6 +1140,7 @@ static struct clk_regmap mipi_dsi_meas = { &mipi_dsi_meas_div.hw }, .num_parents = 1, + .max_rate = 200000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1190,6 +1199,7 @@ static struct clk_regmap dsi_phy = { &dsi_phy_div.hw }, .num_parents = 1, + .max_rate = 1500000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1248,6 +1258,7 @@ static struct clk_regmap vout_mclk = { &vout_mclk_div.hw }, .num_parents = 1, + .max_rate = 334000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1306,6 +1317,7 @@ static struct clk_regmap vout_enc = { &vout_enc_div.hw }, .num_parents = 1, + .max_rate = 200000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1431,6 +1443,7 @@ static struct clk_regmap hcodec = { .ops = &clk_regmap_mux_ops, .parent_data = hcodec_parent_data, .num_parents = ARRAY_SIZE(hcodec_parent_data), + .max_rate = 667000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1489,6 +1502,7 @@ static struct clk_regmap vc9000e_aclk = { &vc9000e_aclk_div.hw }, .num_parents = 1, + .max_rate = 667000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1536,6 +1550,7 @@ static struct clk_regmap vc9000e_core = { &vc9000e_core_div.hw }, .num_parents = 1, + .max_rate = 400000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1594,6 +1609,7 @@ static struct clk_regmap csi_phy0 = { &csi_phy0_div.hw }, .num_parents = 1, + .max_rate = 200000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1652,6 +1668,7 @@ static struct clk_regmap dewarpa = { &dewarpa_div.hw }, .num_parents = 1, + .max_rate = 800000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1710,6 +1727,7 @@ static struct clk_regmap isp0 = { &isp0_div.hw }, .num_parents = 1, + .max_rate = 400000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1768,6 +1786,7 @@ static struct clk_regmap nna_core = { &nna_core_div.hw }, .num_parents = 1, + .max_rate = 800000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1826,6 +1845,7 @@ static struct clk_regmap ge2d = { &ge2d_div.hw }, .num_parents = 1, + .max_rate = 667000000, .flags = CLK_SET_RATE_PARENT, }, }; @@ -1884,6 +1904,7 @@ static struct clk_regmap vapb = { &vapb_div.hw }, .num_parents = 1, + .max_rate = 400000000, .flags = CLK_SET_RATE_PARENT, }, }; diff --git a/drivers/clk/meson/c3-pll.c b/drivers/clk/meson/c3-pll.c index 35fda31a19e2..d80d6ee2409d 100644 --- a/drivers/clk/meson/c3-pll.c +++ b/drivers/clk/meson/c3-pll.c @@ -286,6 +286,8 @@ static struct clk_regmap gp0_pll_dco = { .fw_name = "top", }, .num_parents = 1, + .min_rate = 3000000000, + .max_rate = 6000000000, }, }; @@ -370,6 +372,8 @@ static struct clk_regmap hifi_pll_dco = { .fw_name = "top", }, .num_parents = 1, + .min_rate = 3000000000, + .max_rate = 6000000000, }, };