From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E66061F7545; Tue, 3 Dec 2024 15:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733238857; cv=none; b=VgsnM13BA5UhgZlIFOrQt5JMwSucEinFDWKquSqkhtn4ksfEaKXkxRDZsNTWh43EmJnMzU8edpo+a5CuiKYws4aIKWET3rsN7eXICL4k6ciIoYi/JZasbugRiEDycJbu4Z9imdLRJuzvc8xwFtMWfPQef8GFDCYeOvOT3z3/Q+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733238857; c=relaxed/simple; bh=TYKs91G1RBxeIAK2PQawSZhvgDofGMM34L8w7Zuu8OE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DRKhP5Zo1fd6RWgQm0TiPb3i0S+jVCMrlSCze3uMSkSbntmpq0OFOgQAIDbwW3AQmGfYojtt0XurjJTR2cnHyBAi4Yn4BZcUhPnLw8dfYuQlKmT4qdRyQlHQb04DU5K8zl7K8ZjZWRL5BGPaejAtNHQFjE01GQsnRu198La+Jg4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bGSHkoTZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bGSHkoTZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C0C8C4CECF; Tue, 3 Dec 2024 15:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733238856; bh=TYKs91G1RBxeIAK2PQawSZhvgDofGMM34L8w7Zuu8OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGSHkoTZ16/x/YFs1ypnQxyMjdGzREuVGCcKdRUnIFiuOz+AT688DPVd7/SIhAMC/ WBvBqc0K293IXqppIxG//Omhr6k3V4lPmiSNn9JfP6qKBcgrcQIcEOMhGM1d5dJ7HY XYZnRVYFVyVAoqHRztNqfjgxw+Ram94pECpT7gtw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hien Huynh , Biju Das , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 6.11 421/817] clk: renesas: rzg2l: Fix FOUTPOSTDIV clk Date: Tue, 3 Dec 2024 15:39:53 +0100 Message-ID: <20241203144012.318061492@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241203143955.605130076@linuxfoundation.org> References: <20241203143955.605130076@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Biju Das [ Upstream commit dabf72b85f298970e86891b5218459c17b57b26a ] While computing foutpostdiv_rate, the value of params->pl5_fracin is discarded, which results in the wrong refresh rate. Fix the formula for computing foutpostdiv_rate. Fixes: 1561380ee72f ("clk: renesas: rzg2l: Add FOUTPOSTDIV clk support") Signed-off-by: Hien Huynh Signed-off-by: Biju Das Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/20241024134236.315289-1-biju.das.jz@bp.renesas.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- drivers/clk/renesas/rzg2l-cpg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c index 04b78064d4e01..640ab2cc28cfa 100644 --- a/drivers/clk/renesas/rzg2l-cpg.c +++ b/drivers/clk/renesas/rzg2l-cpg.c @@ -552,7 +552,7 @@ static unsigned long rzg2l_cpg_get_foutpostdiv_rate(struct rzg2l_pll5_param *params, unsigned long rate) { - unsigned long foutpostdiv_rate; + unsigned long foutpostdiv_rate, foutvco_rate; params->pl5_intin = rate / MEGA; params->pl5_fracin = div_u64(((u64)rate % MEGA) << 24, MEGA); @@ -561,10 +561,11 @@ rzg2l_cpg_get_foutpostdiv_rate(struct rzg2l_pll5_param *params, params->pl5_postdiv2 = 1; params->pl5_spread = 0x16; - foutpostdiv_rate = - EXTAL_FREQ_IN_MEGA_HZ * MEGA / params->pl5_refdiv * - ((((params->pl5_intin << 24) + params->pl5_fracin)) >> 24) / - (params->pl5_postdiv1 * params->pl5_postdiv2); + foutvco_rate = div_u64(mul_u32_u32(EXTAL_FREQ_IN_MEGA_HZ * MEGA, + (params->pl5_intin << 24) + params->pl5_fracin), + params->pl5_refdiv) >> 24; + foutpostdiv_rate = DIV_ROUND_CLOSEST_ULL(foutvco_rate, + params->pl5_postdiv1 * params->pl5_postdiv2); return foutpostdiv_rate; } -- 2.43.0