From patchwork Tue Aug 20 01:16:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11102489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24DAF14DE for ; Tue, 20 Aug 2019 01:18:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0D72B2339D for ; Tue, 20 Aug 2019 01:18:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D72B2339D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5142E6E591; Tue, 20 Aug 2019 01:18:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 510126E4DD for ; Tue, 20 Aug 2019 01:17:41 +0000 (UTC) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11A96510; Tue, 20 Aug 2019 03:17:38 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 09/50] drm/bridge: simple-bridge: Add support for enable GPIO Date: Tue, 20 Aug 2019 04:16:40 +0300 Message-Id: <20190820011721.30136-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190820011721.30136-1-laurent.pinchart@ideasonboard.com> References: <20190820011721.30136-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566263858; bh=oJvd8dmz5I30VaYXa/CSqC8WEM4z1yFAnzrog1sbmlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OuODnAhb/xzyG3O+3FLUzg0e8O1v63GEfK07HOo8kYiS11MP8YP0OE8soraZnLqHy wYmumFiermeIokGetM9d7d93/+ZO3Wb623mVlkKWEFVu2NDEpUEzu+DYfXT2hFwR15 wsIDcms5punF2PUgxMgfep3dgrQhNO6ab+VomMO4= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Tomi Valkeinen , Sean Paul , Sebastian Reichel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If an enable GPIO is declared in the firmware, assert it when enabling the bridge and deassert it when disabling it. Signed-off-by: Laurent Pinchart Reviewed-by: Andrzej Hajda Reviewed-by: Stefan Agner Reviewed-by: Boris Brezillon Reviewed-by: Maxime Ripard --- drivers/gpu/drm/bridge/simple-bridge.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index 85aa852eafb4..3e5031833368 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -6,6 +6,7 @@ * Maxime Ripard */ +#include #include #include #include @@ -29,6 +30,7 @@ struct simple_bridge { struct i2c_adapter *ddc; struct regulator *vdd; + struct gpio_desc *enable; }; static inline struct simple_bridge * @@ -140,19 +142,23 @@ static int simple_bridge_attach(struct drm_bridge *bridge, static void simple_bridge_enable(struct drm_bridge *bridge) { struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge); - int ret = 0; + int ret; - if (sbridge->vdd) + if (sbridge->vdd) { ret = regulator_enable(sbridge->vdd); + if (ret) + DRM_ERROR("Failed to enable vdd regulator: %d\n", ret); + } - if (ret) - DRM_ERROR("Failed to enable vdd regulator: %d\n", ret); + gpiod_set_value_cansleep(sbridge->enable, 1); } static void simple_bridge_disable(struct drm_bridge *bridge) { struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge); + gpiod_set_value_cansleep(sbridge->enable, 0); + if (sbridge->vdd) regulator_disable(sbridge->vdd); } @@ -205,6 +211,14 @@ static int simple_bridge_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "No vdd regulator found: %d\n", ret); } + sbridge->enable = devm_gpiod_get_optional(&pdev->dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(sbridge->enable)) { + if (PTR_ERR(sbridge->enable) != -EPROBE_DEFER) + dev_err(&pdev->dev, "Unable to retrieve enable GPIO\n"); + return PTR_ERR(sbridge->enable); + } + sbridge->ddc = simple_bridge_retrieve_ddc(&pdev->dev); if (IS_ERR(sbridge->ddc)) { if (PTR_ERR(sbridge->ddc) == -ENODEV) {