From patchwork Tue May 30 19:28:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13261043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A116C77B7A for ; Tue, 30 May 2023 19:28:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91F9610E418; Tue, 30 May 2023 19:28:25 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EDD210E417 for ; Tue, 30 May 2023 19:28:22 +0000 (UTC) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A75B4847C0; Tue, 30 May 2023 21:28:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1685474900; bh=omn0qPdvYx0kG7n/PZJIkC9DtWFUxvle4DwjJsxCz68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HmYV0I7Mv576uiV8f+VBQoPpl0CSLG+wAZ7T+FjLMpaaG/VdkXaGgxzasDGTuLF45 8DjJejxRCaUIY9dttblaTKsFfpzc1sD3aIs844UXZu2h5Jeq6IRKLdFSUw3oxu2q7+ a7qRbPoPiHdEFRGJTR53fLGr0ZnB3+ayvYHOrcUxq1gyxbn67+/veU7K2bqP8iy7DC obibIQpyMrxarKwjRyQgx3CCUm4lICWyVu6rf21MM9qTLP98nWbMiSWzU03VBkHdVA SlS/faZAMiKKe7heOAG/4/qq4f8k1Y0Ghd2IqsoTDMEOV4XI0ogsoOPH23/oBe9rzh 4rhijEa2+liyA== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/bridge: tc358762: Add reset GPIO support Date: Tue, 30 May 2023 21:28:05 +0200 Message-Id: <20230530192805.648646-2-marex@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230530192805.648646-1-marex@denx.de> References: <20230530192805.648646-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Neil Armstrong , Conor Dooley , Robert Foss , Andrzej Hajda , Krzysztof Kozlowski , Jonas Karlman , Jernej Skrabec , devicetree@vger.kernel.org, Rob Herring , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add reset GPIO support. The reset GPIO is cleared after supply regulator was enabled, and set before supply regulator is disabled. Signed-off-by: Marek Vasut Reviewed-by: Robert Foss --- Cc: Andrzej Hajda Cc: Conor Dooley Cc: Daniel Vetter Cc: David Airlie Cc: Jernej Skrabec Cc: Jonas Karlman Cc: Krzysztof Kozlowski Cc: Laurent Pinchart Cc: Marek Vasut Cc: Neil Armstrong Cc: Rob Herring Cc: Robert Foss Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/tc358762.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c index 77f7f7f547570..5641395fd310e 100644 --- a/drivers/gpu/drm/bridge/tc358762.c +++ b/drivers/gpu/drm/bridge/tc358762.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -63,6 +64,7 @@ struct tc358762 { struct drm_bridge bridge; struct regulator *regulator; struct drm_bridge *panel_bridge; + struct gpio_desc *reset_gpio; bool pre_enabled; int error; }; @@ -138,6 +140,9 @@ static void tc358762_post_disable(struct drm_bridge *bridge) ctx->pre_enabled = false; + if (ctx->reset_gpio) + gpiod_set_value_cansleep(ctx->reset_gpio, 0); + ret = regulator_disable(ctx->regulator); if (ret < 0) dev_err(ctx->dev, "error disabling regulators (%d)\n", ret); @@ -152,6 +157,11 @@ static void tc358762_pre_enable(struct drm_bridge *bridge) if (ret < 0) dev_err(ctx->dev, "error enabling regulators (%d)\n", ret); + if (ctx->reset_gpio) { + gpiod_set_value_cansleep(ctx->reset_gpio, 1); + usleep_range(5000, 10000); + } + ret = tc358762_init(ctx); if (ret < 0) dev_err(ctx->dev, "error initializing bridge (%d)\n", ret); @@ -185,6 +195,11 @@ static int tc358762_parse_dt(struct tc358762 *ctx) ctx->panel_bridge = panel_bridge; + /* Reset GPIO is optional */ + ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(ctx->reset_gpio)) + return PTR_ERR(ctx->reset_gpio); + return 0; }