From patchwork Mon Nov 27 15:41:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119726 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp437820qgn; Mon, 27 Nov 2017 07:42:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMYPGVtqOW6OXQ0YhYMIpboUDkGRD9tnMz/lPk/tMkdJIIVAjhwQIXh+9FBHseE2xSa6EgtJ X-Received: by 10.84.232.8 with SMTP id h8mr32117305plk.274.1511797333042; Mon, 27 Nov 2017 07:42:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511797333; cv=none; d=google.com; s=arc-20160816; b=SwXr5F8htvCouxNaOiGssMPToW8qI9ZdKBxKVtERuFvcWPQljXns3RS12odFA+GrGC ylRqKMnKu2df/WNYFoQcgYl64LADPN2TL5AUXM8IJKU4bUzMZlXGguU9Cc9QIJiSPipi xSgWwed7ehsQkJWTik5mbYtW2er90rtZyle7Pv+zEnufvXFcCkowB4DCa6Z9sJ0ITp6P AZAYE6DmOR46BX5B1h14wrI3c3Js/GjUc2Ej/T3NdVL+byYAMznr1M07z5PBQ+5f7FEM 8k84FOgc1d/ZjjtlSb4pjG+T9/BpJNmPBAVmuWcsJYf9hlj8Ro1l5Lx3zaNnTQBN2REF HU1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=9k9SmHQGMnEn6X8ToPfkkxOR1OorG/UOt3sKZ6f/14Y=; b=qwXQp+BKzNKhVftaliHHfVqulUuNZQFrH9S+fpFYyUisIsDMtySVDKISGao0gjvnzk YVkVlwnmRoC9nQMlk8lbqEL5z+8O0Oa3tr4MC7co9QocKpyVfYXAQNFSjhUc4F99YJHL zBWJyEywbDjz1//g8you8rIV3gbaXOJKgEWOU5v0WIpM+azFrH3Tz5JkcCYOzclX/VM7 Oc1x/lPvWlZF3kAj2md7O7q/dQHPe8hNC7GpICgMVQgZ7LNThPiY8gJlUcgHri7YE3wb GYrNtfkj2TYqW8gc0y5MIABwWFqT7cI1gm+dzuN3LnRwbkgosxnPYASNQIukEQGqQ0Sg 5apA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id m37si12575336plg.444.2017.11.27.07.42.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Nov 2017 07:42:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) 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 609056E308; Mon, 27 Nov 2017 15:42:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 47A316E2FD for ; Mon, 27 Nov 2017 15:42:01 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 75FEC213E3; Mon, 27 Nov 2017 16:42:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3D6F3213E0; Mon, 27 Nov 2017 16:42:00 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH v2 02/18] drm/panel: lvds: Add support for the power-supply property Date: Mon, 27 Nov 2017 16:41:26 +0100 Message-Id: <56a41d54acf87cdb2dc6f7e816f13816a66e2697.1511797218.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Mark Rutland , Thomas Petazzoni , jernej.skrabec@siol.net, plaes@plaes.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Rob Herring , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, icenowy@aosc.io X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A significant number of panels need to power up a regulator in order to operate properly. Add support for the power-supply property to enable and disable such a regulator whenever needed. Reviewed-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard --- drivers/gpu/drm/panel/panel-lvds.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c index e2d57c01200b..57e38a9e7ab4 100644 --- a/drivers/gpu/drm/panel/panel-lvds.c +++ b/drivers/gpu/drm/panel/panel-lvds.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ struct panel_lvds { bool data_mirror; struct backlight_device *backlight; + struct regulator *supply; struct gpio_desc *enable_gpio; struct gpio_desc *reset_gpio; @@ -69,6 +71,9 @@ static int panel_lvds_unprepare(struct drm_panel *panel) if (lvds->enable_gpio) gpiod_set_value_cansleep(lvds->enable_gpio, 0); + if (lvds->supply) + regulator_disable(lvds->supply); + return 0; } @@ -76,6 +81,17 @@ static int panel_lvds_prepare(struct drm_panel *panel) { struct panel_lvds *lvds = to_panel_lvds(panel); + if (lvds->supply) { + int err; + + err = regulator_enable(lvds->supply); + if (err < 0) { + dev_err(lvds->dev, "failed to enable supply: %d\n", + err); + return err; + } + } + if (lvds->enable_gpio) gpiod_set_value_cansleep(lvds->enable_gpio, 1); @@ -196,6 +212,13 @@ static int panel_lvds_probe(struct platform_device *pdev) if (ret < 0) return ret; + lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); + if (IS_ERR(lvds->supply)) { + ret = PTR_ERR(lvds->supply); + dev_err(lvds->dev, "failed to request regulator: %d\n", ret); + return ret; + } + /* Get GPIOs and backlight controller. */ lvds->enable_gpio = devm_gpiod_get_optional(lvds->dev, "enable", GPIOD_OUT_LOW);