From patchwork Mon Jun 17 09:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13700391 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 C5191C27C6E for ; Mon, 17 Jun 2024 09:26:12 +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: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:In-Reply-To:References:List-Owner; bh=Tx4pNRLpiW1DaAXDAqj/NMde19iSIVwY+U2Zh9EufNE=; b=tgCgfyFVI4zI6dsbZ/gFpQX8Kj nSEa0E4lhyrGq41SRobgEQzpT9fBm9dAjbwqIsG7M7+8WqjC1b9eqKZlxCxDSz7ZWDXoU12FcHLXD pcJMaDoY2/OL9RvCe1oH8Uxxql5x1fn5iIe/yeepqXExOYS9FR4zTHqOqKBof3EngS/iIRfCMS/n0 UERcjPZ3/Q8M0H9cqIOnnQ4OhJWaZXkWDQTGc2KetorBz/ZCSWUTWDyC906jtxJKg8tJztQ3BmERC 6wbAnT9iDBn7vhgS43fIc11O3+03sz0kQ3WFIHXGdzlsUEpuyHrNkUfkSBNwfFbnH6PA9JJ/YOlHR prcSrpYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJ8cj-0000000A23i-2JTU; Mon, 17 Jun 2024 09:26:01 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJ8cg-0000000A238-3Eej for linux-arm-kernel@lists.infradead.org; Mon, 17 Jun 2024 09:26:00 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7DCC9CE0F08; Mon, 17 Jun 2024 09:25:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 671F1C2BD10; Mon, 17 Jun 2024 09:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718616355; bh=1jxzhJIYvkT/WxCnVH/1bPAPoB4pVyrYe9iMSSE8TZM=; h=From:To:Cc:Subject:Date:From; b=m4tLuLmxLE/YYsegkxbf+9/zv3OtNcHDcWjlfkA6etjMFPX+q6s4QaAREMVRBr4h5 Wx7TDzJbSjuAgIrDOgc8HGmrgj6ge6Vfn2sqIDFebdLdpvptMTkYBGc/C7fCNyLrrz Rn9uwUW4jRcu6XZPRO6X3H5n2PrncJE5EDjcYV81MUoQiMtba8rZrzOgjcWFRfjnY5 40x4qWkRKCt/6g0Xh5W3sg4fK3rllQ1ZWEQNPN3esg8W0qqKULi/H/ZWM8oynlwhIC Cfhn9FTeau5P/mbSuF9UNe2uIXf94urDfk92Zy9t7JpOMxwBAF62lcTwPIx1qg8fOb t4nwIE5jyC9JQ== From: Lorenzo Bianconi To: linux-clk@vger.kernel.org Cc: p.zabel@pengutronix.de, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.bianconi83@gmail.com, linux-arm-kernel@lists.infradead.org, nbd@nbd.name, john@phrozen.org, upstream@airoha.com, angelogioacchino.delregno@collabora.com Subject: [PATCH] clk: en7523: fix rate divider for slic and spi clocks Date: Mon, 17 Jun 2024 11:25:49 +0200 Message-ID: X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240617_022559_017696_BB1E972A X-CRM114-Status: GOOD ( 10.13 ) 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 Introduce div_offset field in en_clk_desc struct in order to fix rate divider estimation in en7523_get_div routine for slic and spi fixed rate clocks. Moreover, fix base_shift for crypto clock. Fixes: 1e6273179190 ("clk: en7523: Add clock driver for Airoha EN7523 SoC") Signed-off-by: Lorenzo Bianconi Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/clk-en7523.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c index 9757023601c5..9804fce7872d 100644 --- a/drivers/clk/clk-en7523.c +++ b/drivers/clk/clk-en7523.c @@ -62,6 +62,7 @@ struct en_clk_desc { u8 div_shift; u16 div_val0; u8 div_step; + u8 div_offset; }; struct en_clk_gate { @@ -106,6 +107,7 @@ static const struct en_clk_desc en7523_base_clks[] = { .div_bits = 3, .div_shift = 0, .div_step = 1, + .div_offset = 1, }, { .id = EN7523_CLK_EMI, .name = "emi", @@ -119,6 +121,7 @@ static const struct en_clk_desc en7523_base_clks[] = { .div_bits = 3, .div_shift = 0, .div_step = 1, + .div_offset = 1, }, { .id = EN7523_CLK_BUS, .name = "bus", @@ -132,6 +135,7 @@ static const struct en_clk_desc en7523_base_clks[] = { .div_bits = 3, .div_shift = 0, .div_step = 1, + .div_offset = 1, }, { .id = EN7523_CLK_SLIC, .name = "slic", @@ -172,13 +176,14 @@ static const struct en_clk_desc en7523_base_clks[] = { .div_bits = 3, .div_shift = 0, .div_step = 1, + .div_offset = 1, }, { .id = EN7523_CLK_CRYPTO, .name = "crypto", .base_reg = REG_CRYPTO_CLKSRC, .base_bits = 1, - .base_shift = 8, + .base_shift = 0, .base_values = emi_base, .n_base_values = ARRAY_SIZE(emi_base), } @@ -281,7 +286,7 @@ static u32 en7523_get_div(void __iomem *base, int i) if (!val && desc->div_val0) return desc->div_val0; - return (val + 1) * desc->div_step; + return (val + desc->div_offset) * desc->div_step; } static int en7523_pci_is_enabled(struct clk_hw *hw)