Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp738738rwr; Thu, 27 Apr 2023 07:35:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xKlkEsbsybYErXxZPh/GYHVBoaDCY/nSmjB9kp+PrEDCJN+56uq1cQIY8xsf+oAMe2PMn X-Received: by 2002:a05:6a00:e13:b0:634:c6b9:92e4 with SMTP id bq19-20020a056a000e1300b00634c6b992e4mr2409276pfb.0.1682606130769; Thu, 27 Apr 2023 07:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682606130; cv=none; d=google.com; s=arc-20160816; b=L8hvP5DMrJT/0pLEyW6osvQGYKTMhGd8iqmJ2MhT3L1aRNkyuyQ5KlJgBCBXl3TAvR jFnmTgZ3QS6chzBd21z4yR7RFAMmJu1clzI+Uyeq0PvuZEwdeDR4yah6i1HjE6HsVSOC gvxPwexz8YI/fexf7r6WKlxH4N1QvWRy6kooJshATO+JqJBiOl6LoHykFf7upzxue6Fe GgfmPCKl8OB9fJ/Kgx9JlpQGzWESFKuJRYI4A2JvfpyRaqhQXamCFLqzr+WrxiOKvNE3 l//KfAGFUGLr67sJOoGhBZKHFlXiss4gk1ZewhYiEUT/mWfzbMHXpL794zVBa4IQ3CNf 3wJw== 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=Hl7096BnkwEapAhbq31wcet5x7WYvlPHlve+gXUB/0c=; b=X72gdXbmlDNiGGHLjereAFbR0wYcEQcfoUPIa4Ap9HGPh2PMWp1+6CaKfrRi7nirKG stqsAOmtCBI6FVuNw7ixtsdUI/d4biQu/xNV/CWGTFTfwkBpOBH5Trf/d8ntiHr1v2y/ GwCzfkNsNS4vIwPiBlIMv2sRJGJ64c/LROhIxf0KIszGklyvtqNous4dQ3ZRJNueaX8k DkwyafNxh2cUKvrZ5wBtUnKC1BgHWxrbe9pgI9nRKjwNqzUqCGqMiCed5/40h3k7I7B7 jcg/l5eh635ONiEz79RNJC2jZD1A5Uvq9a461sYuy0B6BmdnRpyOssI2Yn7Hfl1fAqWp azUw== 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 h4-20020a056a00000400b0063b8685bab4si19051693pfk.113.2023.04.27.07.35.15; Thu, 27 Apr 2023 07:35:30 -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 S244129AbjD0ObB (ORCPT + 99 others); Thu, 27 Apr 2023 10:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244114AbjD0Oa1 (ORCPT ); Thu, 27 Apr 2023 10:30:27 -0400 Received: from mail11.truemail.it (mail11.truemail.it [IPv6:2001:4b7e:0:8::81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E970A449D 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 3F96D20B59; Thu, 27 Apr 2023 16:29:42 +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 6/9] drm/bridge: tc358768: fix THS_ZEROCNT computation Date: Thu, 27 Apr 2023 16:29:31 +0200 Message-Id: <20230427142934.55435-7-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_ZEROCNT register. This register must be set to a value that ensure that THS_PREPARE + THS_ZERO > 145ns + 10*UI with the actual value of (THS_PREPARE + THS_ZERO) being ((1 to 2) + 1 + (TCLK_ZEROCNT + 1) + (3 to 4)) x ByteClk cycle + + HSByteClk x (2 + (1 to 2)) + (PHY delay) with PHY 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 360c7c65f8c4..36e33cba59a2 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -760,9 +760,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) /* 40ns + 4*UI < THS_PREPARE < 85ns + 6*UI */ val = 50 + tc358768_to_ns(4 * ui_nsk); val = tc358768_ns_to_cnt(val, dsibclk_nsk) - 1; - /* THS_ZERO > 145ns + 10*UI */ - val2 = tc358768_ns_to_cnt(145 - tc358768_to_ns(ui_nsk), dsibclk_nsk); - val |= (val2 - tc358768_to_ns(phy_delay_nsk)) << 8; + /* THS_PREPARE + THS_ZERO > 145ns + 10*UI */ + raw_val = tc358768_ns_to_cnt(145 - tc358768_to_ns(3 * ui_nsk), dsibclk_nsk) - 10; + val2 = clamp(raw_val, 0, 127); + val |= val2 << 8; dev_dbg(priv->dev, "THS_HEADERCNT: 0x%x\n", val); tc358768_write(priv, TC358768_THS_HEADERCNT, val); -- 2.25.1