From patchwork Wed Nov 13 09:23:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis Carikli X-Patchwork-Id: 3177701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C5B2C045B for ; Wed, 13 Nov 2013 09:26:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7CCD200ED for ; Wed, 13 Nov 2013 09:26:38 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3F8D20109 for ; Wed, 13 Nov 2013 09:26:33 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgWhE-0006zy-Kf; Wed, 13 Nov 2013 09:25:13 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgWgw-0002f3-4x; Wed, 13 Nov 2013 09:24:54 +0000 Received: from smtp3-g21.free.fr ([2a01:e0c:1:1599::12]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgWga-0002aN-UH for linux-arm-kernel@lists.infradead.org; Wed, 13 Nov 2013 09:24:35 +0000 Received: from denis-N73SV.local.eukrea.com (unknown [88.170.243.169]) by smtp3-g21.free.fr (Postfix) with ESMTP id E2684A6381; Wed, 13 Nov 2013 10:24:07 +0100 (CET) From: Denis Carikli To: Shawn Guo Subject: [PATCHv4][ 4/7] staging: imx-drm: parallel display: add regulator support. Date: Wed, 13 Nov 2013 10:23:20 +0100 Message-Id: <1384334603-14208-4-git-send-email-denis@eukrea.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1384334603-14208-1-git-send-email-denis@eukrea.com> References: <1384334603-14208-1-git-send-email-denis@eukrea.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131113_042433_604536_0DBE8D65 X-CRM114-Status: GOOD ( 15.99 ) X-Spam-Score: -1.2 (-) Cc: Mark Rutland , devicetree@vger.kernel.org, driverdev-devel@linuxdriverproject.org, Sascha Hauer , Pawel Moll , Stephen Warren , David Airlie , Greg Kroah-Hartman , Ian Campbell , dri-devel@lists.freedesktop.org, Denis Carikli , Laurent Pinchart , Philipp Zabel , =?UTF-8?q?Eric=20B=C3=A9nard?= , Dan Carpenter , Rob Herring , linux-arm-kernel@lists.infradead.org, Mauro Carvalho Chehab X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Dan Carpenter Cc: Rob Herring Cc: Pawel Moll Cc: Mark Rutland Cc: Stephen Warren Cc: Ian Campbell Cc: devicetree@vger.kernel.org Cc: Greg Kroah-Hartman Cc: driverdev-devel@linuxdriverproject.org Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: Eric BĂ©nard Signed-off-by: Denis Carikli --- ChangeLog v2->v3: - Added some interested people in the Cc list. - the lcd-supply is now called display-supply (not all display are LCD). - The code and documentation was updated accordingly. - regulator_is_enabled now guard the regulator enables/disables because regulator_disable does not check the regulator state. --- .../bindings/staging/imx-drm/fsl-imx-drm.txt | 1 + drivers/staging/imx-drm/parallel-display.c | 22 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt index 2d24425..4dd7ce5 100644 --- a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt +++ b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt @@ -28,6 +28,7 @@ Required properties: - compatible: Should be "fsl,imx-parallel-display" - crtc: the crtc this display is connected to, see below Optional properties: +- display-supply : phandle to the regulator device tree node if needed. - interface_pix_fmt: How this display is connected to the crtc. Currently supported types: "rgb24", "rgb565", "bgr666", "rgb666" - edid: verbatim EDID data block describing attached display. diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 46b6fce..195ec60 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "imx-drm.h" @@ -35,6 +36,7 @@ struct imx_parallel_display { struct drm_encoder encoder; struct imx_drm_encoder *imx_drm_encoder; struct device *dev; + struct regulator *disp_reg; void *edid; int edid_len; u32 interface_pix_fmt; @@ -139,6 +141,12 @@ static void imx_pd_encoder_prepare(struct drm_encoder *encoder) { struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + if (imxpd->disp_reg && !regulator_is_enabled(imxpd->disp_reg)) { + if (regulator_enable(imxpd->disp_reg)) + dev_err(imxpd->dev, + "Failed to enable regulator.\n"); + } + imx_drm_crtc_panel_format(encoder->crtc, DRM_MODE_ENCODER_NONE, imxpd->interface_pix_fmt); } @@ -155,6 +163,12 @@ static void imx_pd_encoder_mode_set(struct drm_encoder *encoder, static void imx_pd_encoder_disable(struct drm_encoder *encoder) { + struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + + if (imxpd->disp_reg && regulator_is_enabled(imxpd->disp_reg)) { + if (regulator_disable(imxpd->disp_reg)) + dev_err(imxpd->dev, "Failed to disable regulator.\n"); + } } static void imx_pd_encoder_destroy(struct drm_encoder *encoder) @@ -258,6 +272,14 @@ static int imx_pd_probe(struct platform_device *pdev) if (ret) return ret; + imxpd->disp_reg = devm_regulator_get(&pdev->dev, "display"); + if (IS_ERR(imxpd->disp_reg)) { + dev_warn(&pdev->dev, "Operating without display regulator.\n"); + imxpd->disp_reg = NULL; + } else { + dev_info(&pdev->dev, "Using display regulator.\n"); + } + ret = imx_drm_encoder_add_possible_crtcs(imxpd->imx_drm_encoder, np); platform_set_drvdata(pdev, imxpd);