From patchwork Sun Apr 2 09:42:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 78207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1655083vqo; Sun, 2 Apr 2023 02:44:22 -0700 (PDT) X-Google-Smtp-Source: AKy350a5OGYo1LupXWSpPIv5ch9AbXxd/Gzm5UT/cq/MVdSR2OK3KcuX0iHXtY+cGT3/1wz5HG59 X-Received: by 2002:a17:906:250d:b0:8ae:e724:ea15 with SMTP id i13-20020a170906250d00b008aee724ea15mr31017050ejb.76.1680428662630; Sun, 02 Apr 2023 02:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680428662; cv=none; d=google.com; s=arc-20160816; b=HQ2o/f09dMcG+uPxbh3A2DyGamEz/4NPyKY1qVNAJLS1mJ6R/nsTXh8cr+A7nN3u8r xYMtwqlcJZNNskhgXjWf34QCwSQkFjf0trmp2pDMrOTqWhUgXXcgbzBuCrGEqkDme1Sx ZRC1oxgF6KKsRWer6Qu1B2RCFlZ57I/7xs6ZEpZwBaipZFWP4IxXbSsNs5g6FwwckZrY rAVpOYXYyRtl3zGAuwdqcU5vz2Pp+hPfhpP9WDprsa5Sh/IRThLaVvJu+f/FDf7W8Am7 iXGhcrD30CiWzH+oxUUJwrGAUZjqFRRDBomT78Ki7f+0xU9J2k9S1sgJJbTusFWzdmCH /HvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QT5yFmgCNPj9GQvMRvz/D/b7eOq3lrYP2uQVDtDaTlE=; b=Lcp6sMZeKVPLdpUAo5RGV6katV6U7Lcrxrui1hRYC2iHrlAInQFw6zxkerdGwnMH3c sRCUjL2ieCuOIgGRU9ao71hzZSumwVuki8R084n+dwS3tznwD+AJ1fb73EShwKV7VxVF ijXov4p9RT1GXKgxc1gkmwlyz3/75b8Ko3XCmz8G7822mwKN/LzXodnFC6vkGgqdFOAR Pl2IeFKiaZGNuUgURc2AHs3uMJbkWStkHkPxhRdJm3/D0gzt/iBTRyuXb2tziiMnrBJQ xrJELZmj6XcVVlOuvtNUWMU38KDrCZxw8KWujs5pI4WD7HvtLnV+uo08nwke/+SiAWeK VzkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a1709066b8900b009217e23a19esi267726ejr.599.2023.04.02.02.43.59; Sun, 02 Apr 2023 02:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230258AbjDBJm2 (ORCPT + 99 others); Sun, 2 Apr 2023 05:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjDBJm0 (ORCPT ); Sun, 2 Apr 2023 05:42:26 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC3A1BF7B for ; Sun, 2 Apr 2023 02:42:24 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id iuDzpwm4hwFKBiuEApeDi6; Sun, 02 Apr 2023 11:42:23 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 02 Apr 2023 11:42:23 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: mturquette@baylibre.com, sboyd@kernel.org, abelvesa@kernel.org, peng.fan@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, heiko@sntech.de Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 1/4] clk: Compute masks for fractional_divider clk when needed. Date: Sun, 2 Apr 2023 11:42:04 +0200 Message-Id: <0fd6357242c974259c9e034c6e28a0391c480bf0.1680423909.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762057165312079654?= X-GMAIL-MSGID: =?utf-8?q?1762057165312079654?= There is no real need to pre-compute mmask and nmask when handling fractional_divider clk. They can be computed when needed. Signed-off-by: Christophe JAILLET Reviewed-by: Heiko Stuebner Reviewed-by: Heiko Stuebner --- drivers/clk/clk-fractional-divider.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index 6affe3565025..479297763e70 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -71,6 +71,7 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract) struct clk_fractional_divider *fd = to_clk_fd(hw); unsigned long flags = 0; unsigned long m, n; + u32 mmask, nmask; u32 val; if (fd->lock) @@ -85,8 +86,11 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract) else __release(fd->lock); - m = (val & fd->mmask) >> fd->mshift; - n = (val & fd->nmask) >> fd->nshift; + mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; + nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; + + m = (val & mmask) >> fd->mshift; + n = (val & nmask) >> fd->nshift; if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) { m++; @@ -166,6 +170,7 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, struct clk_fractional_divider *fd = to_clk_fd(hw); unsigned long flags = 0; unsigned long m, n; + u32 mmask, nmask; u32 val; rational_best_approximation(rate, parent_rate, @@ -182,8 +187,11 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, else __acquire(fd->lock); + mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; + nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; + val = clk_fd_readl(fd); - val &= ~(fd->mmask | fd->nmask); + val &= ~(mmask | nmask); val |= (m << fd->mshift) | (n << fd->nshift); clk_fd_writel(fd, val); @@ -260,10 +268,8 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev, fd->reg = reg; fd->mshift = mshift; fd->mwidth = mwidth; - fd->mmask = GENMASK(mwidth - 1, 0) << mshift; fd->nshift = nshift; fd->nwidth = nwidth; - fd->nmask = GENMASK(nwidth - 1, 0) << nshift; fd->flags = clk_divider_flags; fd->lock = lock; fd->hw.init = &init;