Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1406724lqh; Mon, 6 May 2024 07:00:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWy+8CYt7CI5ljcORZREIbN8web0WUiqC06q5HKWwYmvJe1KnF4m+lnELdWwndu4Zb4jYzrJM+rEmmOlqEYMzX44wT+6vkPwoaZiued/A== X-Google-Smtp-Source: AGHT+IHaCtNMrnzbU98PGB3Fk799TxBoSE7scepZOWZieaJCSI/yaTvVp000dIUSRG7HpdBofyJE X-Received: by 2002:a05:6a00:a05:b0:6ea:bf1c:9dfd with SMTP id p5-20020a056a000a0500b006eabf1c9dfdmr14650072pfh.27.1715004043892; Mon, 06 May 2024 07:00:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715004043; cv=pass; d=google.com; s=arc-20160816; b=ch02fYnzp3yZiygAjF5RinFavxrWBVq2ZRUSKKjJuL+Ba1Op2L96dF2PgEay/Aas21 r0FtbnDDOrBmXhGzjg/wtUoVPpdusBfxpFQJ8m+IPJJUQCOykNDtJxPKAmI3HgIDQsNB O1f3xtoGc42N/eSJhAef8TJzXPIakD9i1OIlkxKDUQUr9oYsKhdmeGD02NsXrZsXskH3 dORMbuTHkg+rCm1sPUU3h+rNG4JItg8LvoAhWla4596zZLyAZ3SGkYBwGPG2eXw2uQqg nsgyeMU2XPueWNAYS7r6plHK9ozoqmad1H8l4P0uUE89kvJqxl+vFxhmFF548ZcqnC6w +ChA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=9XSMUdIH/xbrKSJ/1FY3kzcDlUdNOj3PZQCySZMGJPo=; fh=SuRMajwH7N2ZLVBLirbkCwTFKIhKCObxyHKAw4nU6hQ=; b=XBzMAOn4R4Uut4W/xvdWUFIfz5UsC+X95PfbppyyaM0NrQmLeyQ68Cty9vacBL6dry 3Jj4bRly4R++hb0C1IRciMhyWR1nl/iyge3jtHcr4vbe/BDgku/x4bi0bayeOzVR7Hn5 1GjafmFhaQB9sHq8/kJvAWgd7KdMAwBxNk0JrKUCRSPnU7J2D1kAZFjhkJ/CjM9HOgEy D+B1xxxHeVwOcTF2+FdgXR9F0yZvAbt7FRvNVx61vWQSBP7FBQMlATQ7U+BiZU/gOnIO 3iyKxiRLI+AcUlCbdepd8sFrTAfZyAGTbIMTM7kYhK410LFJ+O8IvLGvLGAMm3Ul0mOz hYzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h9hLaZa9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169905-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169905-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l131-20020a633e89000000b0061d147fd37esi6923285pga.893.2024.05.06.07.00.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 07:00:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169905-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h9hLaZa9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169905-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169905-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6EA93B279A4 for ; Mon, 6 May 2024 13:38:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E43C78C97; Mon, 6 May 2024 13:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h9hLaZa9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC43C78C89 for ; Mon, 6 May 2024 13:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002547; cv=none; b=COWxCp/Oji4HNfAVtv3E6C0CL3fZlPxkoBZ9cPXX3T4oP1B6q0CrJw8z5LSoZXxtOk5cRusQ1OW/vGM3UI9vNg7LynZeuqWgC8F7xNIA9AkxNZa3JX5YQUlxSYXp/Yx8z9jW6cLyXwJTXQA9AQBCi7lbHON+oavQJTwV8dwUDNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002547; c=relaxed/simple; bh=gBI1ftlJZK9GLIPJr/NbCBA/Qls8YZkI0rH9liGw82E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TjN/wzv7y6+WMqIoq03Gs0RaotAGVqLxqQK9dSI6Owr3bFgxz7TX7NmJu4le8mGuEaYQfoccN6ZUdF04hnuRnqJeJ5snKsgbQmMJqlEc20BsmNy7Eavo5qmO1jfibuwIaiPJjitmpKt7xoKtqI1a05h+u8Uuy+25k+I98Ltp2NE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h9hLaZa9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB2EAC4AF67; Mon, 6 May 2024 13:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715002547; bh=gBI1ftlJZK9GLIPJr/NbCBA/Qls8YZkI0rH9liGw82E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=h9hLaZa9H6GjxzIZRfYYsRrPiaEmUBLgk6uaHxdbdFwp22Q8cgdEsaIYiY/Rf9Ypn lKfCsi5ROojUiHyhphcOKtuGgMn09uF3w7sGI7DHHmw2wJfmOSWNqILS6JyTqtR9mI vTuU+4CE27bz6NZqk7YLmD41xVHbRzFLlUmbvDv8txUgLoEyF8D9AvcZ7zPiVB+ui8 TvBIrBVQR0u5CFL8Bwl8nowBUbU/Ns+7KxHFwvblEdcotqt5Gym8KN1BTbu6g1+FR8 AGjo26xCkv+3PXBt4SaWMbcRwgdKOz6aL0v5qHB8opihXv97Ht6PM7oKtG2bMOFK4c cxXwl1Tzm7rXg== From: Michael Walle Date: Mon, 06 May 2024 15:34:38 +0200 Subject: [PATCH 09/20] drm/bridge: tc358775: remove complex vsdelay calculation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240506-tc358775-fix-powerup-v1-9-545dcf00b8dd@kernel.org> References: <20240506-tc358775-fix-powerup-v1-0-545dcf00b8dd@kernel.org> In-Reply-To: <20240506-tc358775-fix-powerup-v1-0-545dcf00b8dd@kernel.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Sam Ravnborg , Vinay Simha BN , Tony Lindgren Cc: Daniel Semkowicz , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Michael Walle X-Mailer: b4 0.12.4 To cite the datasheet on VSDELAY: During DSI link speed is slower than that of LVDS link’s, data needs to be buffer within 775XBG before outputting to prevent data from underflow. Register field VPCTRL[VSDELAY] is used to for this purpose This driver assumes that the DSI link speed is the pixel clock (as does every DSI bridge driver), after all the LVDS clock is derived from the DSI clock. Thus we know for a fact, that the DSI link is not slower than the LVDS side. Just use the (sane) default value of the bridge and drop the complicated calculation here. While at it, replace the TC358775_VPCTRL_MSF() and TC358775_VPCTRL_OPXLFMT() inline functions by the usual macros for a bit flag. Signed-off-by: Michael Walle --- drivers/gpu/drm/bridge/tc358775.c | 49 +++++++-------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c index 54aea58a3406..a9d731e87970 100644 --- a/drivers/gpu/drm/bridge/tc358775.c +++ b/drivers/gpu/drm/bridge/tc358775.c @@ -109,7 +109,9 @@ #define RDPKTLN 0x0404 /* Command Read Packet Length */ #define VPCTRL 0x0450 /* Video Path Control */ -#define EVTMODE BIT(5) /* Video event mode enable, tc35876x only */ +#define VPCTRL_MSF BIT(0) +#define VPCTRL_OPXLFMT BIT(8) +#define VPCTRL_EVTMODE BIT(5) /* Video event mode enable, tc35876x only */ #define HTIM1 0x0454 /* Horizontal Timing Control 1 */ #define HTIM2 0x0458 /* Horizontal Timing Control 2 */ #define VTIM1 0x045C /* Vertical Timing Control 1 */ @@ -187,30 +189,6 @@ enum { #define L0EN BIT(1) -#define TC358775_VPCTRL_VSDELAY__MASK 0x3FF00000 -#define TC358775_VPCTRL_VSDELAY__SHIFT 20 -static inline u32 TC358775_VPCTRL_VSDELAY(uint32_t val) -{ - return ((val) << TC358775_VPCTRL_VSDELAY__SHIFT) & - TC358775_VPCTRL_VSDELAY__MASK; -} - -#define TC358775_VPCTRL_OPXLFMT__MASK 0x00000100 -#define TC358775_VPCTRL_OPXLFMT__SHIFT 8 -static inline u32 TC358775_VPCTRL_OPXLFMT(uint32_t val) -{ - return ((val) << TC358775_VPCTRL_OPXLFMT__SHIFT) & - TC358775_VPCTRL_OPXLFMT__MASK; -} - -#define TC358775_VPCTRL_MSF__MASK 0x00000001 -#define TC358775_VPCTRL_MSF__SHIFT 0 -static inline u32 TC358775_VPCTRL_MSF(uint32_t val) -{ - return ((val) << TC358775_VPCTRL_MSF__SHIFT) & - TC358775_VPCTRL_MSF__MASK; -} - #define TC358775_LVCFG_PCLKDIV__MASK 0x000000f0 #define TC358775_LVCFG_PCLKDIV__SHIFT 4 static inline u32 TC358775_LVCFG_PCLKDIV(uint32_t val) @@ -350,7 +328,6 @@ static void tc_bridge_enable(struct drm_bridge *bridge) u32 hback_porch, hsync_len, hfront_porch, hactive, htime1, htime2; u32 vback_porch, vsync_len, vfront_porch, vactive, vtime1, vtime2; unsigned int val = 0; - u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay; struct drm_display_mode *mode; struct drm_connector *connector = get_connector(bridge->encoder); @@ -398,27 +375,17 @@ static void tc_bridge_enable(struct drm_bridge *bridge) /* Video event mode vs pulse mode bit, does not exist for tc358775 */ if (tc->type == TC358765) - val = EVTMODE; + val = VPCTRL_EVTMODE; else val = 0; if (tc->bpc == 8) - val |= TC358775_VPCTRL_OPXLFMT(1); + val |= VPCTRL_OPXLFMT; else /* bpc = 6; */ - val |= TC358775_VPCTRL_MSF(1); - - dsiclk = mode->crtc_clock * 3 * tc->bpc / tc->num_dsi_lanes / 1000; - clkdiv = dsiclk / (tc->lvds_link == DUAL_LINK ? DIVIDE_BY_6 : DIVIDE_BY_3); - byteclk = dsiclk / 4; - t1 = hactive * (tc->bpc * 3 / 8) / tc->num_dsi_lanes; - t2 = ((100000 / clkdiv)) * (hactive + hback_porch + hsync_len + hfront_porch) / 1000; - t3 = ((t2 * byteclk) / 100) - (hactive * (tc->bpc * 3 / 8) / - tc->num_dsi_lanes); - - vsdelay = (clkdiv * (t1 + t3) / byteclk) - hback_porch - hsync_len - hactive; + val |= VPCTRL_MSF; - val |= TC358775_VPCTRL_VSDELAY(vsdelay); - regmap_write(tc->regmap, VPCTRL, val); + regmap_update_bits(tc->regmap, VPCTRL, val, + VPCTRL_OPXLFMT | VPCTRL_MSF | VPCTRL_EVTMODE); regmap_write(tc->regmap, HTIM1, htime1); regmap_write(tc->regmap, VTIM1, vtime1); -- 2.39.2