From patchwork Sat Feb 25 08:38:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2735 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D97C53F376 for ; Sat, 25 Feb 2023 09:38:37 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id dk16-20020a0564021d9000b004aaa054d189sf2125836edb.11 for ; Sat, 25 Feb 2023 00:38:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677314317; cv=pass; d=google.com; s=arc-20160816; b=Na+vzeYFxlasze6dCY/o6VkRuFpM3rK1uDrxHjjGhcPMxVwzcaO946/WEFfJqNNzlZ gaES44us/OObWGOxV1EESEJCPYuaDkalX0aROr1tC9cYwf8GPo4Qt3g6txmP8eE4TgEr buNAoeAY4ewfEoeh86zsH1NJsn7DlrTScoHeLWhRyyXVVkJprvvEO/uWtnaQrQHnyHk/ Aq/hGKOg9j1KN0GNkSVrY0SfjmMJyrsJdiruvcUpj9howO9B04gKsaeHZP/v+b+ZIffq swmtn0VOstjXtPn5dnsk+gqxj/XPlVYgMk83PEWmXO7ZxgiM/B86LqHlRJioFps3TivC vWgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Vi8Ly+HApIjVbOduJvNlDhRMTkyTKzTyX/5VnJdUjiQ=; b=Wa6Kja3nDdO69ejC2at1LnjbNFgP2IoeC13VkjJzPPT9KAFYJSK+BhZdxeED86d6YI b6WiXC2MqbHG1KrcUPv06UN6celdpsp4zjPgnIx0WbKUJyCvWTXa5slecAfWUYijfBH+ PGLNxobC/hvjWGL3FghuiBBR1IcsMDoD7SKxttZSOsZZRb95/+8qzDXg1jtag8IzzTQW 4tFMzbfomijzLaL10bAg3PfVz9B66R6Pum7C63qecCr8UgMj7x7ta3/UCvkuOn8WVCUS x6L+waKWGCitalmxC50SdpGU9S0oyEn2ZugYK/+BItkgX1FgxhP7NHyrY/5z/IA9otSI b26A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="S0Xg/9L0"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Vi8Ly+HApIjVbOduJvNlDhRMTkyTKzTyX/5VnJdUjiQ=; b=qWgBHcDn9BrASVXQKrpuewlL0jfgxwLtPYWtqjnLjVUtcdWdAVmkeEp6fV+wyDl2QI uH4Lw+zrsDTT36bWYC4rLMkJ80ZAN8sp7fXd99u6n1Lc1MDrKN5sGF8eg+UEvGbkdI/M cAV2tCVdkAQJj8OfzO8vRbmKG0jBkJu+9magU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=Vi8Ly+HApIjVbOduJvNlDhRMTkyTKzTyX/5VnJdUjiQ=; b=KgVI3iLMpfs3jDFUikjYnkBygUzndCvoT/KOV/HtjMCdmfGtBhSXJlqbKhXCV0mtzZ pPP9K63338bEoG/oyLz40IHaU1nEtPI/ogxu87r9h+6HU35CSwUXjl1f3aHYFxqX+7V9 yfGfLmW/88G9+xq1T3IGW05qwc332uqRz6G39bjvNlgp6047LDNK7YScRRLd9272W9Ju TWbBmQzwwEmWgGJxebXO3dFoRkslxDUkUBVk5rMQZBIVtxYv41JYtGg3omH/m/lo5xaF eQYZLmfdwQGjcluwJKuyaVfvS6PKQBDMfQHLr+E8arNBokBnMogd0gGCBLDVvYd50Nds fM7g== X-Gm-Message-State: AO0yUKUovMn1jRurf81NQeC8dRq81DwesQiScGWl5LrftNcuifhDje8/ Atil1rfwKR5yZ1JlkmlGL7LBtLuy X-Google-Smtp-Source: AK7set93Qe4S4Q6QaSef+241ngq7ErpffWsu4Upr7HRmpSVwZ3QpC0twjAe8P97Kp4G9mT05+nOgWA== X-Received: by 2002:a17:906:40c7:b0:8d1:9162:514a with SMTP id a7-20020a17090640c700b008d19162514amr9210698ejk.8.1677314317372; Sat, 25 Feb 2023 00:38:37 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:4a12:b0:8b1:793a:1e4d with SMTP id w18-20020a1709064a1200b008b1793a1e4dls3058740eju.0.-pod-prod-gmail; Sat, 25 Feb 2023 00:38:36 -0800 (PST) X-Received: by 2002:a17:906:2412:b0:8b1:76dd:f5ef with SMTP id z18-20020a170906241200b008b176ddf5efmr29296814eja.5.1677314315830; Sat, 25 Feb 2023 00:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677314315; cv=none; d=google.com; s=arc-20160816; b=nAXz9wZgdrxgi+cM6BGRuIZnoJwZnHQ2AzWkTf9MZjUOM+N6x3/kiEfOlLK+7MeWME Nw0jjpNhfCYiF67FGMcIFpr0UzV19MhCi1a7pklxJYDHLAnT61Thg9+NyidEqtAjpxE1 VKPmgoAyDnTKLyA90pdo1uPe0/t23/yrMUybEQQWl/RhkS9eZLctS19cV5Y/d1Y3URxJ mxg6TmIsI7//AvoQN6KW7+cl/GbRDpcNnOqJMb67sFr90d1Nmjx6DGlJ416k28Am8EpK rOBYxsSzIoJJZ6WXHV1dYtvxFg74Mr8Ajj80S1EqoaPTlY+7kVkwW/O6+HuuCYSwtewt 2WMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=D3tGtLKpDPlhoXjnIon7451qNLLQ+gU5NIRQzHhHXZM=; b=Kjp7ASxMZej04AFzW3GIg+nuaXFbK8VGjqJxdl+sH8TN2c5/SdbOsiSR1ttZbTaKw+ 494JRiJCmjVCn/++IzSevfwb79Zil5Ql136vmO68U4i47hZbzsjBX0T9SPtBq9xgV/Bc xXEToJ0oflFv4tbvF+U74acLd7Bjl8vlE87HGPJtLTs81f0Tfoy/RhShZ9Osx8CRX6hT tO56AJSC35S48lV85ijOdVuEF0uZblO28hO+F2pTPnsxSAvNy6L0e918kh9jheT5ZmGU IDAK0c1GZDT9fN/ZpK/T2b8k/lI5wkW5gnuzoqtdRwUX6D5B9kvR28Bf/J7nestH2Z4e 33BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="S0Xg/9L0"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id by8-20020a170906a2c800b008c0c41414a7sor518477ejb.15.2023.02.25.00.38.35 for (Google Transport Security); Sat, 25 Feb 2023 00:38:35 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:4550:b0:8b1:7ae8:ba79 with SMTP id s16-20020a170906455000b008b17ae8ba79mr28986977ejq.30.1677314315666; Sat, 25 Feb 2023 00:38:35 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Feb 2023 00:38:35 -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 2/3] imx6: clock: add support to get LCD pixel clock rate Date: Sat, 25 Feb 2023 09:38:20 +0100 Message-Id: <20230225083821.472605-3-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 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="S0Xg/9L0"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add the get_lcd_clk() function to get the LCD pixel clock rate. The patch has been tested on imx6ul platform. Signed-off-by: Dario Binacchi --- arch/arm/include/asm/arch-mx6/clock.h | 2 + arch/arm/mach-imx/mx6/clock.c | 58 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/arch/arm/include/asm/arch-mx6/clock.h b/arch/arm/include/asm/arch-mx6/clock.h index 8ae49715789c..81af89c631f5 100644 --- a/arch/arm/include/asm/arch-mx6/clock.h +++ b/arch/arm/include/asm/arch-mx6/clock.h @@ -41,6 +41,8 @@ enum mxc_clock { MXC_SATA_CLK, MXC_NFC_CLK, MXC_I2C_CLK, + MXC_LCDIF1_CLK, + MXC_LCDIF2_CLK, }; enum ldb_di_clock { diff --git a/arch/arm/mach-imx/mx6/clock.c b/arch/arm/mach-imx/mx6/clock.c index 17d8dcd5c841..267d86ab4194 100644 --- a/arch/arm/mach-imx/mx6/clock.c +++ b/arch/arm/mach-imx/mx6/clock.c @@ -418,6 +418,60 @@ static u32 get_uart_clk(void) return freq / (uart_podf + 1); } +static u32 get_lcd_clk(unsigned int ifnum) +{ + u32 pll_rate; + u32 pred, postd; + + if (!is_mx6sx() && !is_mx6ul() && !is_mx6ull() && !is_mx6sl() && + !is_mx6sll()) { + debug("This chip does't support lcd\n"); + return 0; + } + + pll_rate = decode_pll(PLL_VIDEO, MXC_HCLK); + if (ifnum == 1) { + if (!is_mx6sl()) { + pred = __raw_readl(&imx_ccm->cscdr2); + pred &= MXC_CCM_CSCDR2_LCDIF1_PRE_DIV_MASK; + pred = pred >> MXC_CCM_CSCDR2_LCDIF1_PRE_DIV_OFFSET; + + postd = readl(&imx_ccm->cbcmr); + postd &= MXC_CCM_CBCMR_LCDIF1_PODF_MASK; + postd = postd >> MXC_CCM_CBCMR_LCDIF1_PODF_OFFSET; + } else { + pred = __raw_readl(&imx_ccm->cscdr2); + pred &= MXC_CCM_CSCDR2_LCDIF_PIX_PRE_DIV_MASK; + pred = pred >> MXC_CCM_CSCDR2_LCDIF_PIX_PRE_DIV_OFFSET; + + postd = readl(&imx_ccm->cscmr1); + postd &= MXC_CCM_CSCMR1_LCDIF_PIX_PODF_OFFSET; + postd = postd >> MXC_CCM_CBCMR_LCDIF1_PODF_OFFSET; + } + } else if (ifnum == 2) { + if (is_mx6sx()) { + pred = __raw_readl(&imx_ccm->cscdr2); + pred &= MXC_CCM_CSCDR2_LCDIF2_PRE_DIV_MASK; + pred = pred >> MXC_CCM_CSCDR2_LCDIF2_PRE_DIV_OFFSET; + + postd = readl(&imx_ccm->cscmr1); + postd &= MXC_CCM_CSCMR1_LCDIF2_PODF_MASK; + postd = postd >> MXC_CCM_CSCMR1_LCDIF2_PODF_OFFSET; + + } else { + goto if_err; + } + } else { + goto if_err; + } + + return DIV_ROUND_UP_ULL((u64)pll_rate, (postd + 1) * (pred + 1)); + +if_err: + debug("This chip not support lcd iterface %d\n", ifnum); + return 0; +} + static u32 get_cspi_clk(void) { u32 reg, cspi_podf; @@ -1273,6 +1327,10 @@ unsigned int mxc_get_clock(enum mxc_clock clk) return get_usdhc_clk(3); case MXC_SATA_CLK: return get_ahb_clk(); + case MXC_LCDIF1_CLK: + return get_lcd_clk(1); + case MXC_LCDIF2_CLK: + return get_lcd_clk(2); default: printf("Unsupported MXC CLK: %d\n", clk); break;