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 5DB34C001DE for ; Sun, 6 Aug 2023 13:42:22 +0000 (UTC) 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=Ktl/8covJwWrbndP1YKpivE77U8CAf6RlFlqCw35cXQ=; b=I6W4XatuMbVQ8O 98A5fpmSqPpBo8cYOgy0PeX4lI0rGXbybzXaABA4agQnUW1Sgjvw8QExAgYJ36Zd/nA0l66kgAngc gyH0AJWVdG0cMAsn17XpMZDj26Oh6j0GOCXycomQ2xweGct7B1VCrzL2k3nn3++QhR0f2agY+vvuk ofsn740YFxTdpLaFXnUydABVaFBdXMgDz4G+/scGlwf4F8SqLtG9DNIKede36b2zEj5VOneK+Psl5 qY4ccczYtlyR74HM9qkpFurns1mMhT+hYp0hp8uZMSugtdKmHJqfctBZz0+za7mb5EI2u5ffKLpGd XilpOx8VimRcOcO3Qduw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qSe18-00FSrw-1K; Sun, 06 Aug 2023 13:41:58 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qSe15-00FSrZ-2s for linux-arm-kernel@lists.infradead.org; Sun, 06 Aug 2023 13:41:57 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99357737980so541141166b.2 for ; Sun, 06 Aug 2023 06:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691329312; x=1691934112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8h3l0kW2b6vVfnZeHC4Hn3Bn63sg4aqSIG5QO3j6yF0=; b=F1gSaB7ak6JbrTNLC24zZlh6p0MBTNNa3UQrtJmMhG8OW+MYTzHrrDMrc5BCPvUsW9 7eoX99pLowYOQ1BdY5bpHxMCNoMq+hkEj2+vgYqYxPkCRwm3ZC+5HLseMoKpGp9+33kR NKB+2ayaBYWhdWCrrl5NcY5AnSYCDscuMAAQ/UWzpagRU26xxRGqQw6liXNPwrz7w4qF pKlQ8lUVzB3GMdJ3pVLXMfok3HGaKcivRe6RLQplbrPLAb3TQp8aO7uTbFe8Wfy0IfK5 cmyx4VjAvS8ztZOwCr4VoOa+eedJGXRzTdis+SQy8bz19IhjNMk8qmSBfrw5Yuj61l+k LNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691329312; x=1691934112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8h3l0kW2b6vVfnZeHC4Hn3Bn63sg4aqSIG5QO3j6yF0=; b=Ukjk7OByovcNRk0oZDpjkDlBMFYF2xWRY8Ufhc+vHSd4HDmActezOSNVX0girBkBR4 gqWw7YrySrh+sk+Fb5JGhoBHXX/LlxJKmyhlTii4Zn68q6z5z+tTjTcyoq+wXUTvxiWk JYYGSxDDVmcPiJV5XBTN3acCQV5JRrnOmD3/YQwKNddm+D67p+z7WjEnwXHrac0eGHxZ dDqqqOyJm+ECuklosXvsZNilQSW38k/rPYTcREB25U8wU0gMbRZjR4303D2b0MzJLvwi 91u+PrR13nFkQfamiGbmtVNe3QOrqRmL0w3WihXvQ84Rjib6DWKVfRRIe7FVgTczKM3l lKHQ== X-Gm-Message-State: AOJu0YyITKMr9fKorZsx5Akzs1LtjyxksKnrXMSOeDzfeyNXGWeo9LUp 2bLRem5CMRam+Z3ZSIxAfVI= X-Google-Smtp-Source: AGHT+IGtCrikG4mrC+gYRcFUweuBPrubVvV5N14YOGnArL2nkxMEhLWlK00Pz+lMgPhSP5zX1nqiIQ== X-Received: by 2002:a17:906:20d5:b0:99b:237e:6ee with SMTP id c21-20020a17090620d500b0099b237e06eemr7127559ejc.30.1691329309975; Sun, 06 Aug 2023 06:41:49 -0700 (PDT) Received: from jernej-laptop.localnet (82-149-1-233.dynamic.telemach.net. [82.149.1.233]) by smtp.gmail.com with ESMTPSA id a8-20020a170906244800b00992b2c55c67sm3976871ejb.156.2023.08.06.06.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Aug 2023 06:41:49 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Maxime Ripard , Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Samuel Holland , Andre Przywara , Roman Beranek , Frank Oltmanns Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Frank Oltmanns Subject: Re: [PATCH v5 05/11] clk: sunxi-ng: Add helper function to find closest rate Date: Sun, 06 Aug 2023 15:41:48 +0200 Message-ID: <8292789.NyiUUSuA9g@jernej-laptop> In-Reply-To: <20230806-pll-mipi_set_rate_parent-v5-5-db4f5ca33fc3@oltmanns.dev> References: <20230806-pll-mipi_set_rate_parent-v5-0-db4f5ca33fc3@oltmanns.dev> <20230806-pll-mipi_set_rate_parent-v5-5-db4f5ca33fc3@oltmanns.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230806_064155_949951_8FA02C1C X-CRM114-Status: GOOD ( 19.40 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dne nedelja, 06. avgust 2023 ob 15:06:50 CEST je Frank Oltmanns napisal(a): > The default behaviour of clocks in the sunxi-ng driver is to select a > clock rate that is closest to but less than the requested rate. > > Add the ccu_is_better_rate() helper function that - depending on the > fact if thc CCU_FEATURE_CLOSEST_RATE flag is set - decides if a rate is > closer than another rate. > > Acked-by: Maxime Ripard > Signed-off-by: Frank Oltmanns Reviewed-by: Jernej Skrabec Best regards, Jernej > --- > drivers/clk/sunxi-ng/ccu_common.c | 12 ++++++++++++ > drivers/clk/sunxi-ng/ccu_common.h | 5 +++++ > 2 files changed, 17 insertions(+) > > diff --git a/drivers/clk/sunxi-ng/ccu_common.c > b/drivers/clk/sunxi-ng/ccu_common.c index 8d28a7a079d0..8babce55302f 100644 > --- a/drivers/clk/sunxi-ng/ccu_common.c > +++ b/drivers/clk/sunxi-ng/ccu_common.c > @@ -39,6 +39,18 @@ void ccu_helper_wait_for_lock(struct ccu_common *common, > u32 lock) } > EXPORT_SYMBOL_NS_GPL(ccu_helper_wait_for_lock, SUNXI_CCU); > > +bool ccu_is_better_rate(struct ccu_common *common, > + unsigned long target_rate, > + unsigned long current_rate, > + unsigned long best_rate) > +{ > + if (common->features & CCU_FEATURE_CLOSEST_RATE) > + return abs(current_rate - target_rate) < abs(best_rate - target_rate); > + > + return current_rate <= target_rate && current_rate > best_rate; > +} > +EXPORT_SYMBOL_NS_GPL(ccu_is_better_rate, SUNXI_CCU); > + > /* > * This clock notifier is called when the frequency of a PLL clock is > * changed. In common PLL designs, changes to the dividers take effect > diff --git a/drivers/clk/sunxi-ng/ccu_common.h > b/drivers/clk/sunxi-ng/ccu_common.h index 5ad219f041d5..942a72c09437 100644 > --- a/drivers/clk/sunxi-ng/ccu_common.h > +++ b/drivers/clk/sunxi-ng/ccu_common.h > @@ -53,6 +53,11 @@ struct sunxi_ccu_desc { > > void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock); > > +bool ccu_is_better_rate(struct ccu_common *common, > + unsigned long target_rate, > + unsigned long current_rate, > + unsigned long best_rate); > + > struct ccu_pll_nb { > struct notifier_block clk_nb; > struct ccu_common *common; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel