From b255585a90bc3b09084e78dbee43e9431a76ef71 Mon Sep 17 00:00:00 2001 From: Lars Ivar Miljeteig Date: Fri, 17 Apr 2020 14:12:03 +0200 Subject: [PATCH] video: mxsfb: Add support for second lcd supply Searches device tree for lcd2-supply --- drivers/video/fbdev/mxsfb.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 87009eef49f3..0e28d16f8a52 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -252,6 +252,7 @@ struct mxsfb_info { unsigned dotclk_delay; const struct mxsfb_devdata *devdata; struct regulator *reg_lcd; + struct regulator *reg_lcd2; bool wait4vsync; struct completion vsync_complete; struct completion flip_complete; @@ -701,6 +702,15 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) } } + if (host->reg_lcd2) { + ret = regulator_enable(host->reg_lcd2); + if (ret) { + dev_err(&host->pdev->dev, + "lcd2 regulator enable failed: %d\n", ret); + return; + } + } + if (host->dispdrv && host->dispdrv->drv->enable) { ret = host->dispdrv->drv->enable(host->dispdrv, fb_info); if (ret < 0) @@ -729,6 +739,13 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) "lcd regulator disable failed: %d\n", ret); } + if (host->reg_lcd2) { + ret = regulator_disable(host->reg_lcd2); + if (ret) + dev_err(&host->pdev->dev, + "lcd2 regulator disable failed: %d\n", + ret); + } return; } clk_enable_pix(host); @@ -799,6 +816,12 @@ static void mxsfb_disable_controller(struct fb_info *fb_info) dev_err(&host->pdev->dev, "lcd regulator disable failed: %d\n", ret); } + if (host->reg_lcd2) { + ret = regulator_disable(host->reg_lcd2); + if (ret) + dev_err(&host->pdev->dev, + "lcd2 regulator disable failed: %d\n", ret); + } } /** @@ -2256,6 +2279,20 @@ static int mxsfb_probe(struct platform_device *pdev) } } + host->reg_lcd2 = devm_regulator_get(&pdev->dev, "lcd2"); + if (IS_ERR(host->reg_lcd2)) { + ret = PTR_ERR(host->reg_lcd2); + if (ret == -EPROBE_DEFER) { + dev_warn(&pdev->dev, "lcd2-supply not ready, deferring\n"); + goto fb_release; + } else { + dev_err(&pdev->dev, + "Failed to get lcd2-supply (errno %d), ignoring\n", + ret); + host->reg_lcd2 = NULL; + } + } + ret = devm_request_irq(&pdev->dev, irq, mxsfb_irq_handler, 0, dev_name(&pdev->dev), host); if (ret) {