From patchwork Thu Oct 17 15:02:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis Carikli X-Patchwork-Id: 3062171 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 B58CFBF924 for ; Thu, 17 Oct 2013 16:53:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78CAA20461 for ; Thu, 17 Oct 2013 16:53:41 +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 C6E4C20398 for ; Thu, 17 Oct 2013 16:53:39 +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 1VWp9i-00035M-MG; Thu, 17 Oct 2013 15:06:31 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWp8y-0008Jn-R7; Thu, 17 Oct 2013 15:05:44 +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 1VWp7l-00086t-ML for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2013 15:04:33 +0000 Received: from denis-N73SV.local.eukrea.com (unknown [88.170.243.169]) by smtp4-g21.free.fr (Postfix) with ESMTP id 246344C8226; Thu, 17 Oct 2013 17:03:20 +0200 (CEST) From: Denis Carikli To: Sascha Hauer Subject: [Patch v2][ 07/37] video: mx3fb: Introduce regulator support. Date: Thu, 17 Oct 2013 17:02:05 +0200 Message-Id: <1382022155-21954-8-git-send-email-denis@eukrea.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382022155-21954-1-git-send-email-denis@eukrea.com> References: <1382022155-21954-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-20131017_110430_439151_404622BE X-CRM114-Status: GOOD ( 13.46 ) X-Spam-Score: -1.2 (-) Cc: linux-fbdev@vger.kernel.org, Denis Carikli , Tomi Valkeinen , =?UTF-8?q?Eric=20B=C3=A9nard?= , 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-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.6 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 This commit is based on the following commit by Fabio Estevam: 4344429 video: mxsfb: Introduce regulator support Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: linux-fbdev@vger.kernel.org Cc: Sascha Hauer Cc: linux-arm-kernel@lists.infradead.org Cc: Eric BĂ©nard Signed-off-by: Denis Carikli --- drivers/video/mx3fb.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c index 804f874..37704da 100644 --- a/drivers/video/mx3fb.c +++ b/drivers/video/mx3fb.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -267,6 +268,7 @@ struct mx3fb_info { struct dma_async_tx_descriptor *txd; dma_cookie_t cookie; struct scatterlist sg[2]; + struct regulator *reg_lcd; struct fb_var_screeninfo cur_var; /* current var info */ }; @@ -1001,6 +1003,7 @@ static void __blank(int blank, struct fb_info *fbi) struct mx3fb_info *mx3_fbi = fbi->par; struct mx3fb_data *mx3fb = mx3_fbi->mx3fb; int was_blank = mx3_fbi->blank; + int ret; mx3_fbi->blank = blank; @@ -1019,6 +1022,15 @@ static void __blank(int blank, struct fb_info *fbi) case FB_BLANK_HSYNC_SUSPEND: case FB_BLANK_NORMAL: sdc_set_brightness(mx3fb, 0); + if (mx3_fbi->reg_lcd) { + if (regulator_is_enabled(mx3_fbi->reg_lcd)) { + ret = regulator_disable(mx3_fbi->reg_lcd); + if (ret) + dev_warn(fbi->device, + "lcd regulator disable failed " + "with error: %d\n", ret); + } + } memset((char *)fbi->screen_base, 0, fbi->fix.smem_len); /* Give LCD time to update - enough for 50 and 60 Hz */ msleep(25); @@ -1026,7 +1038,17 @@ static void __blank(int blank, struct fb_info *fbi) break; case FB_BLANK_UNBLANK: sdc_enable_channel(mx3_fbi); + if (mx3_fbi->reg_lcd) { + if (!regulator_is_enabled(mx3_fbi->reg_lcd)) { + ret = regulator_enable(mx3_fbi->reg_lcd); + if (ret) + dev_warn(fbi->device, + "lcd regulator enable failed " + "with error: %d\n", ret); + } + } sdc_set_brightness(mx3fb, mx3fb->backlight_level); + break; } } @@ -1202,6 +1224,7 @@ static int mx3fb_suspend(struct platform_device *pdev, pm_message_t state) { struct mx3fb_data *mx3fb = platform_get_drvdata(pdev); struct mx3fb_info *mx3_fbi = mx3fb->fbi->par; + int ret; console_lock(); fb_set_suspend(mx3fb->fbi, 1); @@ -1210,7 +1233,15 @@ static int mx3fb_suspend(struct platform_device *pdev, pm_message_t state) if (mx3_fbi->blank == FB_BLANK_UNBLANK) { sdc_disable_channel(mx3_fbi); sdc_set_brightness(mx3fb, 0); - + if (mx3_fbi->reg_lcd) { + if (regulator_is_enabled(mx3_fbi->reg_lcd)) { + ret = regulator_disable(mx3_fbi->reg_lcd); + if (ret) + dev_warn(&pdev->dev, + "lcd regulator disable failed " + "with error: %d\n", ret); + } + } } return 0; } @@ -1222,10 +1253,20 @@ static int mx3fb_resume(struct platform_device *pdev) { struct mx3fb_data *mx3fb = platform_get_drvdata(pdev); struct mx3fb_info *mx3_fbi = mx3fb->fbi->par; + int ret; if (mx3_fbi->blank == FB_BLANK_UNBLANK) { sdc_enable_channel(mx3_fbi); sdc_set_brightness(mx3fb, mx3fb->backlight_level); + if (mx3_fbi->reg_lcd) { + if (!regulator_is_enabled(mx3_fbi->reg_lcd)) { + ret = regulator_enable(mx3_fbi->reg_lcd); + if (ret) + dev_warn(&pdev->dev, + "lcd regulator enable failed " + "with error: %d\n", ret); + } + } } console_lock(); @@ -1438,6 +1479,10 @@ static int init_fb_chan(struct mx3fb_data *mx3fb, struct idmac_channel *ichan) if (ret < 0) goto erfb; + mx3fbi->reg_lcd = devm_regulator_get(dev, "lcd"); + if (IS_ERR(mx3fbi->reg_lcd)) + mx3fbi->reg_lcd = NULL; + return 0; erfb: