Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp739949rwr; Thu, 27 Apr 2023 07:36:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4l3S6dfeMpxV0gqUaGLqNWmckX79U98iucxSocZlfsaxhZuNoqljnyoKbP0M+eijBN/Ol3 X-Received: by 2002:a05:6a20:7f84:b0:f6:9492:93a6 with SMTP id d4-20020a056a207f8400b000f6949293a6mr2115117pzj.4.1682606186258; Thu, 27 Apr 2023 07:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682606186; cv=none; d=google.com; s=arc-20160816; b=bsd+xdi/+1vSLyWAYLGHe6GyiU/52W5TxXYwhgeTRjW4VfliafIVi+pFBT2Zoa2Cgp l8PeV8UCYJIf367cJWU73feozRb50QrI0wHITXSN2Ev37GZB7oRwkKjeQYchYOVq+u6+ QaMo6kEM+ZMmZxSbozfLj+G0NieofjiI2+xNQc78VrkMN3io698O+R10Z8jGKF2YJq6E kC0aTyX+PF0fcr75CJrAjsOr8Py6M3dgN2JGM9B/B9SQPi9Bdz5gYY1ozFV1KwmvpcUg O6ogOSWFhIiJASL8efDYTzGxQjFEDU9eHuHx+btaH5kiF5RmGWiPQMETPLZG9ToCxDW1 0ESg== 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=DhAtpAOd2+BV94COvDxYtDubOQa6dzIjkLLxNNJO44M=; b=nwfcNGXMLIdEfMGeeHQ7W+dKKH5x54tc8mjkRm7e0QaHlfaTAHjqwNC5d4WufGZ5w8 EucS1/NIYv2IWwAzF5VvU3H33mpiDRIzYLZmNEdFxLDvtVf5jb+qAgHq72dv0Slad420 LdQQRS1buol9Xz9CUxIHywp4U7namWnfpo+dXmy1RGMDRODQswlHwKI8/psQ00CzwUB0 fui9Cm+6uqlZHvEDaW+JSXWgx8n32GQFgp15B+RT90xdNZkVbpNuna1Bg0zSVC6OvUEW SJv8OvmF7BKn5D3pMxinjA67sXaOsjQAghX0DO3Vq3ch3X4KmF5vImuwrAQ8qilpXdso 7rAA== 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 85-20020a630758000000b0052132a8e4e3si19635642pgh.510.2023.04.27.07.36.13; Thu, 27 Apr 2023 07:36:26 -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 S244173AbjD0Oaq (ORCPT + 99 others); Thu, 27 Apr 2023 10:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244099AbjD0OaZ (ORCPT ); Thu, 27 Apr 2023 10:30:25 -0400 Received: from mail11.truemail.it (mail11.truemail.it [IPv6:2001:4b7e:0:8::81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0D346B1 for ; Thu, 27 Apr 2023 07:30:19 -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 2F95C20B61; Thu, 27 Apr 2023 16:29:43 +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 8/9] drm/bridge: tc358768: fix THS_TRAILCNT computation Date: Thu, 27 Apr 2023 16:29:33 +0200 Message-Id: <20230427142934.55435-9-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 Correct computation of THS_TRAILCNT register. This register must be set to a value that ensure that THS_TRAIL > 60 ns + 4 x UI and THS_TRAIL > 8 x UI and THS_TRAIL < TEOT with TEOT = 105 ns + (12 x UI) with the actual value of THS_TRAIL being (1 + THS_TRAILCNT) x ByteClk cycle + ((1 to 2) + 2) xHSBYTECLK cycle + - (PHY output delay) with PHY output delay being about (8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion. Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver") Signed-off-by: Francesco Dolcini --- drivers/gpu/drm/bridge/tc358768.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c index 854fc04f08d0..947c7dca567a 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -779,9 +779,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) dev_dbg(priv->dev, "TCLK_POSTCNT: 0x%x\n", val); tc358768_write(priv, TC358768_TCLK_POSTCNT, val); - /* 60ns + 4*UI < THS_PREPARE < 105ns + 12*UI */ - val = tc358768_ns_to_cnt(60 + tc358768_to_ns(15 * ui_nsk), - dsibclk_nsk) - 5; + /* max(60ns + 4*UI, 8*UI) < THS_TRAILCNT < 105ns + 12*UI */ + raw_val = tc358768_ns_to_cnt(60 + tc358768_to_ns(18 * ui_nsk), + dsibclk_nsk) - 4; + val = clamp(raw_val, 0, 15); dev_dbg(priv->dev, "THS_TRAILCNT: 0x%x\n", val); tc358768_write(priv, TC358768_THS_TRAILCNT, val); -- 2.25.1