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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0402DC77B76 for ; Sat, 22 Apr 2023 14:11:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F307863B6; Sat, 22 Apr 2023 16:11:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="r1/326PU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7945D8642F; Sat, 22 Apr 2023 16:11:30 +0200 (CEST) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0A9AF86439 for ; Sat, 22 Apr 2023 16:11:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dario.binacchi@amarulasolutions.com Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-504eb1155d3so20089133a12.1 for ; Sat, 22 Apr 2023 07:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1682172686; x=1684764686; 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=JrQ8o7UyARpsrBXpt9TSn9qwzjxHnBHq9JmOxAYlJnw=; b=r1/326PU4cR1168JwvfACIQq/AefcXKYRArQ0ZMhz88xJi5E5sxYUilOYASRK4IRnI Mc0FkILepz4sDIBGOdZka4EuYaasxjAcpp4EqQimhtfQPvakLtzGkMcTafAf9+bKbQpm RzqFLviz7m+pTBw8TJjmS2GA4lhllQgUFf5UY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682172686; x=1684764686; 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=JrQ8o7UyARpsrBXpt9TSn9qwzjxHnBHq9JmOxAYlJnw=; b=gF8m+utL0bvEWR7mNGCo+3oiugveoPXuaHNYmkuwWiySiU4bkEu1NuLzC+vHqYQ9RO pA6Y+i1mUvmPEbg09ZqbNWXDF2JOXVE50vps8blLYyf11UzMKL+HErfepY4c3+a7qMKp gtoRzndo39jATTpg+EbIBczw4W940uI6doseHcV/bd/NxBXq/omt/5AblPFZUzVKvXNh p2u/7hgyLZ6udLxyhJ3ReKSJvCryn0/v6zU3cOs1h+USyA1A0X/5ViDQEOcqF0Rk0GMr i9E5Yja0WXrPQQFiS+KgL8V/ll0TI0cZmooPcR/sOJdbg5S07brA8GQMELzP6dOZImZ9 nylw== X-Gm-Message-State: AAQBX9fp4gO/6QIIyj+5izgKXOZErhx7CvCOflGhoCnnH6zg06uWKnc9 ntOeipjlL1ySPKlWkAHay96+18gvzn2KCvCdZ737iQ== X-Google-Smtp-Source: AKy350ZavNFDnimDW/KtbsUPHqndl4UObtw+gMgmdxGG30j6h8H0TWeBb7VvdBzgD5L2xxdQlDxjug== X-Received: by 2002:a17:906:2307:b0:94a:643e:9e26 with SMTP id l7-20020a170906230700b0094a643e9e26mr5890981eja.14.1682172686501; Sat, 22 Apr 2023 07:11:26 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-5-99-194.retail.telecomitalia.it. [87.5.99.194]) by smtp.gmail.com with ESMTPSA id de23-20020a1709069bd700b0094f02ebedf5sm3304752ejc.64.2023.04.22.07.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 07:11:25 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Sean Anderson , Lukasz Majewski , Dario Binacchi , Michael Trimarchi , Fabio Estevam , "NXP i.MX U-Boot Team" , Stefano Babic Subject: [RESEND PATCH 1/3] imx6: clock: improve calculations to get the PLL video rate Date: Sat, 22 Apr 2023 16:11:17 +0200 Message-Id: <20230422141119.618453-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230422141119.618453-1-dario.binacchi@amarulasolutions.com> References: <20230422141119.618453-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean During some tests to check the pixel clock rate in the transition from U-Boot to the Linux kernel, I noticed that with the same configuration of the registers the debug messages reported different rates. The same Linux kernel calculations are now used to get the PLL video rate. Signed-off-by: Dario Binacchi Reviewed-by: Michael Trimarchi --- arch/arm/mach-imx/mx6/clock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/mx6/clock.c b/arch/arm/mach-imx/mx6/clock.c index cb9d629be408..17d8dcd5c841 100644 --- a/arch/arm/mach-imx/mx6/clock.c +++ b/arch/arm/mach-imx/mx6/clock.c @@ -213,6 +213,7 @@ int enable_spi_clk(unsigned char enable, unsigned spi_num) static u32 decode_pll(enum pll_clocks pll, u32 infreq) { u32 div, test_div, pll_num, pll_denom; + u64 temp64; switch (pll) { case PLL_SYS: @@ -272,7 +273,10 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq) } test_div = 1 << (2 - test_div); - return infreq * (div + pll_num / pll_denom) / test_div; + temp64 = (u64)infreq; + temp64 *= pll_num; + do_div(temp64, pll_denom); + return infreq * div + (unsigned long)temp64; default: return 0; } -- 2.32.0