Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1396405lqh; Mon, 6 May 2024 06:41:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRSIXS1iRLyZvXKf1MiQpCvmDmmYwNPNIrC9jN9RMGN4aeqsc/6NBwCOJgxBZb2DC4/0KOdl15ReGlByI8OJmpCHYCIkig/vVNgZsTBg== X-Google-Smtp-Source: AGHT+IFK6tQwJ0Dz1RRFyd9sjWb68YYierkwGScRKwr8IRr/D0vJTBl+hvx1CcxR385jSAXGbQ7h X-Received: by 2002:a17:906:2dc6:b0:a59:ddec:b339 with SMTP id h6-20020a1709062dc600b00a59ddecb339mr790815eji.50.1715002897490; Mon, 06 May 2024 06:41:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715002897; cv=pass; d=google.com; s=arc-20160816; b=wVZGnSm1KXLM/DwbyDLQDwdmPNR187n5D4K5GWNktSP1jiISB9MJ8GpWUvNFb9Xy6L 2vk4SaQSDzpe08T0UrbYFvEmXlvKvqAEmBxQPxAmKkzkHkBIuLHsyIi4//R/cqpev/SH nUIBtlY7g6N3m6GtADtJOEZevOIAUGyBin/+la3OI2DBClOP1NvlFEAZM/U26w1D8F0S eHlVxZAW3MWWMp4QibI0466M9rkw0IAyNOkkHsBk6vJwtmFSrko4OFoBT4APm+Fk0oPV ISRDcQT5UY4M14XtYbgL1BezF2l6WgbUyyxtMp8MD5TPR9Fd8mfQhWlgIejtuuGfY2UH usjg== 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=Tga59FAehztjaaAkLBf/e3NN0NozTH144Ry5q5o30Sk=; fh=SuRMajwH7N2ZLVBLirbkCwTFKIhKCObxyHKAw4nU6hQ=; b=zDBSBHko/28zKOdTv+bXzJyDuys14hmyIqwWNpwZc2pYJk9wc/ttM69ufZJiKqDL5O HkhDRWBjVlLdNdh5Nn6ZB54v+5Ys0QqxYZsjwSBNzdT9gkATXp3EWOPj1NvkW5Bk6OEo IWwWCiO+XaTOxPJqb7bDaYjwnw86YotEeFTMgZt+BVQc0BlDFbQDr5qff97Q2lNbMATJ a8mf9K3W1ev8qDvNxJ7BRs0R5LAkatpi9GxIfQE5Flh1ZPMaEMx+7cMJ4XOqEeQjAzSw OJKXSf3PBBhwT3MujKf8J9ce589tD+wwQcNgZjgyxfjSkYILE+I2xeUMOBG/90ViP6z+ R0Dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fOxWWLGo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ht20-20020a170907609400b00a59ce0dc680si1160058ejc.98.2024.05.06.06.41.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:41:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fOxWWLGo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169919-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 112E31F21F4F for ; Mon, 6 May 2024 13:41:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDA4712AADD; Mon, 6 May 2024 13:36:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fOxWWLGo" 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 B971D12AACE for ; Mon, 6 May 2024 13:36:36 +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=1715002596; cv=none; b=RkVWtz+6pZwMAIV/HVMi0mcxyOrzQekLDwmz/jIh3tR6ZSIdwL4zwmVBZtvYL1MEydcF9k8G/Tw1VqETvCMuAlmq/H79YZDqynNFxEV7X6973Qp5o8dtPNtATxMbj6h4aOJBLSP0MYvPRzu0g6Hs3wWVztotsD9JnuLU1V1SkVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002596; c=relaxed/simple; bh=7pxQETmnu6FGrgnJHaKGqthAffDCBJczpSl2HJqrSW8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QeSiZMIxcegNKVFZ7yL+7h8D5UbrBVLKjg3x0qzIMg0hBznTLxX+lMo3eB9d5vCPnLGe8HH6pgYB68hZIJFgA/GIdzLl8MzcjUPqYyb21ZvWkBGeIXuU60/SIXzDM2MClLy53N5Y/N46DXL9sSbJcP71BiJ8AYvLI42kHSLv3vk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fOxWWLGo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8ABDC3277B; Mon, 6 May 2024 13:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715002596; bh=7pxQETmnu6FGrgnJHaKGqthAffDCBJczpSl2HJqrSW8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fOxWWLGouwuxi+wtZp8YtrRVkgU+b1Md5gkgRMvCNTI0WHqGG64jKKjij/9oaKJ3s bLoUZW4xYs9HGkNT1sOgk2kdRXx0nh+SNgIWMfWC241S7gj0ytO3pLM2I87IqpkEtM shFabsZBvgkh26S5AbFO07or1s4cpPiBWcGQ5yKzq3ih8/k5d1jh88mC/OlWep+IIo 9Rxy9MFQNYGcpksZ/LJSCFboECeTJjGpHDhepQNR8NjByobFeCI+hZqPnt9QGkOtYz XflAsaH3gwmnQfTlJUACPm5BIsGOXS5WfDKQwy/IeeXeFJhdIwM3MoZ8+ukMGCqVUI j9n7oMj01/c1w== From: Michael Walle Date: Mon, 06 May 2024 15:34:48 +0200 Subject: [PATCH 19/20] drm/bridge: tc358775: fix power-up sequencing 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-19-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 The reset line of this bridge must be released while the DSI data lanes and DSI clock lane are in LP-11 mode. After that the DSI clock has to be turned on, which is a requirement to have I2C work. To achieve this, use the new .lp11_notify() callback where the reset line is released. Set .pre_enable_prev_first to make sure, there is a valid DSI clock during the .pre_enabe() op. In .pre_enable() the bridge will be fully configured but the LVDS transmitter will remain disabled. It will eventually be enabled in the .enable() op. With the correct initialization sequence we don't need the additional reset, nor the additional write to VFUEN. With that fixed, the init sequence is exactly how the vendor is requiring it. Signed-off-by: Michael Walle --- drivers/gpu/drm/bridge/tc358775.c | 62 +++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c index 99dbbb1fee78..31f89b7d5a3a 100644 --- a/drivers/gpu/drm/bridge/tc358775.c +++ b/drivers/gpu/drm/bridge/tc358775.c @@ -239,6 +239,9 @@ static void tc358775_power_up(struct tc_data *tc) struct device *dev = &tc->dsi->dev; int ret; + if (tc->powered) + return; + ret = regulator_enable(tc->vddio); if (ret < 0) dev_err(dev, "regulator vddio enable failed, %d\n", ret); @@ -252,6 +255,8 @@ static void tc358775_power_up(struct tc_data *tc) gpiod_set_value(tc->reset_gpio, 0); usleep_range(200, 250); + + tc->powered = true; } static void tc358775_power_down(struct tc_data *tc) @@ -271,20 +276,8 @@ static void tc358775_power_down(struct tc_data *tc) ret = regulator_disable(tc->vddio); if (ret < 0) dev_err(dev, "regulator vddio disable failed, %d\n", ret); -} -static void tc_bridge_pre_enable(struct drm_bridge *bridge) -{ - struct tc_data *tc = bridge_to_tc(bridge); - - tc358775_power_up(tc); -} - -static void tc_bridge_post_disable(struct drm_bridge *bridge) -{ - struct tc_data *tc = bridge_to_tc(bridge); - - tc358775_power_down(tc); + tc->powered = false; } /* helper function to access bus_formats */ @@ -474,12 +467,25 @@ static void tc358775_configure_lvds_clock(struct tc_data *tc) regmap_write(tc->regmap, LVCFG, val); } -static void tc358775_bridge_enable(struct drm_bridge *bridge) +static void tc358775_dsi_lp11_notify(struct drm_bridge *bridge) { struct tc_data *tc = bridge_to_tc(bridge); - unsigned int val = 0; - struct drm_display_mode *mode; + + tc358775_power_up(tc); +} + +static void tc358775_bridge_pre_enable(struct drm_bridge *bridge) +{ struct drm_connector *connector = get_connector(bridge->encoder); + struct tc_data *tc = bridge_to_tc(bridge); + struct drm_display_mode *mode; + unsigned int val = 0; + + /* + * Legacy behavior, make sure this bridge is powered even if + * drm_bridge_dsi_lp11_notify() isn't called by the DSI host + */ + tc358775_power_up(tc); mode = &bridge->encoder->crtc->state->adjusted_mode; @@ -488,22 +494,27 @@ static void tc358775_bridge_enable(struct drm_bridge *bridge) dev_info(tc->dev, "DSI2LVDS Chip ID.%02x Revision ID. %02x **\n", (val >> 8) & 0xFF, val & 0xFF); - regmap_write(tc->regmap, SYSRST, - SYS_RST_REG | SYS_RST_DSIRX | SYS_RST_BM | SYS_RST_LCD | - SYS_RST_I2CM); - usleep_range(30000, 40000); - tc358775_configure_dsi(tc, mode->crtc_clock); 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_VFUEN); tc358775_configure_lvds_clock(tc); +} + +static void tc358775_bridge_enable(struct drm_bridge *bridge) +{ + struct tc_data *tc = bridge_to_tc(bridge); - /* Finally, enable the LVDS transmitter */ regmap_update_bits(tc->regmap, LVCFG, LVCFG_LVEN, LVCFG_LVEN); } +static void tc358775_bridge_post_disable(struct drm_bridge *bridge) +{ + struct tc_data *tc = bridge_to_tc(bridge); + + tc358775_power_down(tc); +} + /* * According to the datasheet, the horizontal back porch, front porch and sync * length must be a multiple of 2 and the minimal horizontal pulse width is 8. @@ -634,11 +645,12 @@ static int tc_bridge_attach(struct drm_bridge *bridge, static const struct drm_bridge_funcs tc_bridge_funcs = { .attach = tc_bridge_attach, - .pre_enable = tc_bridge_pre_enable, + .dsi_lp11_notify = tc358775_dsi_lp11_notify, + .pre_enable = tc358775_bridge_pre_enable, .enable = tc358775_bridge_enable, + .post_disable = tc358775_bridge_post_disable, .mode_fixup = tc_mode_fixup, .mode_valid = tc_mode_valid, - .post_disable = tc_bridge_post_disable, }; static int tc_attach_host(struct tc_data *tc) -- 2.39.2