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 531A2C64EC7 for ; Sat, 25 Feb 2023 08:39:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E0063809A5; Sat, 25 Feb 2023 09:38:49 +0100 (CET) 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="XZrLfkxc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0466985B68; Sat, 25 Feb 2023 09:38:42 +0100 (CET) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 51D3485B84 for ; Sat, 25 Feb 2023 09:38:35 +0100 (CET) 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-x536.google.com with SMTP id d30so6416431eda.4 for ; Sat, 25 Feb 2023 00:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; 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=ziR30gGYbNwF+BWVCTJGgGS6T2Wya5Vb2HBNyjs4l0M=; b=XZrLfkxc4O69pl0OdbYBBhAdrqTpwpBRxTbG5sHP3aHUpZd3tFU70HmBX4NwhkpTRi AHSdDfI2JGM2hkJOXfeA/VlwUhXLuR6OxUbiJEQgHkN3xTZPMFbgcn5xKbIzZ92ZB5HK XAQ+2qIVO+iq+jMLvDDKcoG0HkQoJjw3AbKjA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ziR30gGYbNwF+BWVCTJGgGS6T2Wya5Vb2HBNyjs4l0M=; b=VZSJEn5Qs9qsVtIHBt3lsXtUSWlt1eEQmmn+rdw902SxZ2a0Nys8fmh37ZxaoBTiMl ic980GbTz7Q1MGqe2YgiJibuUZDfrEy2vYEcrE/45mntNX2aogz3ZLVzO3Yfo83vozxz Q6FnTaOkMCklSzvUjIICL3T9Q5TEf+UkQQG365tF37bWxIyLUNNQ/L/1il+Ts4yPl9zi ALiwbeCmOrInZF4LQTtrhhUMApHJycaDViU/q+0+AkiNhYuNjTqLUvEgDVS6du/II0BL 5cAmk6vCdA+J5dnVPGtU12pyRlP8pTcinnbmqdHdYiuY1yIehtRjmw1de03nVt4NmeE7 kT1w== X-Gm-Message-State: AO0yUKUywFCUJSu6ZMSrXgOgod/p+FkaLXIHV94juXA9JQVuq7oLH3Ft fTPq/OJ2byjWwuEJmPT/oObBFn0h3Hfr/e6oz9Y= X-Google-Smtp-Source: AK7set9E+UVbYQvL+RdmDUFTYMl4QbWvAfYrMqTrWk0U/DA44HhGVpWTqPZFz+butjXvXumiEoserA== X-Received: by 2002:a17:907:8b85:b0:8ee:babc:d40b with SMTP id tb5-20020a1709078b8500b008eebabcd40bmr8113130ejc.58.1677314314702; Sat, 25 Feb 2023 00:38:34 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-56-22-12.retail.telecomitalia.it. [82.56.22.12]) by smtp.gmail.com with ESMTPSA id u20-20020a170906655400b008f2b0c6052csm591958ejn.89.2023.02.25.00.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Feb 2023 00:38:34 -0800 (PST) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Lukasz Majewski , Sean Anderson , linux-amarula@amarulasolutions.com, Dario Binacchi , Fabio Estevam , "NXP i.MX U-Boot Team" , Stefano Babic Subject: [PATCH 1/3] imx6: clock: improve calculations to get the PLL video rate Date: Sat, 25 Feb 2023 09:38:19 +0100 Message-Id: <20230225083821.472605-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230225083821.472605-1-dario.binacchi@amarulasolutions.com> References: <20230225083821.472605-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.6 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 --- 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