From patchwork Tue Nov 5 14:39:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis Carikli X-Patchwork-Id: 288549 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6C9F22C00A9 for ; Wed, 6 Nov 2013 01:40:06 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdhnR-0005B5-Gj; Tue, 05 Nov 2013 14:39:57 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdhnP-00045x-2g; Tue, 05 Nov 2013 14:39:55 +0000 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdhnK-00045B-09 for linux-arm-kernel@lists.infradead.org; Tue, 05 Nov 2013 14:39:51 +0000 Received: from denis-N73SV.local.eukrea.com (unknown [88.170.243.169]) by smtp4-g21.free.fr (Postfix) with ESMTP id 434F64C821F; Tue, 5 Nov 2013 15:39:17 +0100 (CET) From: Denis Carikli To: Shawn Guo Subject: [PATCHv11][ 1/7] video: imxfb: Introduce regulator support. Date: Tue, 5 Nov 2013 15:39:08 +0100 Message-Id: <1383662354-22417-1-git-send-email-denis@eukrea.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131105_093950_732849_9316DCD0 X-CRM114-Status: GOOD ( 13.12 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fabio Estevam , linux-fbdev@vger.kernel.org, =?UTF-8?q?Eric=20B=C3=A9nard?= , Denis Carikli , Tomi Valkeinen , Sascha Hauer , Jean-Christophe Plagniol-Villard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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 --- ChangeLog v9->v10: - Added a return 0; at the end of imxfb_disable_controller. ChangeLog v8->v9: - return an error if regulator_{enable,disable} fails in imxfb_{enable,disable}_controller, and use it. --- drivers/video/imxfb.c | 55 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 38733ac..a2fe8bd 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; @@ -561,14 +563,25 @@ static void imxfb_exit_backlight(struct imxfb_info *fbi) } #endif -static void imxfb_enable_controller(struct imxfb_info *fbi) +static int imxfb_enable_controller(struct imxfb_info *fbi) { + int ret; if (fbi->enabled) - return; + return 0; 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 ret; + } + } + writel(fbi->screen_dma, fbi->regs + LCDC_SSA); /* panning offset 0 (0 pixel offset) */ @@ -593,12 +606,16 @@ static void imxfb_enable_controller(struct imxfb_info *fbi) fbi->backlight_power(1); if (fbi->lcd_power) fbi->lcd_power(1); + + return 0; } -static void imxfb_disable_controller(struct imxfb_info *fbi) +static int imxfb_disable_controller(struct imxfb_info *fbi) { + int ret; + if (!fbi->enabled) - return; + return 0; pr_debug("Disabling LCD controller\n"); @@ -613,6 +630,17 @@ 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); + return ret; + } + + return 0; } static int imxfb_blank(int blank, struct fb_info *info) @@ -626,13 +654,12 @@ static int imxfb_blank(int blank, struct fb_info *info) case FB_BLANK_VSYNC_SUSPEND: case FB_BLANK_HSYNC_SUSPEND: case FB_BLANK_NORMAL: - imxfb_disable_controller(fbi); - break; + return imxfb_disable_controller(fbi); case FB_BLANK_UNBLANK: - imxfb_enable_controller(fbi); - break; + return imxfb_enable_controller(fbi); } + return 0; } @@ -734,8 +761,7 @@ static int imxfb_suspend(struct platform_device *dev, pm_message_t state) pr_debug("%s\n", __func__); - imxfb_disable_controller(fbi); - return 0; + return imxfb_disable_controller(fbi); } static int imxfb_resume(struct platform_device *dev) @@ -745,8 +771,7 @@ static int imxfb_resume(struct platform_device *dev) pr_debug("%s\n", __func__); - imxfb_enable_controller(fbi); - return 0; + return imxfb_enable_controller(fbi); } #else #define imxfb_suspend NULL @@ -1020,6 +1045,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