Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp737670rwr; Thu, 27 Apr 2023 07:34:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ELuRFirZMb82EubqETAuVpEJi1jiydI9QeXdXijNaszi8ZxP4fHiLW7m0Dv9TXLRA7ieY X-Received: by 2002:a17:902:da85:b0:1a1:956d:2281 with SMTP id j5-20020a170902da8500b001a1956d2281mr2143797plx.3.1682606081954; Thu, 27 Apr 2023 07:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682606081; cv=none; d=google.com; s=arc-20160816; b=qPE/K6sRLmYUn5x0NKZ7Pho4otPNR0UkusUa07i4Bi+ACFGO8QHmJrb3uzXUiRDgv5 P7wDE4wXD32bQevlFS9uZkkd9A/1LnnDrvAjAh+EEe+C2YjK1KyFyl/6DGh9ouxnOdMC x0ggF5/WeGN1mTR2skSNVmZBu7/GFN3BYJusmNCiLfHPvs3ci5d+ZWSqh8O+Lxf2ppXH 6IoOygJl0sgKVK8L9dgVLdlD3E8lmaN/SG66rMqj36bMBdp8x55o5MI74hLPOFcD8Iy1 GQ3rLmEdSOebCXufTOruQL735H2ULDThK7PIMkQWgA+Q0psgQt+SnXmSsCoduboZ2mm9 w7nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AgCbS65Z6arsdaarFfPoTaGN82Mu54ilD1aXoRZPAFY=; b=v2o13RWEJiuGvJWgsui1fdLIKXsBHiJjxY8pLlXdqebs8fCu/WhHk9jfvMdslMwhmr UfdyI7hzecs5SU1LUbi1y024qBVGPd4GiS/2VYuw8aHbJ2OoT50R/vWEiTmlXyJYcDE3 eoZdSD3pOkXNzvsCJafd0s80zKMfx0DDW3Gpxa0AR0FNxbFRXpbiavCR0g/lfN79toQL DopaYQkdOpxksUGmq/Fof3LMQoIdB3m5fT4mtz04XwEpqAdvTobfz73a8/GiCwNk5zmg /4xTW53BAHt4N4Umz09WiuupBfuyGamrraZ0ig7b01O48f8qt5MCUi+tXgHcWsuH2FKM vgAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v6-20020a63f846000000b0051b58fc93b3si19456902pgj.223.2023.04.27.07.34.24; Thu, 27 Apr 2023 07:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243793AbjD0Oaf (ORCPT + 99 others); Thu, 27 Apr 2023 10:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243431AbjD0OaT (ORCPT ); Thu, 27 Apr 2023 10:30:19 -0400 Received: from mail11.truemail.it (mail11.truemail.it [IPv6:2001:4b7e:0:8::81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BA685BB2 for ; Thu, 27 Apr 2023 07:29:44 -0700 (PDT) Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id C28EC20B57; Thu, 27 Apr 2023 16:29:40 +0200 (CEST) From: Francesco Dolcini To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , tomi.valkeinen@ideasonboard.com, dri-devel@lists.freedesktop.org Cc: Francesco Dolcini , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Subject: [PATCH v1 3/9] drm/bridge: tc358768: fix PLL target frequency Date: Thu, 27 Apr 2023 16:29:28 +0200 Message-Id: <20230427142934.55435-4-francesco@dolcini.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230427142934.55435-1-francesco@dolcini.it> References: <20230427142934.55435-1-francesco@dolcini.it> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Francesco Dolcini Correctly compute the PLL target frequency, the current formula works correctly only when the input bus width is 24bit, actually to properly compute the PLL target frequency what is relevant is the bits-per-pixel on the DSI link. No regression expected since the DSI format is currently hard-coded as MIPI_DSI_FMT_RGB888. Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver") Signed-off-by: Francesco Dolcini --- drivers/gpu/drm/bridge/tc358768.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c index e9e3f9e02bba..dba1bf3912f1 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -146,6 +146,7 @@ struct tc358768_priv { u32 pd_lines; /* number of Parallel Port Input Data Lines */ u32 dsi_lanes; /* number of DSI Lanes */ + u32 dsi_bpp; /* number of Bits Per Pixel over DSI */ /* Parameters for PLL programming */ u32 fbd; /* PLL feedback divider */ @@ -284,12 +285,12 @@ static void tc358768_hw_disable(struct tc358768_priv *priv) static u32 tc358768_pll_to_pclk(struct tc358768_priv *priv, u32 pll_clk) { - return (u32)div_u64((u64)pll_clk * priv->dsi_lanes, priv->pd_lines); + return (u32)div_u64((u64)pll_clk * priv->dsi_lanes, priv->dsi_bpp); } static u32 tc358768_pclk_to_pll(struct tc358768_priv *priv, u32 pclk) { - return (u32)div_u64((u64)pclk * priv->pd_lines, priv->dsi_lanes); + return (u32)div_u64((u64)pclk * priv->dsi_bpp, priv->dsi_lanes); } static int tc358768_calc_pll(struct tc358768_priv *priv, @@ -426,6 +427,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, priv->output.panel = panel; priv->dsi_lanes = dev->lanes; + priv->dsi_bpp = mipi_dsi_pixel_format_to_bpp(dev->format); /* get input ep (port0/endpoint0) */ ret = -EINVAL; @@ -437,7 +439,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, } if (ret) - priv->pd_lines = mipi_dsi_pixel_format_to_bpp(dev->format); + priv->pd_lines = priv->dsi_bpp; drm_bridge_add(&priv->bridge); -- 2.25.1