From mboxrd@z Thu Jan 1 00:00:00 1970 From: Denis Carikli Subject: [PATCHv5][ 5/8] staging: imx-drm: parallel display: add regulator support. Date: Thu, 5 Dec 2013 19:28:09 +0100 Message-ID: <1386268092-21719-5-git-send-email-denis@eukrea.com> References: <1386268092-21719-1-git-send-email-denis@eukrea.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1386268092-21719-1-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Greg Kroah-Hartman Cc: Marek Vasut , devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org, Denis Carikli , Dan Carpenter , Rob Herring , Pawel Moll , Mark Rutland , Stephen Warren , Ian Campbell , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org, David Airlie , dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, Sascha Hauer , Shawn Guo , linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, =?UTF-8?q?Eric=20B=C3=A9nard?= List-Id: devicetree@vger.kernel.org Cc: Dan Carpenter Cc: Rob Herring Cc: Pawel Moll Cc: Mark Rutland Cc: Stephen Warren Cc: Ian Campbell Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Greg Kroah-Hartman Cc: driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org Cc: David Airlie Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Cc: Eric B=C3=A9nard Signed-off-by: Denis Carikli --- ChangeLog v3->v5: - Code clenaup. ChangeLog v2->v3: - Added some interested people in the Cc list. - the lcd-supply is now called display-supply (not all display are LCD)= =2E - 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= =2Etxt 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= =2E - interface_pix_fmt: How this display is connected to the crtc. Currently supported types: "rgb24", "rgb565", "bgr666", "rgb66= 6" - edid: verbatim EDID data block describing attached display. diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/stagi= ng/imx-drm/parallel-display.c index 65d0c18..61c0aeb 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 =20 #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; @@ -141,6 +143,13 @@ static void imx_pd_encoder_prepare(struct drm_enco= der *encoder) { struct imx_parallel_display *imxpd =3D enc_to_imxpd(encoder); =20 + if (!IS_ERR(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); } @@ -157,6 +166,12 @@ static void imx_pd_encoder_mode_set(struct drm_enc= oder *encoder, =20 static void imx_pd_encoder_disable(struct drm_encoder *encoder) { + struct imx_parallel_display *imxpd =3D enc_to_imxpd(encoder); + + if (!IS_ERR(imxpd->disp_reg) && regulator_is_enabled(imxpd->disp_reg)= ) { + if (regulator_disable(imxpd->disp_reg)) + dev_err(imxpd->dev, "Failed to disable regulator.\n"); + } } =20 static void imx_pd_encoder_destroy(struct drm_encoder *encoder) @@ -260,6 +275,13 @@ static int imx_pd_probe(struct platform_device *pd= ev) if (ret) return ret; =20 + imxpd->disp_reg =3D devm_regulator_get(&pdev->dev, "display"); + if (PTR_ERR(imxpd->disp_reg) =3D=3D -EPROBE_DEFER) + return -EPROBE_DEFER; + + if (IS_ERR(imxpd->disp_reg)) + dev_dbg(&pdev->dev, "Operating without display regulator.\n"); + ret =3D imx_drm_encoder_add_possible_crtcs(imxpd->imx_drm_encoder, np= ); =20 platform_set_drvdata(pdev, imxpd); --=20 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" i= n the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html