From patchwork Thu Oct 24 08:58:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis Carikli X-Patchwork-Id: 3091041 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 97EF39F2B7 for ; Thu, 24 Oct 2013 08:58:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CF5520498 for ; Thu, 24 Oct 2013 08:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3306820211 for ; Thu, 24 Oct 2013 08:58:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754269Ab3JXI6k (ORCPT ); Thu, 24 Oct 2013 04:58:40 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]:57561 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754267Ab3JXI6k (ORCPT ); Thu, 24 Oct 2013 04:58:40 -0400 Received: from denis-N73SV.local.eukrea.com (unknown [88.170.243.169]) by smtp3-g21.free.fr (Postfix) with ESMTP id 1E7A4A62BC; Thu, 24 Oct 2013 10:58:25 +0200 (CEST) From: Denis Carikli To: Sascha Hauer Cc: Shawn Guo , =?UTF-8?q?Eric=20B=C3=A9nard?= , linux-arm-kernel@lists.infradead.org, Jean-Christophe PLAGNIOL-VILLARD , Sergei Shtylyov , Denis Carikli , Fabio Estevam , Tomi Valkeinen , linux-fbdev@vger.kernel.org Subject: [PATCHv7][ 1/6] video: imxfb: Introduce regulator support. Date: Thu, 24 Oct 2013 10:58:18 +0200 Message-Id: <1382605103-9595-1-git-send-email-denis@eukrea.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This commit is based on the following commit by Fabio Estevam: 4344429 video: mxsfb: Introduce regulator support Cc: Fabio Estevam Cc: Sascha Hauer Cc: linux-arm-kernel@lists.infradead.org Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: linux-fbdev@vger.kernel.org Cc: Eric BĂ©nard Signed-off-by: Denis Carikli --- drivers/video/imxfb.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 44ee678..4bf3837 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -145,6 +146,7 @@ struct imxfb_info { struct clk *clk_ipg; struct clk *clk_ahb; struct clk *clk_per; + struct regulator *reg_lcd; enum imxfb_type devtype; bool enabled; @@ -563,12 +565,23 @@ static void imxfb_exit_backlight(struct imxfb_info *fbi) static void imxfb_enable_controller(struct imxfb_info *fbi) { + int ret; if (fbi->enabled) return; pr_debug("Enabling LCD controller\n"); + if (fbi->reg_lcd) { + ret = regulator_enable(fbi->reg_lcd); + if (ret) { + dev_err(&fbi->pdev->dev, + "lcd regulator enable failed with error: %d\n", + ret); + return; + } + } + writel(fbi->screen_dma, fbi->regs + LCDC_SSA); /* panning offset 0 (0 pixel offset) */ @@ -597,6 +610,8 @@ static void imxfb_enable_controller(struct imxfb_info *fbi) static void imxfb_disable_controller(struct imxfb_info *fbi) { + int ret; + if (!fbi->enabled) return; @@ -613,6 +628,14 @@ static void imxfb_disable_controller(struct imxfb_info *fbi) fbi->enabled = false; writel(0, fbi->regs + LCDC_RMCR); + + if (fbi->reg_lcd) { + ret = regulator_disable(fbi->reg_lcd); + if (ret) + dev_err(&fbi->pdev->dev, + "lcd regulator disable failed with error: %d\n", + ret); + } } static int imxfb_blank(int blank, struct fb_info *info) @@ -1020,6 +1043,12 @@ static int imxfb_probe(struct platform_device *pdev) goto failed_register; } + fbi->reg_lcd = devm_regulator_get(&pdev->dev, "lcd"); + if (IS_ERR(fbi->reg_lcd)) { + dev_info(&pdev->dev, "No lcd regulator used.\n"); + fbi->reg_lcd = NULL; + } + imxfb_enable_controller(fbi); fbi->pdev = pdev; #ifdef PWMR_BACKLIGHT_AVAILABLE