Skip to content

Commit

Permalink
video/atmel_lcdfb: Introduce regulator support
Browse files Browse the repository at this point in the history
This adds regulator support to enable/disable the LCD voltage, using
'lcd-supply' as regulator name.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
  • Loading branch information
Alexander Stein authored and Tomi Valkeinen committed Sep 30, 2014
1 parent a00d91e commit 2d60545
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/video/atmel,lcdc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Required nodes:
- default-mode: a videomode within the display with timing parameters
as specified below.

Optional properties:
- lcd-supply: Regulator for LCD supply voltage.

Example:

fb0: fb@0x00500000 {
Expand Down
20 changes: 20 additions & 0 deletions drivers/video/fbdev/atmel_lcdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <video/of_display_timing.h>
#include <linux/regulator/consumer.h>
#include <video/videomode.h>

#include <mach/cpu.h>
Expand Down Expand Up @@ -60,6 +61,7 @@ struct atmel_lcdfb_info {
struct atmel_lcdfb_pdata pdata;

struct atmel_lcdfb_config *config;
struct regulator *reg_lcd;
};

struct atmel_lcdfb_power_ctrl_gpio {
Expand Down Expand Up @@ -302,10 +304,24 @@ static void init_contrast(struct atmel_lcdfb_info *sinfo)

static inline void atmel_lcdfb_power_control(struct atmel_lcdfb_info *sinfo, int on)
{
int ret;
struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;

if (pdata->atmel_lcdfb_power_control)
pdata->atmel_lcdfb_power_control(pdata, on);
else if (sinfo->reg_lcd) {
if (on) {
ret = regulator_enable(sinfo->reg_lcd);
if (ret)
dev_err(&sinfo->pdev->dev,
"lcd regulator enable failed: %d\n", ret);
} else {
ret = regulator_disable(sinfo->reg_lcd);
if (ret)
dev_err(&sinfo->pdev->dev,
"lcd regulator disable failed: %d\n", ret);
}
}
}

static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = {
Expand Down Expand Up @@ -1193,6 +1209,10 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
if (!sinfo->config)
goto free_info;

sinfo->reg_lcd = devm_regulator_get(&pdev->dev, "lcd");
if (IS_ERR(sinfo->reg_lcd))
sinfo->reg_lcd = NULL;

info->flags = ATMEL_LCDFB_FBINFO_DEFAULT;
info->pseudo_palette = sinfo->pseudo_palette;
info->fbops = &atmel_lcdfb_ops;
Expand Down

0 comments on commit 2d60545

Please sign in to comment.