From patchwork Sat Apr 22 14:11:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2863 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BC1793F334 for ; Sat, 22 Apr 2023 16:11:28 +0200 (CEST) Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-94a34a09571sf287309466b.1 for ; Sat, 22 Apr 2023 07:11:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682172688; cv=pass; d=google.com; s=arc-20160816; b=zEEt+KHWRCYKjDP9lc+67/41mUfn/C1fXwJLJjVTlmcPhWnRiEA7Ex97ancvBr0aE1 uLVUzrGBEm+kkUmxFN9yPpPTe0mN8Iw6IznwTFz0oYxB91rf2ORjN2gdudMNR7Iiga5A i4A95GeSjX7S8jup/QELjpFYxmTGCeN/ERMRiN92rQilJxokpHbvj5UfxXq5VovUpw/A WTDKIVdFtmZ4KcE3nHemcrj1GQMEXC3IdfeNIREpcDgAyBxQ+TIgYTEF17T1cNcR46e6 IzwfLshJDHbx7xBsDdfUwFKPjXAqVVsNNlc0Sf9kcjMs2VK/CkGYgUABfApYVPWeIbKi T30A== 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=70eB7XApWyvIWs+3JaIUs5Ly01nSa7IHh3byxvUQuU8=; b=06fz8RN5b4Sup3e2qWSs+SUcDCAhyh6APIU+fVo95mq2ioqvXDMMNYDezzJzgep3CY MEEF2gV4tB3aXe6wuNy7VAvGafhq835/xDHTGaxCbnIjyIwVYStSgsAS0FbSY8SHsUlc JEwsha5G4ji9aGk0l7aA5dmgRmWFYzUA1NGmdmCgFk6Bg89TOqkW2rlhqd6VNIj9bSAA 7BWQZ0FQ4qE8ijNvJqJydODKzDR9YRCUp4EJ4GhbdnlyMTomyJxRZTMDq205xB8wYPkc dYcsDMTT/XN4UCq0cPoWTJ7ldFbV9JzdhDNCEI/XMR14UBhMVrZnVaFcTqQPlF3kJkbM p+cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="r1/326PU"; 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; t=1682172688; x=1684764688; 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=70eB7XApWyvIWs+3JaIUs5Ly01nSa7IHh3byxvUQuU8=; b=g9C+p4qQ9R/aKXSovfSQAXSUYxO3eh+FrzmRk72iNZs/j9sCx1FWh5ngV6vzF5yK5U Izb9MWnxyrncf82reElhWKItm1CSXBIGpBDaQx9Y2BFSSGBoV1nYQORCIK9MjBPyb/F5 /2Be/giEkhEBmOazY8HeQmzC4Xta/i7y7ksCg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682172688; x=1684764688; 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-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=70eB7XApWyvIWs+3JaIUs5Ly01nSa7IHh3byxvUQuU8=; b=Zwh+/hS1zpoRKyIlj7lLk6DPCG2H/NaU7Jn7iDui8BZqwjoVW/wgF9tOF7IvJ2NlZJ BGcT40PtSLZF6U01RBundFYcusZpXZkUrsbDOt5kG7uglWqqI8LPuCWupVQu8ESJydXB 6F3AFrkR2UgPzoimmAlZuCiEK5fV/ceOHsXdbjq2xOT1hqjpVUlq6h+SKFs/Sfex3Ip3 FgXzEU1NtD/bX8ZTsU+uIvhs9kaaUnEw9lqD+GSHJlk1JeTQAbBLIAmfYWXnK6U3wbOv tZE54j9BLa1YZAUCmJJgUPzB1moLCYpMdMo3qV8LykV9BB49P4PpEI5WZ7sDJVkL+eaj cnhQ== X-Gm-Message-State: AAQBX9dDmR7fR6c5EDBggsLy2iY8ThFmDkt7LEtpZNbh+bHbR8Hrp8hL AfTkXFXkQqMYe25qa1CwJJW7XR+8 X-Google-Smtp-Source: AKy350YBwDpaw3ObPUhquRQiaeGAG+NsnxJHxqJxEy3rhq7PAuRAYXF/jypwN81KayERXv2dYiP5gQ== X-Received: by 2002:a17:906:d8c8:b0:94e:46ee:f9c8 with SMTP id re8-20020a170906d8c800b0094e46eef9c8mr1786101ejb.14.1682172688343; Sat, 22 Apr 2023 07:11:28 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:b60a:b0:921:8068:e25e with SMTP id vl10-20020a170907b60a00b009218068e25els5048384ejc.0.-pod-prod-gmail; Sat, 22 Apr 2023 07:11:27 -0700 (PDT) X-Received: by 2002:a17:906:7b84:b0:94f:367f:3f2e with SMTP id s4-20020a1709067b8400b0094f367f3f2emr5210550ejo.1.1682172686721; Sat, 22 Apr 2023 07:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682172686; cv=none; d=google.com; s=arc-20160816; b=AiXo1LiLIs/gLOInWY4SsPRZOHQ79sBkvRq7DznYyqH7M/cu16RXqBrmnqZKA9xSNU P8A9eflaJEZ+BNuRJQTgFUJVM8BFI6fhB76on2uSFF8SzVqhyovNum1UT1jQuWD3cXTR D9tjiaYkDcFQYhDtaNp7EE627BofSek1RVxMvHbiyh1F1auk9mM/GvU1/HX/D9APhlnF D8/wqHxedUnZISpvFD5K/3fpPtG1jrQlCBM/VuQQVvZgkwxV7KbW2IJT9C6r30Ccnf+d Uir0i5mCd4X070Yoeh8N2pw9hR3aIrTy2sW1B/Jd61OyD/cecA/f1b6kB3BngP5FLRLT emzQ== 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=JrQ8o7UyARpsrBXpt9TSn9qwzjxHnBHq9JmOxAYlJnw=; b=gvai5WDX2TyFNh3U50Z4qtBofpr9SRoAYKd0NhvMgFPFVp8KX4cL8hd9oHdf/thbAm vAIz+OJYqjb38Q6EPvMBJfd4s6vK74Z9kNBEhTDc2mRONKzQov2qbYP0CbtF4Jbq555O cKhVD6+43ZI/gj8PESbyGxqdlo29SYJIa4e7TsM0J7dfSSq6xFLxap4PegEGlAj7gXN8 N/lWTjZWOstYoEV387/ElIhizeTb8P6kz4Q8k6DpnbyX6etHm/F6ml+d8JohOgIKAFJf AGW8qNNX+DMwvSYTtly/ISzXRJzErZ0BnRZfBOUM40Bby24apn6qeHjG0JAHa3RsLSIw GGqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="r1/326PU"; 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 e9-20020a170906080900b00948ca560e85sor3789114ejd.42.2023.04.22.07.11.26 for (Google Transport Security); Sat, 22 Apr 2023 07:11:26 -0700 (PDT) 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: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 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="r1/326PU"; 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: , 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; } From patchwork Sat Apr 22 14:11:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2864 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 01F8E3F334 for ; Sat, 22 Apr 2023 16:11:30 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-506a455ee4csf2413278a12.3 for ; Sat, 22 Apr 2023 07:11:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682172689; cv=pass; d=google.com; s=arc-20160816; b=qot1OWPjxQgHG+P9dYjgcn8lriGTF3gmXrlBNtB2Mg2lveypGflenLKzxDSVWy38iT bEFOSfOttg4SlymSwhudJslUPc36KZjE4MKGjp+KQ6xw6VrZCnshNFcnYlJ8wtPlS+Ox 1HxFAZOoHUo0ajE3+13cckyCXJ64Bo0B+cxiTVik4/vXpx3byJqpubfUUyH/V/yNPtlY rsZVgyVAKgkVLLKvLbeCodJXD2ABXp2mr/e2/8uQd/sigioLY7+vkro4DrxCbgiDqjRu +OC5j01l9OM8LtwwpD/2tFVnQUYFandRM6vvT35269iw9QyyktR/itRihxXZEK58OtNT 3+OA== 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=HxKWno88YH1zTYmFMiddkc8R6N0uqROX3AtxS7pTIu0H4b4h9+9jR0JbGAzQelESdI FDsKpE8LaMIOhPxWD0fgrFFj9wSWvHOyjiheS24vwHGWWAz4Kl9Mptkwgmlm+HtbrUi5 KniPl8g4V1s1pEfCpS/fzyYT8Q/pgbXqIoHwTOvkoK2NL+fu6LD+Zqt8tSrJ9WOXFuJx iILt6AeMAzDQCQlflOq/qAP+fI02vjsW+NakLVZ0WZoH2k/yu3uTRUkgHhM+w0yexo5X Mx9KHaBet1DSo9aBZuf+KTQC/D/CqEqB+Q+YDv19QXXEarBOgcC8JTA73blgWFGCMZnw wV6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hJMK6db1; 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; t=1682172689; x=1684764689; 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=bLvgSQPUEL+23qr3N56HuEsH6mqQcOqSqF5/BZ2x7DN6/W3bnCmP3FVB64aPKLLsvq Bzue6FA2GUAbfhfp/eCo1n4X9fIQI4i2PIJcase+iYWbHwVZCPyexStVEACpJNjJFWp/ /7ZLbjXLD9pGTzlMtgBdYqRR02H8ETcTahuEg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682172689; x=1684764689; 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-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Vi8Ly+HApIjVbOduJvNlDhRMTkyTKzTyX/5VnJdUjiQ=; b=cKV3jxUlme+jwmloz2nC4EhQjHyvb5/P5jKUQfFgxcldth9TMKunsQKFw7hCbO7Vr+ C7mJYmpebBlDourKXbYN0j9cFVp9MDKT57HbQHND0feV9UrQGM+N0YQvu2FT6RubDuR7 37hLyGc/u7Xz2uer9Mc8oigCTTH57HuB3wqzPrnmkkmeJx3YwPEOWYCtBUHmJeccYaDZ UtqWEzWiEj29Pl5xhEoZgtQ9H8aeFicWYmYljtIe1mazoWFNMjdywHQ7Y6gV7TKCh5AK 7WfuCcMp7OWWNdz4fpK2+9v5UzEzOIrsf2plnZ8kRxWoGWvH4ha/B1hTzauZmhK5Xw/r K7AQ== X-Gm-Message-State: AAQBX9cuQ6kqq+NuaGv/1V4R26zbqdFc7oaSE39kPWTGcyhx0dRX8v8A L1mMoc0QSZq2fyMVcATjP22u/sEK7ZEU3iTN X-Google-Smtp-Source: AKy350aYryPQaMMsQY1MiKwxwO1WOS97omdiL7maXizhHT8exCjVTBO5jaBdag3hYexvZ5ojTTrgIg== X-Received: by 2002:a50:a456:0:b0:502:4c87:7981 with SMTP id v22-20020a50a456000000b005024c877981mr3376926edb.4.1682172689723; Sat, 22 Apr 2023 07:11:29 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:b14f:b0:94e:d85f:f87f with SMTP id bt15-20020a170906b14f00b0094ed85ff87fls5018522ejb.8.-pod-prod-gmail; Sat, 22 Apr 2023 07:11:28 -0700 (PDT) X-Received: by 2002:a17:906:3550:b0:957:12b6:8918 with SMTP id s16-20020a170906355000b0095712b68918mr5064130eja.75.1682172688165; Sat, 22 Apr 2023 07:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682172688; cv=none; d=google.com; s=arc-20160816; b=ZTPoFnT2xQqasBWrU2Ilygm066FV1fgmkcbeFe7LXp3yI6HqNfKQGBqx3TzIwiGbi1 2zcnkijbX64RyahyQj2OiNwUlEngE27B5uhEJ2L9pJUOsM8547r6CcQnnI1yPuyGws3r 29JQGP+wOU8GwOQLV2tpZcS60O1ix1yJgIlI4dGg7JKpEmYhoyn8UWqna/OUnzWmeXKh D3ATyBr9tGl7FoaDWvzohhtUbAsOcbkiJWPStEe35PT+pQ7TAOhClzPBMiD3C/d6j2Ig RaC+MZyHC1bcXRbjnNJnUREByG9jS26SP0AidaAmORuP/D7hvRwFS//VrHkkvQVnKJfP TdYg== 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=drUDFo4tGy+Hswtt21Q7Y7DNjpVwKMlvZygzecTaOV6KXPQckmoyexEiC+PZhQINi7 PS/a6DCh/5WrROvn7c3PHbLtSAVeT7rjEpbYVu5R2N5GJb3s0SlOJwZYNNo9d29Naypa 68lNVi27ghAfdMEL+YPITd52ie26e+oGoQcP8fuTN2/VRQiDhAN154eAxB/lxHUmEafC mRzW1KwDrdB4mesUHzW13s0X22+jTJ6mbkqm6Bk5ysKPQL0zL2EjlgBrbNKiJCG52YC/ IKkebGIpihVGXCCO49KgUoqflkxysHzod4ycg712viAcBmlcXiW3WVMwd2dL/opvXlRf h6hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hJMK6db1; 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 ku20-20020a170907789400b0094f190f46ebsor3860327ejc.32.2023.04.22.07.11.28 for (Google Transport Security); Sat, 22 Apr 2023 07:11:28 -0700 (PDT) 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:35c6:b0:94a:9c9e:6885 with SMTP id p6-20020a17090635c600b0094a9c9e6885mr5071461ejb.58.1682172687850; Sat, 22 Apr 2023 07:11:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 07:11:27 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Sean Anderson , Lukasz Majewski , Dario Binacchi , Fabio Estevam , Michael Trimarchi , "NXP i.MX U-Boot Team" , Stefano Babic Subject: [RESEND PATCH 2/3] imx6: clock: add support to get LCD pixel clock rate Date: Sat, 22 Apr 2023 16:11:18 +0200 Message-Id: <20230422141119.618453-3-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 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=hJMK6db1; 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; From patchwork Sat Apr 22 14:11:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2865 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A0FCA3F334 for ; Sat, 22 Apr 2023 16:11:31 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9532170e883sf305172166b.3 for ; Sat, 22 Apr 2023 07:11:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682172691; cv=pass; d=google.com; s=arc-20160816; b=CgUR0P2LtlbkPPqm0IjDy7dbXjs/ZKB29nvIhsLGUt0k6ekY2XSom7Jksc2PGFuugX qOcSu/RiO+DbAMOB/sOISDHXMja7GyTvCtb+VJ+59mePCCIcc3MS4TP/6boVQN+O1BpX db+irZ8gHeJTg0+j7p2KeT+N5SzqZhkRRQA+D5t+flAEqCyzbQoCkO+tXvYU6Q6NjGxw zyO6teXgDx7CEsLyET3dLW3C9hWJdTkCmnj8xib1i8nrlnN6gAgLb808a1aZz4dialNy xoQstpMp6AwSTk2PaCTSV0aFDjsNXj5ZDqAmSZ9Ybz2fK7j4JnPHv7rWC6bl3SUOCW+A ogJg== 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=0UlzovGeaHx1CRlnbQUGXCJzm4DyxE47yyD7nrCSGes=; b=g280qLsmktN5VFmlLTEfr9qCn6B9HaQ5OhKX77ittA9XyEshXXGcFgBwr7lUSm2bYs OElONNz4H+5rMgpHR6HeeOvbVBuWgWjinXCx3L87K4dOQmmWGxkWKZhM41FlkG7FORXl 0iLUimo1Rml5XQNJSsmQu7AUXMNVJvbQ0audetqbjxIw7YEwNj2x3y4rmg2pM4DkmYTT zfFFa/cBNJQb4OV6ok+sM7i/OTqahMo4dAFOne9bO+Qe65xoYhVy9oE1FVlbNwMPBHFX 9dsn0EPhntIZuizDUwW1V56Vzfvp164pb9jgos6rhlY+yBet2HUBz7H6t7yYy6orly0T uCYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UyN5d9Iq; 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; t=1682172691; x=1684764691; 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=0UlzovGeaHx1CRlnbQUGXCJzm4DyxE47yyD7nrCSGes=; b=OZyn4KEcdy9Z9np427v9sYwcDND86LavQTBShrDcVKGXgOA7pymqlzDojG/gyMzUxf 6q90FETAekfGapl1tNqupyqwW6IFyP9SVAOSpnA7RK9SUtBXfo1AqGCIUQgbIoXJxTRM 6iblYtWRHCS7sot28P9PJOfQSBfXH/vrwYDl8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682172691; x=1684764691; 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-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0UlzovGeaHx1CRlnbQUGXCJzm4DyxE47yyD7nrCSGes=; b=Kw0qULmwCawQ5j4kO1lm3VQ3j2jADzq8he+4CGaCQc1gCDdkJk7q+IJIXJQl045zsS 5m8aOPUiqHGGd2hT2X+WA/QXIZHkIe7MBvfl6gYdtWyPx62JwJQJofcloj3BzFG8CJ5e sOzt588nIMWHc97UWqCwezNuuF1lOl+g8ia2AJuqM+JMWqdUYB+QIZr5dRiEYoSyRSG3 O6KgZXFRFwBn4nkiWaJYrZ4gSEtG+cetiR4leBZUcJecf+xrA8nTR7bkRRRerw/5ZoG7 e1LfJ3gHXQoQ75PlQ+Ve7MSbzH49Pi6qdKgIGq3X29PhWMOkp5IXHLoeUOeQRLZiubyN PspA== X-Gm-Message-State: AAQBX9dYwd5mT2gQrCOAWPAERkJ3DRdo5KPEs5zC002m3bv7OrGJyoe2 A8zRz/O0RjYU4lsAhBwYZn5RNdrh X-Google-Smtp-Source: AKy350YV41QKvvytxlotJXSQeFnoRu8UZU/WjbhdQsdeLODZjFxa5GHsCIXZaRX7PKpqMuURjgcRng== X-Received: by 2002:a17:906:6b83:b0:953:8cab:aadf with SMTP id l3-20020a1709066b8300b009538cabaadfmr2325970ejr.7.1682172691344; Sat, 22 Apr 2023 07:11:31 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:3099:b0:94e:cd76:edae with SMTP id 25-20020a170906309900b0094ecd76edaels5033285ejv.1.-pod-prod-gmail; Sat, 22 Apr 2023 07:11:30 -0700 (PDT) X-Received: by 2002:a17:906:b314:b0:94f:3521:396 with SMTP id n20-20020a170906b31400b0094f35210396mr5287167ejz.23.1682172689528; Sat, 22 Apr 2023 07:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682172689; cv=none; d=google.com; s=arc-20160816; b=tNKWeV4PLJbvYU4kt4VjqGgboJa+5wznfJU7jRdvpuVhthlwsPrTK/HORUJqIvBO5/ E8hFMrFAB5m8EcK+GwFcXPpwtNoMuCA2rzdC1myDLuieHMRDPCAdZqFfbdJ4gkVmXcv7 /ke7qJptzf1wNjKP4E/ETgAvMHCYiaZgP5o2hdbK2iUQ2YVZuqh9TfOa55leL9+rmoqO JnXPjTwUw553A95DqafyEaDMLtOQhzL94++xg4wy+7SLqjrxjpJpkbgtgPFfTyPeIdEY ENJigtczmoq990NfuWwgPDUwDjE+eCVk6T6yhKEQvMKOaEVF61RROY3duwiffJZwhihr hHuA== 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=me4F0JM7Jds27bWvbPrAN/z1URpB4mxVWlTiCV6oeRE=; b=HFEBHNLZHvLAqgApM7R+QkFQIwStP1YCNSPyAM0QZc+WloAhdZxP5DnyeVJyJI89ce ocwjSGYnw+sPLVJYpsmV/40z2rodUwK9l4aRmyxmF1cYP5viDWvxLS1ARqMy4C0wq2k8 9O2jGhtkOx2n7pUhAlQ3iQPMKAp6eJkCU/B3mvqAZ+dqdI1i/AxcVaXP6Dwh66EMwR4G VJpd4lVLFcakWvbeKQSNDAh5rgvbElL7ssNQJGTpCubtE1VdOqT/T5qAXU2rcU/AC+XE g/rBw+M7vRJnq2cyKJBj7fNS5K0Y8hoW/d4qnxj9GFxMOAYnN19Kkd8VNXRTg5vko1O8 2jEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UyN5d9Iq; 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 w24-20020a17090652d800b0094effdbe375sor3849002ejn.136.2023.04.22.07.11.29 for (Google Transport Security); Sat, 22 Apr 2023 07:11:29 -0700 (PDT) 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:1114:b0:94f:3f92:c7b0 with SMTP id h20-20020a170906111400b0094f3f92c7b0mr5271242eja.60.1682172689193; Sat, 22 Apr 2023 07:11:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 07:11:28 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Sean Anderson , Lukasz Majewski , Dario Binacchi , Fabio Estevam , Michael Trimarchi , "NXP i.MX U-Boot Team" , Stefano Babic Subject: [RESEND PATCH 3/3] imx6: clock: print real pixel clock rate Date: Sat, 22 Apr 2023 16:11:19 +0200 Message-Id: <20230422141119.618453-4-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 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=UyN5d9Iq; 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 debug messages to print the real pixel clock rate, which may not be the requested one. Signed-off-by: Dario Binacchi --- arch/arm/mach-imx/mx6/clock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-imx/mx6/clock.c b/arch/arm/mach-imx/mx6/clock.c index 267d86ab4194..1bdc568f9b14 100644 --- a/arch/arm/mach-imx/mx6/clock.c +++ b/arch/arm/mach-imx/mx6/clock.c @@ -802,6 +802,7 @@ void mxs_set_lcdclk(u32 base_addr, u32 freq) } enable_lcdif_clock(base_addr, 1); + debug("pixel clock = %u\n", mxc_get_clock(MXC_LCDIF1_CLK)); } else if (is_mx6sx()) { /* Setting LCDIF2 for i.MX6SX */ if (enable_pll_video(pll_div, pll_num, pll_denom, post_div)) @@ -823,6 +824,7 @@ void mxs_set_lcdclk(u32 base_addr, u32 freq) MXC_CCM_CSCMR1_LCDIF2_PODF_OFFSET)); enable_lcdif_clock(base_addr, 1); + debug("pixel clock = %u\n", mxc_get_clock(MXC_LCDIF2_CLK)); } }