Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1395692lqh; Mon, 6 May 2024 06:40:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDDqZoekqKFJAZ4JyYjblOVzdDGNWY3wV2+9LFBzSFbAsmBi9SFvvM5DoI4VkPgLI8D05P2p4wDN40PC0WqhhpbI3U741k42y0Du7ELA== X-Google-Smtp-Source: AGHT+IG24k9OnB+pQziJp3hRgwyVohECoNltvAGgJT5w0SYkAaVqIDSbeBJxsw4g5cFPQRNcYFha X-Received: by 2002:a05:622a:10e:b0:43a:9cd3:7fed with SMTP id u14-20020a05622a010e00b0043a9cd37fedmr11932814qtw.17.1715002816320; Mon, 06 May 2024 06:40:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715002816; cv=pass; d=google.com; s=arc-20160816; b=LWgvbOejuTqsD/7YpRZ8ziOMr4Ha4C5eiY9KK/U1f1HuKSDp+coWZVhLFCtYY5rpnU rJFtbBqyiiv2jYTpDEHLvYOgJhTWyfpOEmdplN6tJCNJV+B//TDRdUyD+ZiGfmLqkp0e +M2HnJFYgUZdmXYgV5t+/yzN6TZ2pw3uC0h5G++ZoTmPIw38pxg5rWVREsEfrJtLXul5 Lu4K1DSLs1+Zj/fynsmhTy723yuBFnGEkHzfKOHQrn3oHbmcPghxHcEmnHLAuJloZafJ ydVedKxkH2mr1LnXPRil/TGI2/av76l7t92Gzw2OqBQDOGBp5bgdcfhcFd7MdZXUmFQS q97w== 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=gMzoqzlOovfJDV81cUoogI1yKSPjhvs7YYHFOLJ6Kr0=; fh=SuRMajwH7N2ZLVBLirbkCwTFKIhKCObxyHKAw4nU6hQ=; b=0LFoIyNndfE6nTDcI5j0DwQt5r2WrfzrriQMLXfejlNr8eUXyi1DNW4E+KPGQP1R6V H4+zTvATzExTv7Odg+tqNl6NqxzSxCQREWoPXDbJxkBQ0iH8Nowy9szjsQxw+puiOPAI f/xOUj6lri8WxQU3WF/SttTxqEp7uJLey62XELnPxVr7zN8o7CW8NaxsYBU2TmsqDK0w Pi/5DxKpvTKpzj3gNwCmCs3FMf/D9ZjuIq7TrG0M6UOEaQjxfo7OTugHAX+7ihhVQmu9 4Xsj2AlRxq64LdYHnS41zZZ75xbjBMozjca5WFB4pOzsHRuPGPwXoses8pn9p5Kvgc8F AOIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K1lVik91; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169912-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y16-20020a05622a165000b0043aae35870dsi9794103qtj.280.2024.05.06.06.40.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:40:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K1lVik91; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169912-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0F1F81C22850 for ; Mon, 6 May 2024 13:40:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01C048563F; Mon, 6 May 2024 13:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K1lVik91" 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 1B60C7F476 for ; Mon, 6 May 2024 13:36:21 +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=1715002582; cv=none; b=DxDXULyDbWzcG01TCFBplLWadVrYdtdSkLbmwL3PX3aTjy5PJEDurGwTErLe0Iu6PRBRYWQAUDvVETkhep6CdM0rc29yTDQZY1rLZNCs+GLf+QV1BWYB202654jvLojtR+uKcLA8SYlw9iun9Rr+RiKGHIiCc30T+i/gzsWdTgE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002582; c=relaxed/simple; bh=MJDOXWqTjpbjsQTnGrv4MfUIC0eogdPWXfz9qOdcOCA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OXJ/V5N+APgo5B2Ltm7XOEZACBctmjaHEU8nEyij3AG+NKOZu9mOxccS6tcbGYGB2DCoV1/levnIWFufQQ3zUJyaeAgvuLy1WqnNUqSl+7aSdo1J8XzMDU8tmD22fKJCrWp/oyNhtvUSWCxfCV2LsBlWAm+OQtzlxR6+++MtrPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K1lVik91; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 466E6C3277B; Mon, 6 May 2024 13:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715002581; bh=MJDOXWqTjpbjsQTnGrv4MfUIC0eogdPWXfz9qOdcOCA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K1lVik91lKB3BsVDt1TF6+YiO2iiiAcRRDupmDnuWDqXPQ8Od8Umgmb4EtrUlopDN TsljnH30VDHb9P+oXMK37QRBqO5oRv6/iX8acZo2y6Yj1ilVudcgi2/5dhVKB6zuU1 8p28dpI+vQ1zLpqoQlNQvyptH0Di2CH2ZoyZcDbhk2ZnQ0bdp3AgZBWM+CE927F1+E g3Pz48GTKs6FSdKTWpCdxE9cHzcI4mKi7htABfoi1FWHs4RFYma2htWtzGeGhx/ztz y+g8VuQy5lKed4jXxjd1GUueDfwtuHIn8ERKlXRwtJfHgN27jbkcAqzRaKGXO13TAr 05eXigYD3g/ng== From: Michael Walle Date: Mon, 06 May 2024 15:34:45 +0200 Subject: [PATCH 16/20] drm/bridge: tc358775: use proper defines to configure LVDS timings 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: 7bit Message-Id: <20240506-tc358775-fix-powerup-v1-16-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 Provide bitfield macros for the individual fields in the LVDS timing registers and get rid of the magic values. Signed-off-by: Michael Walle --- drivers/gpu/drm/bridge/tc358775.c | 52 +++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c index 33a97ddba7b5..c50554ec4b28 100644 --- a/drivers/gpu/drm/bridge/tc358775.c +++ b/drivers/gpu/drm/bridge/tc358775.c @@ -111,11 +111,19 @@ #define VPCTRL_OPXLFMT BIT(8) #define VPCTRL_EVTMODE BIT(5) /* Video event mode enable, tc35876x only */ #define HTIM1 0x0454 /* Horizontal Timing Control 1 */ +#define HTIM1_HPW GENMASK(8, 0) +#define HTIM1_HBPR GENMASK(24, 16) #define HTIM2 0x0458 /* Horizontal Timing Control 2 */ +#define HTIM2_HACT GENMASK(10, 0) +#define HTIM2_HFPR GENMASK(24, 16) #define VTIM1 0x045C /* Vertical Timing Control 1 */ +#define VTIM1_VPW GENMASK(7, 0) +#define VTIM1_VBPR GENMASK(23, 16) #define VTIM2 0x0460 /* Vertical Timing Control 2 */ +#define VTIM2_VACT GENMASK(10, 0) +#define VTIM2_VFPR GENMASK(23, 16) #define VFUEN 0x0464 /* Video Frame Timing Update Enable */ -#define VFUEN_EN BIT(0) /* Upload Enable */ +#define VFUEN_VFUEN BIT(0) /* Upload Enable */ /* Mux Input Select for LVDS LINK Input */ #define LV_MX0003 0x0480 /* Bit 0 to 3 */ @@ -346,24 +354,19 @@ static void tc358775_configure_dsi(struct tc_data *tc, unsigned int pixelclk) static void tc358775_configure_lvds_timings(struct tc_data *tc, struct drm_display_mode *mode) { - u32 hback_porch, hsync_len, hfront_porch, hactive, htime1, htime2; - u32 vback_porch, vsync_len, vfront_porch, vactive, vtime1, vtime2; + u32 hback_porch, hsync_len, hfront_porch, hactive; + u32 vback_porch, vsync_len, vfront_porch, vactive; + unsigned int val; hback_porch = mode->htotal - mode->hsync_end; hsync_len = mode->hsync_end - mode->hsync_start; + hactive = mode->hdisplay; + hfront_porch = mode->hsync_start - mode->hdisplay; + vback_porch = mode->vtotal - mode->vsync_end; vsync_len = mode->vsync_end - mode->vsync_start; - - htime1 = (hback_porch << 16) + hsync_len; - vtime1 = (vback_porch << 16) + vsync_len; - - hfront_porch = mode->hsync_start - mode->hdisplay; - hactive = mode->hdisplay; - vfront_porch = mode->vsync_start - mode->vdisplay; vactive = mode->vdisplay; - - htime2 = (hfront_porch << 16) + hactive; - vtime2 = (vfront_porch << 16) + vactive; + vfront_porch = mode->vsync_start - mode->vdisplay; /* Video event mode vs pulse mode bit, does not exist for tc358775 */ if (tc->type == TC358765) @@ -379,12 +382,23 @@ static void tc358775_configure_lvds_timings(struct tc_data *tc, 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); - regmap_write(tc->regmap, HTIM2, htime2); - regmap_write(tc->regmap, VTIM2, vtime2); + val = u32_encode_bits(hsync_len, HTIM1_HPW); + val |= u32_encode_bits(hback_porch, HTIM1_HBPR); + regmap_write(tc->regmap, HTIM1, val); + + val = u32_encode_bits(hactive, HTIM2_HACT); + val |= u32_encode_bits(hfront_porch, HTIM2_HFPR); + regmap_write(tc->regmap, HTIM2, val); + + val = u32_encode_bits(vsync_len, VTIM1_VPW); + val |= u32_encode_bits(vback_porch, VTIM1_VBPR); + regmap_write(tc->regmap, VTIM1, val); + + val = u32_encode_bits(vactive, VTIM2_VACT); + val |= u32_encode_bits(vfront_porch, VTIM2_VFPR); + regmap_write(tc->regmap, VTIM2, val); - regmap_write(tc->regmap, VFUEN, VFUEN_EN); + regmap_write(tc->regmap, VFUEN, VFUEN_VFUEN); } static const struct tc358775_pll_settings tc358775_pll_settings[] = { @@ -475,7 +489,7 @@ static void tc358775_bridge_enable(struct drm_bridge *bridge) tc358775_configure_lvds_timings(tc, mode); tc358775_configure_pll(tc, mode->crtc_clock); tc358775_configure_color_mapping(tc, connector->display_info.bus_formats[0]); - regmap_write(tc->regmap, VFUEN, VFUEN_EN); + regmap_write(tc->regmap, VFUEN, VFUEN_VFUEN); tc358775_configure_lvds_clock(tc); /* Finally, enable the LVDS transmitter */ -- 2.39.2