From patchwork Mon May 24 10:37:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12277289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0817C2B9F7 for ; Mon, 24 May 2021 23:45:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B3CDA61420 for ; Mon, 24 May 2021 23:45:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3CDA61420 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q8HzZRST7IcSlBbeeu5W6rN8AlQhqGLIT+KTloAJtY0=; b=lQYqLLqJiF695B dO8OwY3bVzEhgx0IwCJjfSeliLiO5hhPVJDY3/CvJ7oBHginoAJ//k87Pgb4reOzgH2jlVx4UszbQ hp1MkeK4wsoaV/Kbn1o3GMxFRWK4ZJsdB9CmWXQpx6VzYidDcc5UDsd3T9/DkHW/L6+Qe8NSf8nAs 399Rh2JiIXx9S3RQOJyOXddWvY1sWNqmFTZpQ1ezDcD1EQSFhEIElc6Cc5ExkX4scImKVPWGnMHqe Hlti1Ngn5adKEVArVrESzi7ow1wxjtb6hyqLcE4A/shEHeY5eFXEJSjV5tjglmjxVh2qMhXvoTSK1 OHebYjhDRq9F3z+0qM3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1llKGS-002OnR-TF; Mon, 24 May 2021 23:45:40 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ll7y1-000pue-JL; Mon, 24 May 2021 10:37:51 +0000 Received: by mail-ej1-x62a.google.com with SMTP id z12so39567131ejw.0; Mon, 24 May 2021 03:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7DuEzwceNsnqYkEeiiZKaUdLTGoHWRI6KUHxHFfU1j4=; b=XasM8I+jWP45hASRQz2pDtCH3J/lY7Vm9kZLI+IH/vZEVthGGV4ROUbUeGU/qIqvVp tQdMMqtih8wQ0DYSJCMRCUO5g6Ijf+UZ4dkuZ++sRGlARBzMuJSSAyGvho6twoA3822C 5gr5iumVWLsBjXgmmmQlppiFHgJFTQPpzdaQRA2Dbyd68/2B0Sv4HxV+DTliZouBpf15 5C20k6fwKt2Bus2t0kdeOhktpkZwM+tnLrKHAJI8fCjg7cU2VKmRZAAlOzaEs+9zbFeQ M72Tu9DFhaNuDokzzr6XwgEwXbiI/9yg3yEhhcjLsg4SU953eiB17wRTlAEGBKVmRAUG iRdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7DuEzwceNsnqYkEeiiZKaUdLTGoHWRI6KUHxHFfU1j4=; b=r3riALCIufd5R1T2GzkNeNRVgkCu52azE0C8c26446uysxkaNDzmXh21ADUqv53NIo GH13LqCdchmpHIinVfFrzXuAud3gpqHOvYVV9aK4P4YJM7K3ECJfWcZ5BRWi6u69PSO2 nMs2tWJX1DYRApZG8TKwAPf8Ww0qsfpVASnkHqxw3HCoBhmb4tYZ/nvDm6MdyeUpkPJL D5FfpNYtQtlaF+i7bpzPUtrECtdmf4Du4KN4qDEddF5bztniJSNTOpJO4oReAxL+Hq6A 2DL4KNCBCAOIfLGKB7QJ3i+4AFqwRYpt4VG8KvKV9kgm2VWnE+g2QeNF7gy+0GxxQ0Z3 TMVg== X-Gm-Message-State: AOAM530HwVXIKAXiKjj4c7EqCR+l9/pGlU85/IHC+gW8Xp5IfRRpsVd/ Ju+F1uqEfFcEgh9PBd547RQ= X-Google-Smtp-Source: ABdhPJwQ/2GEiSXKNvjACryhQkePleZPR6KX44B2C0K/pqg7dYhxGhpBo6XdnjV531KBhtbX0t4kCQ== X-Received: by 2002:a17:907:2136:: with SMTP id qo22mr22269933ejb.246.1621852668092; Mon, 24 May 2021 03:37:48 -0700 (PDT) Received: from localhost.localdomain (p200300f1370a3a00f22f74fffe210725.dip0.t-ipconnect.de. [2003:f1:370a:3a00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id r15sm2616418edm.61.2021.05.24.03.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 03:37:47 -0700 (PDT) From: Martin Blumenstingl To: mturquette@baylibre.com, sboyd@kernel.org, narmstrong@baylibre.com, jbrunet@baylibre.com, linux-clk@vger.kernel.org Cc: khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl Subject: [PATCH v2 1/3] clk: divider: Add re-usable determine_rate implementations Date: Mon, 24 May 2021 12:37:31 +0200 Message-Id: <20210524103733.554878-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524103733.554878-1-martin.blumenstingl@googlemail.com> References: <20210524103733.554878-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210524_033749_658435_3A154B30 X-CRM114-Status: GOOD ( 16.33 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org These are useful when running on 32-bit systems to increase the upper supported frequency limit. clk_ops.round_rate returns a signed long which limits the maximum rate on 32-bit systems to 2^31 (or approx. 2.14GHz). clk_ops.determine_rate internally uses an unsigned long so the maximum rate on 32-bit systems is 2^32 or approx. 4.29GHz. To avoid code-duplication switch over divider_{ro_,}round_rate_parent to use the new divider_{ro_,}determine_rate functions. Signed-off-by: Martin Blumenstingl --- drivers/clk/clk-divider.c | 75 +++++++++++++++++++++++++++++------- include/linux/clk-provider.h | 6 +++ 2 files changed, 67 insertions(+), 14 deletions(-) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 344997203f0e..87ba4966b0e8 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -343,16 +343,63 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent, return bestdiv; } +int divider_determine_rate(struct clk_hw *hw, struct clk_rate_request *req, + const struct clk_div_table *table, u8 width, + unsigned long flags) +{ + int div; + + div = clk_divider_bestdiv(hw, req->best_parent_hw, req->rate, + &req->best_parent_rate, table, width, flags); + + req->rate = DIV_ROUND_UP_ULL((u64)req->best_parent_rate, div); + + return 0; +} +EXPORT_SYMBOL_GPL(divider_determine_rate); + +int divider_ro_determine_rate(struct clk_hw *hw, struct clk_rate_request *req, + const struct clk_div_table *table, u8 width, + unsigned long flags, unsigned int val) +{ + int div; + + div = _get_div(table, val, flags, width); + + /* Even a read-only clock can propagate a rate change */ + if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { + if (!req->best_parent_hw) + return -EINVAL; + + req->best_parent_rate = clk_hw_round_rate(req->best_parent_hw, + req->rate * div); + } + + req->rate = DIV_ROUND_UP_ULL((u64)req->best_parent_rate, div); + + return 0; +} +EXPORT_SYMBOL_GPL(divider_ro_determine_rate); + long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, unsigned long rate, unsigned long *prate, const struct clk_div_table *table, u8 width, unsigned long flags) { - int div; + struct clk_rate_request req = { + .rate = rate, + .best_parent_rate = *prate, + .best_parent_hw = parent, + }; + int ret; - div = clk_divider_bestdiv(hw, parent, rate, prate, table, width, flags); + ret = divider_determine_rate(hw, &req, table, width, flags); + if (ret) + return ret; - return DIV_ROUND_UP_ULL((u64)*prate, div); + *prate = req.best_parent_rate; + + return req.rate; } EXPORT_SYMBOL_GPL(divider_round_rate_parent); @@ -361,23 +408,23 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, const struct clk_div_table *table, u8 width, unsigned long flags, unsigned int val) { - int div; - - div = _get_div(table, val, flags, width); + struct clk_rate_request req = { + .rate = rate, + .best_parent_rate = *prate, + .best_parent_hw = parent, + }; + int ret; - /* Even a read-only clock can propagate a rate change */ - if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { - if (!parent) - return -EINVAL; + ret = divider_ro_determine_rate(hw, &req, table, width, flags, val); + if (ret) + return ret; - *prate = clk_hw_round_rate(parent, rate * div); - } + *prate = req.best_parent_rate; - return DIV_ROUND_UP_ULL((u64)*prate, div); + return req.rate; } EXPORT_SYMBOL_GPL(divider_ro_round_rate_parent); - static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 162a2e5546a3..d83b829305c0 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -629,6 +629,12 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, unsigned long rate, unsigned long *prate, const struct clk_div_table *table, u8 width, unsigned long flags, unsigned int val); +int divider_determine_rate(struct clk_hw *hw, struct clk_rate_request *req, + const struct clk_div_table *table, u8 width, + unsigned long flags); +int divider_ro_determine_rate(struct clk_hw *hw, struct clk_rate_request *req, + const struct clk_div_table *table, u8 width, + unsigned long flags, unsigned int val); int divider_get_val(unsigned long rate, unsigned long parent_rate, const struct clk_div_table *table, u8 width, unsigned long flags); From patchwork Mon May 24 10:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12277029 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 355EDC04FF3 for ; Mon, 24 May 2021 21:54:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D905561413 for ; Mon, 24 May 2021 21:54:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D905561413 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AhU/p7QGe+3ByS/1Sf7rty/7uaIKQUV4lp4um2CVQrc=; b=q2m4TTrI7qNAFX CvjkcRHZJRTfGQhHKRJdm4KfEgl7X+soMFjQz72T2Fdbr/Gk9X9jbtbnDwOxgz7h6V/3oZ6h4rR7v nfWeRQiwuD8rby1qv9QyzrmxBSpi2Nga7k2ZFz3s/2TDwhs1urP6tNiSxdrX19alEtNvwXwss0uR4 pXWjEO2mflIYN83qq/gG8tS2ydL8NoslbSNnJPdFZzxLj2WjQQnAc5ZZ8BrFXfkWUp1ZFngdM545A eDJywWgMLDGP0RgVydhAbs1phUEXEZ471Mxs0QD7oKGmkli/Qq1c6PkT+Vv3YcDrdraOYTDZzbFHr 7jldQJ9VH2PlZcI6SJOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1llIWa-0020mz-VA; Mon, 24 May 2021 21:54:13 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ll7y2-000puv-9t; Mon, 24 May 2021 10:37:51 +0000 Received: by mail-ed1-x529.google.com with SMTP id a25so31325656edr.12; Mon, 24 May 2021 03:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=br2LAkdVkinf4lfGstyxEISEcfDBPafEL/ugOBpOFVs=; b=jBG36Q7wVbObvnVdapVzc2TMCF8/w76fE0SYz7u7B6tf90Wm9+dknqvhzTcg438hqe pEfe3AYnEqFqkDKgH3+bFnLVJHRcJe3/CeFL+vq5rAx0jgY8W9iIFdqNbQgM+j+1U/zC i6MJTN2kuvIOLos3h70NLtEQXg3SkcIw/G+UrFp9gMcUhaLCiJaa91mmp4sSCP803kSz 7nIu3z79jlPd6MUe5aTQoSMHHuDkgw2baFY/C6WuO2q8zDk5f/bn0cwSHdHH9+TXXD1Z E/if+uwcI+knAjSClWqUZiCXjS5+MlDMi3ke3z/MNBxIUkjAzX/l3wl1qAqGmhPFHERp 5dug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=br2LAkdVkinf4lfGstyxEISEcfDBPafEL/ugOBpOFVs=; b=P/A2Gg1td9o9e7A7320B7hh+26wdFLFWM2qvtwqZMj8eqjEL+9ea/Mz7GoJiTcLxER zJxI6FypjOBbO6U7UQ0fHUKKr+6iMlcQWGW9yDFUM0aV3eeYXTKlwJQW7iln9CzcrfaX TEerZyydBPcv5+HhKWrkA22pzyJyG/zxrdk3y+UOLQ9eHHinZP4RzeJRSDgJlmyWf048 NgLdXZnJCT+cyd0ANgfSXhB0BQSnAX6GJaxDBVWRDgHsqSvXAu2ckCebooC4v18kTMDb 3dcIriYlmWKf68YqC8nNIkoehVKcg20ko4CeOcf98k4ewiyGonqz+mvB4R/dBqoThisB k2MA== X-Gm-Message-State: AOAM530W4QbUBdpEkHx0nNZZrPdWUX8HmLq1hKIArmXpWQazeSKCKwdy nRrpdjVoFwdvpk4FxE1686g= X-Google-Smtp-Source: ABdhPJwJC01A6NC8Z1rC637INdrccXaNZyehezoGsf+7Q+DiLbQiYHmT9xwZwNar4OnjaZlO3+UK+A== X-Received: by 2002:aa7:d413:: with SMTP id z19mr25021347edq.37.1621852668811; Mon, 24 May 2021 03:37:48 -0700 (PDT) Received: from localhost.localdomain (p200300f1370a3a00f22f74fffe210725.dip0.t-ipconnect.de. [2003:f1:370a:3a00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id r15sm2616418edm.61.2021.05.24.03.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 03:37:48 -0700 (PDT) From: Martin Blumenstingl To: mturquette@baylibre.com, sboyd@kernel.org, narmstrong@baylibre.com, jbrunet@baylibre.com, linux-clk@vger.kernel.org Cc: khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl Subject: [PATCH v2 2/3] clk: divider: Switch from .round_rate to .determine_rate by default Date: Mon, 24 May 2021 12:37:32 +0200 Message-Id: <20210524103733.554878-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524103733.554878-1-martin.blumenstingl@googlemail.com> References: <20210524103733.554878-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210524_033750_362389_08794E6E X-CRM114-Status: GOOD ( 13.57 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org .determine_rate is meant to replace .round_rate. The former comes with a benefit which is especially relevant on 32-bit systems: since .determine_rate uses an "unsigned long" (compared to a "signed long" which is used by .round_rate) the maximum value on 32-bit systems increases from 2^31 (or approx. 2.14GHz) to 2^32 (or approx. 4.29GHz). Switch to a .determine_rate implementation by default so 32-bit systems can benefit from the increased maximum value as well as so we have one fewer user of .round_rate. Signed-off-by: Martin Blumenstingl --- drivers/clk/clk-divider.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 87ba4966b0e8..9e05e81116af 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -425,8 +425,8 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, } EXPORT_SYMBOL_GPL(divider_ro_round_rate_parent); -static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate) +static int clk_divider_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct clk_divider *divider = to_clk_divider(hw); @@ -437,13 +437,13 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, val = clk_div_readl(divider) >> divider->shift; val &= clk_div_mask(divider->width); - return divider_ro_round_rate(hw, rate, prate, divider->table, - divider->width, divider->flags, - val); + return divider_ro_determine_rate(hw, req, divider->table, + divider->width, + divider->flags, val); } - return divider_round_rate(hw, rate, prate, divider->table, - divider->width, divider->flags); + return divider_determine_rate(hw, req, divider->table, divider->width, + divider->flags); } int divider_get_val(unsigned long rate, unsigned long parent_rate, @@ -500,14 +500,14 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, const struct clk_ops clk_divider_ops = { .recalc_rate = clk_divider_recalc_rate, - .round_rate = clk_divider_round_rate, + .determine_rate = clk_divider_determine_rate, .set_rate = clk_divider_set_rate, }; EXPORT_SYMBOL_GPL(clk_divider_ops); const struct clk_ops clk_divider_ro_ops = { .recalc_rate = clk_divider_recalc_rate, - .round_rate = clk_divider_round_rate, + .determine_rate = clk_divider_determine_rate, }; EXPORT_SYMBOL_GPL(clk_divider_ro_ops); From patchwork Mon May 24 10:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12277031 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 997ACC04FF3 for ; Mon, 24 May 2021 21:56:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4A42E600CD for ; Mon, 24 May 2021 21:56:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A42E600CD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gPe2VLP4rmyuID4jhLRGoEM65WfRbH+pNqsZOcc8bQ4=; b=HzD0KL8pAdWlj/ EmB9ArMn8Z4oA3oaJrbaW8iAXSPGqmsxTDHGGE8W8lumrNyB8TdAaAgbtnMQF7mbRHyu7UBJ/lWap pD52IO6cnlDp7RSJ7MZcARmI44YaZPM63yu2PPGdEPR/xLUNMM2JNgAHc5AjA9DtH9P5VpobEBE77 cZSmJrwjeqJj0hYY0guhXoOjxaQVqFH5+ghVN+2TnKst7cRdi7/w7Wu9nI5/8VurPAbMHW/q3yTVx CZaNEaTXkAEp1OWD7xlbXG7/ts7KvqdXDK7ZMnKV9gVAUH7k5lD5aqsgLY0ryWAslgwueZ2sBQ/Rc NSFDxJno+Ab3zN0juAqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1llIYI-00218s-OY; Mon, 24 May 2021 21:55:58 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ll7y2-000pv9-Jz; Mon, 24 May 2021 10:37:52 +0000 Received: by mail-ej1-x62e.google.com with SMTP id s22so40804634ejv.12; Mon, 24 May 2021 03:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D9PoKK0/f5+W8bgWFgVSBXS4bTp3NbAEIo6GlJr5v8A=; b=XUPX+sm0RNbOl3akoKmJdcug6VvbFVss7IrvGZFOHF5FdfguqhCkHq65S57Ilk5f/3 p1ua+E5zOQJNBiRMiDO4wEoSWhudhNUp6/urdIjRJ0NPeMruTG16PCnnzvPg7YKphCDK vJOtSZ4qClvDCcAOIYO/ELwFVrOuf5PY8qRqB70zHxMgrkJ2RfvIiNR9Mh4ISz7xCDij q2rtBm7rl6vNUlTiN5sBRevkobxNR6APjypX8tKGkS4dOTT1U8ll3tR2YXRhyD38X3T+ 8xP5YJdM1DoyqaIAawr1D5GwvpTLbOxHLiir78pNcbOucV7CcWdyJvb5teip623/IF6D hCyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D9PoKK0/f5+W8bgWFgVSBXS4bTp3NbAEIo6GlJr5v8A=; b=q0hJsjXvGD0vNXGtGosYHh5cGof8iZ59AZAdu/hvHZRxiVjlGwfhJ4qLvdRtEqEg7Y hBL0ikd9bAo9gggjobXbhG0YIGGGvpmpPKOKP7YikUtGA9VzlnqIUfLAdrAmjLzLzAkc X0hESboKkd5Rpz0NIMOa/4nWgXbEfvEuyrE26Xn+ilvFFAehO9+5HuzTuTdb1ZjyqV+S vvsCbhnlK85U5mEKr9Tp+z5xYaW3tyJ82RfuZKFsh5Q2EzmyeSlXqxXOBZzX356wxjRB wEV980XEaRWlYDEPlGLepjbfl/59JFODFxFPO+SQsV2RcXmlv1SNsP0BRqvjZXXxFDq7 lm2w== X-Gm-Message-State: AOAM533ZnZPtCMW8JgLUJZR7ds7xHgx043Fde76nICrdzfSorRWfNLjM k57JQC+RSzkABaJlOGrXEd4= X-Google-Smtp-Source: ABdhPJxji7Msow1IjPo9+v0JxjQuF/MZH2cI9E+oqnbxbvprgU3c/OuibsfJWHOyfd84x1jHbdz2jw== X-Received: by 2002:a17:906:fc1e:: with SMTP id ov30mr22364766ejb.526.1621852669408; Mon, 24 May 2021 03:37:49 -0700 (PDT) Received: from localhost.localdomain (p200300f1370a3a00f22f74fffe210725.dip0.t-ipconnect.de. [2003:f1:370a:3a00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id r15sm2616418edm.61.2021.05.24.03.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 03:37:49 -0700 (PDT) From: Martin Blumenstingl To: mturquette@baylibre.com, sboyd@kernel.org, narmstrong@baylibre.com, jbrunet@baylibre.com, linux-clk@vger.kernel.org Cc: khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl Subject: [PATCH v2 3/3] clk: meson: regmap: switch to determine_rate for the dividers Date: Mon, 24 May 2021 12:37:33 +0200 Message-Id: <20210524103733.554878-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524103733.554878-1-martin.blumenstingl@googlemail.com> References: <20210524103733.554878-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210524_033750_691756_4DEEF946 X-CRM114-Status: GOOD ( 13.81 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org This increases the maxmium supported frequency on 32-bit systems from 2^31 (signed long as used by clk_ops.round_rate, maximum value: approx. 2.14GHz) to 2^32 (unsigned long as used by clk_ops.determine_rate, maximum value: approx. 4.29GHz). On Meson8/8b/8m2 the HDMI PLL and it's OD (post-dividers) are capable of running at up to 2.97GHz. So switch the divider implementation in clk-regmap to clk_ops.determine_rate to support these higher frequencies on 32-bit systems. Reviewed-by: Jerome Brunet Signed-off-by: Martin Blumenstingl --- drivers/clk/meson/clk-regmap.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/clk/meson/clk-regmap.c b/drivers/clk/meson/clk-regmap.c index dcd1757cc5df..8ad8977cf1c2 100644 --- a/drivers/clk/meson/clk-regmap.c +++ b/drivers/clk/meson/clk-regmap.c @@ -75,8 +75,8 @@ static unsigned long clk_regmap_div_recalc_rate(struct clk_hw *hw, div->width); } -static long clk_regmap_div_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate) +static int clk_regmap_div_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct clk_regmap *clk = to_clk_regmap(hw); struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); @@ -87,18 +87,17 @@ static long clk_regmap_div_round_rate(struct clk_hw *hw, unsigned long rate, if (div->flags & CLK_DIVIDER_READ_ONLY) { ret = regmap_read(clk->map, div->offset, &val); if (ret) - /* Gives a hint that something is wrong */ - return 0; + return ret; val >>= div->shift; val &= clk_div_mask(div->width); - return divider_ro_round_rate(hw, rate, prate, div->table, - div->width, div->flags, val); + return divider_ro_determine_rate(hw, req, div->table, + div->width, div->flags, val); } - return divider_round_rate(hw, rate, prate, div->table, div->width, - div->flags); + return divider_determine_rate(hw, req, div->table, div->width, + div->flags); } static int clk_regmap_div_set_rate(struct clk_hw *hw, unsigned long rate, @@ -123,14 +122,14 @@ static int clk_regmap_div_set_rate(struct clk_hw *hw, unsigned long rate, const struct clk_ops clk_regmap_divider_ops = { .recalc_rate = clk_regmap_div_recalc_rate, - .round_rate = clk_regmap_div_round_rate, + .determine_rate = clk_regmap_div_determine_rate, .set_rate = clk_regmap_div_set_rate, }; EXPORT_SYMBOL_GPL(clk_regmap_divider_ops); const struct clk_ops clk_regmap_divider_ro_ops = { .recalc_rate = clk_regmap_div_recalc_rate, - .round_rate = clk_regmap_div_round_rate, + .determine_rate = clk_regmap_div_determine_rate, }; EXPORT_SYMBOL_GPL(clk_regmap_divider_ro_ops);