From patchwork Tue Aug 22 16:19:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 136592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3810767vqi; Tue, 22 Aug 2023 11:24:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfhqiAuJp1j1a0yOnuK/KTZnmIYK0IrxzY9kSCW5GcxKi2sSAeIHAP33ggReQrPEo+qlRF X-Received: by 2002:a17:903:32ce:b0:1bc:2d43:c747 with SMTP id i14-20020a17090332ce00b001bc2d43c747mr13575141plr.38.1692728683332; Tue, 22 Aug 2023 11:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692728683; cv=none; d=google.com; s=arc-20160816; b=0xqCMSh/iuyDoNFaVldcHH96S5s03ESGFVCJD7clOzt0t7xH1r/VRw0bDnMuicW/sf yLiKPHGKW6ZyOnSWCTSKc+Wpusm6BZNBfgNhAMztYbca7iltORy8hIHfacHcJ1Qb6T+a +5zOXuePxITh11+i/Gu7gSeDeOEb16V16tW1o8wTLIXeh/dbqUgxlMFMxfb7ymlteDHu owvsfeC7+jXfaGUVmacXone1W7qUzg3OK9Z8a+fOtMLoYCAS3FnE9caYaI+V3owsYhhH ZacZirspPAN7Wa7cyXkd+ZSK6NXOXP/y+mLKLXRtl38k6URcKY4Vm0bJxdR42F8xP5dN aqfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ylKK4O2SutIbtf7nNpZ0+vCaI5X5gZQGumseaf03HIo=; fh=lPlKf1PhZKgmDKmNHoLwviSf3cvO+AJgrT68RUEi/pE=; b=Rix05YnmC0UcDheHlyRM1Le0tD63n/1nG4r9H//HyJ/jsLUVsuK2VYRDyKLDbS+MKw XR8+jeJ/y/O6iSf2l7kc6K27GoymoK4KDJSQnOU34Xz9zgIY8V7gb+I+I9Ni8iaZUYXl UY7bqzstJ/uIcxQCJ+57ZHNDqfPGXwwqvuRddZLKO98v+WSzMJU5WgFW1oQrlXF9mVyb fUlFkoZcVdV7tgEje2IoK0xWWiWaCyw0fF6tcruVE7w22NwgY3a2fsb92kv5aUqyXrUQ nL4FJy8zFKTEmoQTJf8as4QmgECvRWGgJCQHFvTltQ9KPaj7cilNXbhwchue+MPJOvb0 qTRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X9hYlW9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q3-20020a17090311c300b001b9d335180dsi10028832plh.618.2023.08.22.11.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 11:24:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X9hYlW9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6E7303DF9A; Tue, 22 Aug 2023 10:23:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237743AbjHVQUa (ORCPT + 99 others); Tue, 22 Aug 2023 12:20:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237713AbjHVQU0 (ORCPT ); Tue, 22 Aug 2023 12:20:26 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B9A5CF0 for ; Tue, 22 Aug 2023 09:20:12 -0700 (PDT) Received: from [127.0.1.1] (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BB48F396B; Tue, 22 Aug 2023 18:18:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1692721133; bh=dfvDuc3+OJeVTyiiwUXOv9K+PGAuzxd6tO3qEoOctDw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X9hYlW9Xjwzwq7eUrYJUdv2nx73lICt9qbFKSviUXdrtQxWkZRWlhUU7eN6uTvs8q Jo9rGSiDCNFP64aFiWBJrr82/y9F4RmOPh2n7r1UvlcufWbq1tK4p+g0Dn2mr0NgHJ I5iCwglI204JlZsZVfqx4gCHTZMStNAL7dSoHFlY= From: Tomi Valkeinen Date: Tue, 22 Aug 2023 19:19:42 +0300 Subject: [PATCH v3 09/12] drm/bridge: tc358768: Rename dsibclk to hsbyteclk MIME-Version: 1.0 Message-Id: <20230822-tc358768-v3-9-c82405dac0c1@ideasonboard.com> References: <20230822-tc358768-v3-0-c82405dac0c1@ideasonboard.com> In-Reply-To: <20230822-tc358768-v3-0-c82405dac0c1@ideasonboard.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , =?utf-8?q?P=C3=A9ter_Ujfalusi?= , Maxim Schwalm , Francesco Dolcini Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Aradhya Bhatia , Tomi Valkeinen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7362; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=dfvDuc3+OJeVTyiiwUXOv9K+PGAuzxd6tO3qEoOctDw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBk5OAt7iW4LNztF4KjC75OeOjaYehOdMGnRvedl KUHh+2ZEfqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZOTgLQAKCRD6PaqMvJYe 9Q2ZD/49qnm8OXtFtT5rjgwLRzX9ldGBSxmibb655ooYOEcNpS34mbF9gPQXgJDNFY67/Cz7bQ9 6ou77Zy6+WedlkwwCPP/GJgzO0kQ6+7vyIRaL1QvURNgYwbCItvZE/phhsk0x4eK9D9NoeUsvqD NBd5Ejm+BZ+RHhTIbA7OxhHAU8L9ZuCszLy4IoTAh7Hu6yX/VNJyiNYePeY3OfihdW+xkjhUn4j QjnCfsr6A7ahZnkKrX9OcMgeX0uwEpgqIw2iVHk3PK1pc7p5wT1wWwIOg4fhBTByYHFsU+/BKTf eh6R5TnXhJcbWS4WGEdgbuapeS5OEF4ppNeVSKJqV0zrLR23aidy2WCoM273KhDAWu942cgxVOG KRLBO6IzCfbir+cQ9PvfndMtIoJFQkMGVCGsuU/z6iAGCpZdqIBBtZdZxGTXwFaGW/EulCg5hoJ h8aGstcfFQnxOBhZh5BdbjBPMu6HGPGs9URqSuJ9kDfwuG2bXrltdvqnp9zkJ4E9Y+3s/PE5jIX 6Czd98xnOpsvheZaHex97YSOq/oGJwk8VzWmu4ayugBrua+cnScPfd1zMQ0I52f2J0OETU8wGWv bcb22jSipHERvhL/lvxAe6kVr9iuOzOIFwOcfdf0p6IGpPxn8x4rNuZwFc7uHyWZ+VXeYNHUkbn NjVkkJs/kBa/oaQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774954671670591559 X-GMAIL-MSGID: 1774954671670591559 The Toshiba documentation talks about HSByteClk when referring to the DSI HS byte clock, whereas the driver uses 'dsibclk' name. Also, in a few places the driver calculates the byte clock from the DSI clock, even if the byte clock is already available in a variable. To align the driver with the documentation, change the 'dsibclk' variable to 'hsbyteclk'. This also make it easier to visually separate 'dsibclk' and 'dsiclk' variables. Reviewed-by: Peter Ujfalusi Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/bridge/tc358768.c | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c index 6297d28250e9..0f117d673b14 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -604,7 +604,7 @@ static int tc358768_setup_pll(struct tc358768_priv *priv, dev_dbg(priv->dev, "PLL: refclk %lu, fbd %u, prd %u, frs %u\n", clk_get_rate(priv->refclk), fbd, prd, frs); - dev_dbg(priv->dev, "PLL: pll_clk: %u, DSIClk %u, DSIByteClk %u\n", + dev_dbg(priv->dev, "PLL: pll_clk: %u, DSIClk %u, HSByteClk %u\n", priv->dsiclk * 2, priv->dsiclk, priv->dsiclk / 4); dev_dbg(priv->dev, "PLL: pclk %u (panel: %u)\n", tc358768_pll_to_pclk(priv, priv->dsiclk * 2), @@ -646,8 +646,8 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) u32 val, val2, lptxcnt, hact, data_type; s32 raw_val; const struct drm_display_mode *mode; - u32 dsibclk_nsk, dsiclk_nsk, ui_nsk; - u32 dsiclk, dsibclk, video_start; + u32 hsbyteclk_nsk, dsiclk_nsk, ui_nsk; + u32 dsiclk, hsbyteclk, video_start; const u32 internal_delay = 40; int ret, i; struct videomode vm; @@ -678,7 +678,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) drm_display_mode_to_videomode(mode, &vm); dsiclk = priv->dsiclk; - dsibclk = dsiclk / 4; + hsbyteclk = dsiclk / 4; /* Data Format Control Register */ val = BIT(2) | BIT(1) | BIT(0); /* rdswap_en | dsitx_en | txdt_en */ @@ -730,67 +730,67 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) tc358768_write(priv, TC358768_D0W_CNTRL + i * 4, 0x0000); /* DSI Timings */ - dsibclk_nsk = (u32)div_u64((u64)1000000000 * TC358768_PRECISION, - dsibclk); + hsbyteclk_nsk = (u32)div_u64((u64)1000000000 * TC358768_PRECISION, + hsbyteclk); dsiclk_nsk = (u32)div_u64((u64)1000000000 * TC358768_PRECISION, dsiclk); ui_nsk = dsiclk_nsk / 2; dev_dbg(dev, "dsiclk_nsk: %u\n", dsiclk_nsk); dev_dbg(dev, "ui_nsk: %u\n", ui_nsk); - dev_dbg(dev, "dsibclk_nsk: %u\n", dsibclk_nsk); + dev_dbg(dev, "hsbyteclk_nsk: %u\n", hsbyteclk_nsk); /* LP11 > 100us for D-PHY Rx Init */ - val = tc358768_ns_to_cnt(100 * 1000, dsibclk_nsk) - 1; + val = tc358768_ns_to_cnt(100 * 1000, hsbyteclk_nsk) - 1; dev_dbg(dev, "LINEINITCNT: %u\n", val); tc358768_write(priv, TC358768_LINEINITCNT, val); /* LPTimeCnt > 50ns */ - val = tc358768_ns_to_cnt(50, dsibclk_nsk) - 1; + val = tc358768_ns_to_cnt(50, hsbyteclk_nsk) - 1; lptxcnt = val; dev_dbg(dev, "LPTXTIMECNT: %u\n", val); tc358768_write(priv, TC358768_LPTXTIMECNT, val); /* 38ns < TCLK_PREPARE < 95ns */ - val = tc358768_ns_to_cnt(65, dsibclk_nsk) - 1; + val = tc358768_ns_to_cnt(65, hsbyteclk_nsk) - 1; dev_dbg(dev, "TCLK_PREPARECNT %u\n", val); /* TCLK_PREPARE + TCLK_ZERO > 300ns */ val2 = tc358768_ns_to_cnt(300 - tc358768_to_ns(2 * ui_nsk), - dsibclk_nsk) - 2; + hsbyteclk_nsk) - 2; dev_dbg(dev, "TCLK_ZEROCNT %u\n", val2); val |= val2 << 8; tc358768_write(priv, TC358768_TCLK_HEADERCNT, val); /* TCLK_TRAIL > 60ns AND TEOT <= 105 ns + 12*UI */ - raw_val = tc358768_ns_to_cnt(60 + tc358768_to_ns(2 * ui_nsk), dsibclk_nsk) - 5; + raw_val = tc358768_ns_to_cnt(60 + tc358768_to_ns(2 * ui_nsk), hsbyteclk_nsk) - 5; val = clamp(raw_val, 0, 127); dev_dbg(dev, "TCLK_TRAILCNT: %u\n", val); tc358768_write(priv, TC358768_TCLK_TRAILCNT, val); /* 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; + val = tc358768_ns_to_cnt(val, hsbyteclk_nsk) - 1; dev_dbg(dev, "THS_PREPARECNT %u\n", val); /* THS_PREPARE + THS_ZERO > 145ns + 10*UI */ - raw_val = tc358768_ns_to_cnt(145 - tc358768_to_ns(3 * ui_nsk), dsibclk_nsk) - 10; + raw_val = tc358768_ns_to_cnt(145 - tc358768_to_ns(3 * ui_nsk), hsbyteclk_nsk) - 10; val2 = clamp(raw_val, 0, 127); dev_dbg(dev, "THS_ZEROCNT %u\n", val2); val |= val2 << 8; tc358768_write(priv, TC358768_THS_HEADERCNT, val); /* TWAKEUP > 1ms in lptxcnt steps */ - val = tc358768_ns_to_cnt(1020000, dsibclk_nsk); + val = tc358768_ns_to_cnt(1020000, hsbyteclk_nsk); val = val / (lptxcnt + 1) - 1; dev_dbg(dev, "TWAKEUP: %u\n", val); tc358768_write(priv, TC358768_TWAKEUP, val); /* TCLK_POSTCNT > 60ns + 52*UI */ val = tc358768_ns_to_cnt(60 + tc358768_to_ns(52 * ui_nsk), - dsibclk_nsk) - 3; + hsbyteclk_nsk) - 3; dev_dbg(dev, "TCLK_POSTCNT: %u\n", val); tc358768_write(priv, TC358768_TCLK_POSTCNT, val); /* 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; + hsbyteclk_nsk) - 4; val = clamp(raw_val, 0, 15); dev_dbg(dev, "THS_TRAILCNT: %u\n", val); tc358768_write(priv, TC358768_THS_TRAILCNT, val); @@ -804,11 +804,11 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) (mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS) ? 0 : BIT(0)); /* TXTAGOCNT[26:16] RXTASURECNT[10:0] */ - val = tc358768_to_ns((lptxcnt + 1) * dsibclk_nsk * 4); - val = tc358768_ns_to_cnt(val, dsibclk_nsk) / 4 - 1; + val = tc358768_to_ns((lptxcnt + 1) * hsbyteclk_nsk * 4); + val = tc358768_ns_to_cnt(val, hsbyteclk_nsk) / 4 - 1; dev_dbg(dev, "TXTAGOCNT: %u\n", val); - val2 = tc358768_ns_to_cnt(tc358768_to_ns((lptxcnt + 1) * dsibclk_nsk), - dsibclk_nsk) - 2; + val2 = tc358768_ns_to_cnt(tc358768_to_ns((lptxcnt + 1) * hsbyteclk_nsk), + hsbyteclk_nsk) - 2; dev_dbg(dev, "RXTASURECNT: %u\n", val2); val = val << 16 | val2; tc358768_write(priv, TC358768_BTACNTRL1, val); @@ -831,13 +831,13 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) /* hsw * byteclk * ndl / pclk */ val = (u32)div_u64(vm.hsync_len * - ((u64)priv->dsiclk / 4) * priv->dsi_lanes, + (u64)hsbyteclk * priv->dsi_lanes, vm.pixelclock); tc358768_write(priv, TC358768_DSI_HSW, val); /* hbp * byteclk * ndl / pclk */ val = (u32)div_u64(vm.hback_porch * - ((u64)priv->dsiclk / 4) * priv->dsi_lanes, + (u64)hsbyteclk * priv->dsi_lanes, vm.pixelclock); tc358768_write(priv, TC358768_DSI_HBPR, val); } else { @@ -856,7 +856,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) /* (hsw + hbp) * byteclk * ndl / pclk */ val = (u32)div_u64((vm.hsync_len + vm.hback_porch) * - ((u64)priv->dsiclk / 4) * priv->dsi_lanes, + (u64)hsbyteclk * priv->dsi_lanes, vm.pixelclock); tc358768_write(priv, TC358768_DSI_HSW, val); From patchwork Tue Aug 22 16:19:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 136575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3786199vqi; Tue, 22 Aug 2023 10:42:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhbl4Q5kitJNuWf/RfHzr39T0BmF4AE8DYHk+HuPaRvJBx57SDyAPgFhFsWR7M/ncmOGWf X-Received: by 2002:a05:6808:dc5:b0:3a8:4dfd:4f0b with SMTP id g5-20020a0568080dc500b003a84dfd4f0bmr10059763oic.19.1692726142146; Tue, 22 Aug 2023 10:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692726142; cv=none; d=google.com; s=arc-20160816; b=Xz5ct6Ha1CaQCiVjT/31URS6eOmNy9NBMb0vBbgod0+EFr+i87cqXUYM2zKwpT6fNH 7e06WoZgJ+uYoUE98pJ6MXFbPeSWrf7pvwcoTcFK0zaqUne42L69VYSxAfANVEUGp4P5 YSIKsRlZBd3Bc7bIsKxmQCQdvFWcWnlk/LUZOvJSCULwrZfkeyc0c1cmIKjS1/lkFKFk GlQfmbtnF6bzeQDI7rMtSXGe2oY/neRG/Fox1G4yyNard3IGt+F98U8TinmGBJ+XJeq7 wzOIaKMk6YMvk2DWB0+4oFI0rPZAC6GyzZxQX91pIIqj9UKrm/H2siYQ/nGTmARXbl6h Gnow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=2YlUbGw4okVmE2Jn2QWxypEuCPY9x4Qji0+ldhH7r3A=; fh=lPlKf1PhZKgmDKmNHoLwviSf3cvO+AJgrT68RUEi/pE=; b=Z0xgU0wFxc8NfCZeYUYma9DLkBImYCTZ5xB4t1puXw6beuo6pVLBr9XBMZkllFRt4l XHAhC8va4z3awq5SEusE5TTbtUBG6zHk4otLalHxqRWKDL54cRgZGh3iy69YedFNN5Fd 3Jx5L59hRmfpYIvTV06cndYoe6yLJcYoEniGAraygZRNSUTP0+ZU+2xtgHdcGW1Ird+D bq5jBvEgYL18FNiydgPsrQb1WNJVIQVp63K0MMmLFfxk7O+U1u3XftadAy7xpdTT9PP+ PpFtRs0OHB0IOPcwoneOhKXl2Jgegt2EgpUzvXoRLGYFlDC52NrAM2kjOXSwPV0HRB5C Vd/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CQNJQdUe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 26-20020a63115a000000b00565cc12ee24si8973017pgr.874.2023.08.22.10.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 10:42:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CQNJQdUe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78C125BA5; Tue, 22 Aug 2023 10:16:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237706AbjHVQUi (ORCPT + 99 others); Tue, 22 Aug 2023 12:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237662AbjHVQU1 (ORCPT ); Tue, 22 Aug 2023 12:20:27 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3004FE61 for ; Tue, 22 Aug 2023 09:20:16 -0700 (PDT) Received: from [127.0.1.1] (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0181187F4; Tue, 22 Aug 2023 18:18:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1692721135; bh=LO6DVrF7Wy//586q71JqmvhJ6yqjCtp6tNE4HEdX3hc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CQNJQdUewY94WUFp9YPll+PZlDY1phdM4tVllfLf9tWDLtfljBMn7CgXk95lIJeMJ VqFB/z4vpcxTbOBRpsaIfxiBFu2iqUrU2RohOpTOegdhKeCDlTBxtnWf7drjLPMgKh jMK9q0I4Spa4gups2zh4fGRoadXnLpbgVtQg6SEI= From: Tomi Valkeinen Date: Tue, 22 Aug 2023 19:19:44 +0300 Subject: [PATCH v3 11/12] drm/bridge: tc358768: Fix tc358768_ns_to_cnt() MIME-Version: 1.0 Message-Id: <20230822-tc358768-v3-11-c82405dac0c1@ideasonboard.com> References: <20230822-tc358768-v3-0-c82405dac0c1@ideasonboard.com> In-Reply-To: <20230822-tc358768-v3-0-c82405dac0c1@ideasonboard.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , =?utf-8?q?P=C3=A9ter_Ujfalusi?= , Maxim Schwalm , Francesco Dolcini Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Aradhya Bhatia , Tomi Valkeinen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=956; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=LO6DVrF7Wy//586q71JqmvhJ6yqjCtp6tNE4HEdX3hc=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBk5OAuWjKWskwExcfKQDmgn/U8rq857fNH5jATm ZR/kqZaJDiJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZOTgLgAKCRD6PaqMvJYe 9ZwAEACr5jOQagaCCvcZpT8sfneYHY7YPSelKldZoR04bQCAK7S5k5aa3SpTIQ/EeTBc53dOjkq ewlV4E2veNj+RKf5HA8f243swDg9tdU4WBj60XglDh1JCKwEgkaWDSYzgZnKtXuH2pz9MGv5oKd VbBaBkEiU3f+AxL+tLLHS5fifFJIJ08ZMSjhLuo82pQYJ9BSOGQPzmDFLkW3kQUgE38rgrHh3mw jEAKEqSbd6c5EejvSEq7ynzJDVB0I4i6iJtiIJuXdVh7uIBwqRdtvRXrpRRHIza2Kg/LRRCwGV4 /OB8+3sRs1HaQzT1o75L+Zro0IJlJBlkDNgJ2DZAkISO1Yfk+83vFod1nhDow5Nmvg7L+rW9fqN RVImT2DTJb9H297Xf9TFVrg96UWwUd9pI2OTsc0xnDo5lNYV45Nq5w6KOacgvfT9v42Zf9c9oC1 mglS612hxEXQg1q3ES2jiwHWpPVp8EaP0qLSryjMKhaVD18dsClBh779ZCG2jNbrx6wakpfHLf4 4DEl1eRGAFULetw0heN5UGHyiw+6J+CGbCQVtX+T6xQHNO0DFSaovXA4twlKXtHdHVHzQ8YVTEG u6xJOQtqgQO/cjNe8MDQQaRt0A2hMoooMU9wqyd4I3OOf2U94/WccXaKBsFzr3SriP+GMOdsiNj LimPFRnaGpghTFQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774952007331333725 X-GMAIL-MSGID: 1774952007331333725 The tc358768_ns_to_cnt() is, most likely, supposed to do a div-round-up operation, but it misses subtracting one from the dividend. Fix this by just using DIV_ROUND_UP(). Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver") Reviewed-by: Peter Ujfalusi Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/bridge/tc358768.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c index 9ce8d120b50c..f41bf56b7d6b 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -630,7 +630,7 @@ static int tc358768_setup_pll(struct tc358768_priv *priv, static u32 tc358768_ns_to_cnt(u32 ns, u32 period_ps) { - return (ns * 1000 + period_ps) / period_ps; + return DIV_ROUND_UP(ns * 1000, period_ps); } static u32 tc358768_ps_to_ns(u32 ps)