From patchwork Tue Oct 17 09:06:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 116037 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4636668qgn; Tue, 17 Oct 2017 02:06:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB/DNgfGqkJnYzAyGLnOgZGg/A0pPT6f/d+gpsY+DZzraRaplsHi/OU3YxQ70S6pUpi8+Xw X-Received: by 10.84.205.70 with SMTP id o6mr11704120plh.350.1508231217176; Tue, 17 Oct 2017 02:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508231217; cv=none; d=google.com; s=arc-20160816; b=BKQyhQHuqdt57d25dHzAFxaHaJYljPCkD6C75PMghzDuoSjH0J+Itf8KQLirOyB3+p NgOuK0fs8/bQNJxBrTTsa1uRmCqTaS7j/d+zWAgXMnwYSLHavZc8mlYJuDtsNh4dpeT1 CRKVNHRZRx2Jn09nJ1MfcPQPrlVdZMo7ZK6hJe4QydPOsX+mxJr0eXRYbDdpLVUPaNbj 1Sf2+47g4DSe/szkooElXfJs1Kg7PBApBsr2kwYF6vh340LF2QkhogTvQBnjz7oldVIv ZcIF3pAdLBNfXnDDDCsyEAzaV9wIBJa6bKF2GfjaIa11cC1sTpn3jtHOf9VHQ92DBwf7 ZMvw== 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=PrszxQLv9Aap/EznQOMMzg5uIx0jTVzT+aYoIFCukh0=; b=xaoesogcSmPgfZsM8BSibrrtoaHeKWMWEp/ocZMkeMjFuEIKW7GoIwgWRORAkTuYy0 Lpv/1IgqIdGd/P/NuGE5ImKpHJcZd/l02X10wnziA+l8vZOXhN2+u1fCySk/4Tk6eoTM V5gR8eE1Gimw0krfUeazAZASLeV+cL6835BRKX+M/+ySpzAKK06MkiCNsF9SMh6lrBWo jbJj5XmbFfDINT54JD0sC8MVj3CCDvNiIsAE/PWEtP8DvNpotv3155yaIhk8bNDDaTs6 1VEEKrcI72T3dutidgTEzitUnH0Dt4+nStus+4hMwmckUdrOiqgx/0pqdLVfUuBH1BcA gUZQ== 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 t21si4599600pgb.737.2017.10.17.02.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 02:06:57 -0700 (PDT) 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 91FF46E611; Tue, 17 Oct 2017 09:06:45 +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 CA8C56E606 for ; Tue, 17 Oct 2017 09:06:42 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 3FF5320898; Tue, 17 Oct 2017 11:06:41 +0200 (CEST) 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 (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 15F3D20892; Tue, 17 Oct 2017 11:06:41 +0200 (CEST) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH 09/23] drm/panel: lvds: Add support for the power-supply property Date: Tue, 17 Oct 2017 11:06:16 +0200 Message-Id: <6f688742088e5e873f8d392956e06e783667aa96.1508231063.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: References: In-Reply-To: References: Cc: Mark Rutland , Thomas Petazzoni , plaes@plaes.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Quentin Schulz , Rob Herring , Mylene Josserand , 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. Signed-off-by: Maxime Ripard Reviewed-by: Chen-Yu Tsai --- 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);