From mboxrd@z Thu Jan 1 00:00:00 1970 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 F13A7FD4F1A for ; Tue, 10 Mar 2026 18:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oDpUFVubUhLjiPJb1eA9mXwL9cKm4D7iCqVyZ/+IIRQ=; b=L9lRc4esJskcNw2fltoTq+rJm7 CYk6lJGq0jxuCcUtTRyUT1zOaQ8xRmz3wO2Onk30HevhKTnp4ktfLxcB8tvFrm3o06gmjSmi6b6ca scKxUR27aIp/qFaSJ2mtZVguNpbJ0Xx16DTNyyHmoAMMjteOYZ2tnA8/lagVPbO7FAos4NkVY5ebP A5MEjbSgMFMllAtONmgpBG49qHRl/Vebmrqjb5GuM7nEjH59DAmwuUi7NCV2WeuLxoVTES2gYUXzl Xs8E+ojBWx0gIt1+2qga2/2EwD/A+aXBpDLBmYUEm+P0ruKztzNg2We4nOeQTA+Wp9ktkuCo7JTIY kQreD/Ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w020o-0000000A6IL-241W; Tue, 10 Mar 2026 18:40:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w020k-0000000A6ET-2rC1 for linux-arm-kernel@lists.infradead.org; Tue, 10 Mar 2026 18:40:55 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BADEB14BF; Tue, 10 Mar 2026 11:40:47 -0700 (PDT) Received: from pluto.guest.local (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 283403F7BD; Tue, 10 Mar 2026 11:40:50 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org, linux-clk@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: sudeep.holla@arm.com, philip.radford@arm.com, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, etienne.carriere@foss.st.com, peng.fan@oss.nxp.com, michal.simek@amd.com, dan.carpenter@linaro.org, geert+renesas@glider.be, kuninori.morimoto.gx@renesas.com, marek.vasut+renesas@gmail.com, Cristian Marussi , Brian Masney , Michael Turquette , Stephen Boyd Subject: [PATCH v2 03/13] clk: scmi: Use new determine_rate clock operation Date: Tue, 10 Mar 2026 18:40:20 +0000 Message-ID: <20260310184030.3669330-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260310184030.3669330-1-cristian.marussi@arm.com> References: <20260310184030.3669330-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260310_114054_795881_012AE06D X-CRM114-Status: GOOD ( 16.23 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the Clock protocol layer determine_rate logic to calculate the closest rate that can be supported by a specific clock. No functional change. Cc: Brian Masney Cc: Michael Turquette Cc: Stephen Boyd Cc: linux-clk@vger.kernel.org Signed-off-by: Cristian Marussi --- @brian: I'd modify further this clk-scmi driver, with a patch on top of this series, to properly use your new CLK_ROUNDING_NOOP flag once your series AND another (already reviewed) series on clk-scmi from Peng are in. --- drivers/clk/clk-scmi.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index b6a12f3bc123..c223e4ef1dd1 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -57,35 +56,17 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw, static int scmi_clk_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { - u64 fmin, fmax, ftmp; + int ret; struct scmi_clk *clk = to_scmi_clk(hw); /* - * We can't figure out what rate it will be, so just return the - * rate back to the caller. scmi_clk_recalc_rate() will be called - * after the rate is set and we'll know what rate the clock is + * If we could not get a better rate scmi_clk_recalc_rate() will be + * called after the rate is set and we'll know what rate the clock is * running at then. */ - if (clk->info->rate_discrete) - return 0; - - fmin = clk->info->range.min_rate; - fmax = clk->info->range.max_rate; - if (req->rate <= fmin) { - req->rate = fmin; - - return 0; - } else if (req->rate >= fmax) { - req->rate = fmax; - - return 0; - } - - ftmp = req->rate - fmin; - ftmp += clk->info->range.step_size - 1; /* to round up */ - ftmp = div64_ul(ftmp, clk->info->range.step_size); - - req->rate = ftmp * clk->info->range.step_size + fmin; + ret = scmi_proto_clk_ops->determine_rate(clk->ph, clk->id, &req->rate); + if (ret) + return ret; return 0; } -- 2.53.0