Commit 5c694f80 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Bartlomiej Zolnierkiewicz

video: fbdev: imxfb: ensure balanced regulator usage

The fbdev framework doesn't care to call the .set_power callback only on
changes. So the driver has to care for itself that the regulator doesn't
get disabled more often than enabled.

This fixes the regulator warning

	unbalanced disables for lcd supply

which can be triggered by doing

	echo 4 > /sys/class/lcd/imxfb-lcd/lcd_power

twice.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200323211626.24812-1-u.kleine-koenig@pengutronix.de
parent 04dff10f
...@@ -172,6 +172,7 @@ struct imxfb_info { ...@@ -172,6 +172,7 @@ struct imxfb_info {
int num_modes; int num_modes;
struct regulator *lcd_pwr; struct regulator *lcd_pwr;
int lcd_pwr_enabled;
}; };
static const struct platform_device_id imxfb_devtype[] = { static const struct platform_device_id imxfb_devtype[] = {
...@@ -801,16 +802,30 @@ static int imxfb_lcd_get_power(struct lcd_device *lcddev) ...@@ -801,16 +802,30 @@ static int imxfb_lcd_get_power(struct lcd_device *lcddev)
return FB_BLANK_UNBLANK; return FB_BLANK_UNBLANK;
} }
static int imxfb_regulator_set(struct imxfb_info *fbi, int enable)
{
int ret;
if (enable == fbi->lcd_pwr_enabled)
return 0;
if (enable)
ret = regulator_enable(fbi->lcd_pwr);
else
ret = regulator_disable(fbi->lcd_pwr);
if (ret == 0)
fbi->lcd_pwr_enabled = enable;
return ret;
}
static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power) static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power)
{ {
struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev); struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
if (!IS_ERR(fbi->lcd_pwr)) { if (!IS_ERR(fbi->lcd_pwr))
if (power == FB_BLANK_UNBLANK) return imxfb_regulator_set(fbi, power == FB_BLANK_UNBLANK);
return regulator_enable(fbi->lcd_pwr);
else
return regulator_disable(fbi->lcd_pwr);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment