drm/omap: displays: panel-dpi: Support for handling backlight devices

The associated backlight device can be configured via DT by providing the
phandle to the device.

If the backlight device is configured, the driver can manage the backligt
along with the panel's power state, iow it can turn on the backlight when
the panel is enabled and turn it off when the panel is disabled.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
Peter Ujfalusi 2016-09-09 13:33:06 +03:00 committed by Tomi Valkeinen
parent 4573ebe5ec
commit 39135a305a
2 changed files with 38 additions and 2 deletions

View File

@ -9,6 +9,7 @@ Optional properties:
- enable-gpios: panel enable gpio - enable-gpios: panel enable gpio
- reset-gpios: GPIO to control the RESET pin - reset-gpios: GPIO to control the RESET pin
- vcc-supply: phandle of regulator that will be used to enable power to the display - vcc-supply: phandle of regulator that will be used to enable power to the display
- backlight: phandle of the backlight device
Required nodes: Required nodes:
- "panel-timing" containing video timings - "panel-timing" containing video timings
@ -22,6 +23,8 @@ lcd0: display@0 {
compatible = "samsung,lte430wq-f0c", "panel-dpi"; compatible = "samsung,lte430wq-f0c", "panel-dpi";
label = "lcd"; label = "lcd";
backlight = <&backlight>;
port { port {
lcd_in: endpoint { lcd_in: endpoint {
remote-endpoint = <&dpi_out>; remote-endpoint = <&dpi_out>;

View File

@ -16,6 +16,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/backlight.h>
#include <video/omap-panel-data.h> #include <video/omap-panel-data.h>
#include <video/of_display_timing.h> #include <video/of_display_timing.h>
@ -30,6 +31,8 @@ struct panel_drv_data {
struct videomode vm; struct videomode vm;
struct backlight_device *backlight;
/* used for non-DT boot, to be removed */ /* used for non-DT boot, to be removed */
int backlight_gpio; int backlight_gpio;
@ -97,6 +100,11 @@ static int panel_dpi_enable(struct omap_dss_device *dssdev)
if (gpio_is_valid(ddata->backlight_gpio)) if (gpio_is_valid(ddata->backlight_gpio))
gpio_set_value_cansleep(ddata->backlight_gpio, 1); gpio_set_value_cansleep(ddata->backlight_gpio, 1);
if (ddata->backlight) {
ddata->backlight->props.power = FB_BLANK_UNBLANK;
backlight_update_status(ddata->backlight);
}
dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
return 0; return 0;
@ -113,6 +121,11 @@ static void panel_dpi_disable(struct omap_dss_device *dssdev)
if (gpio_is_valid(ddata->backlight_gpio)) if (gpio_is_valid(ddata->backlight_gpio))
gpio_set_value_cansleep(ddata->backlight_gpio, 0); gpio_set_value_cansleep(ddata->backlight_gpio, 0);
if (ddata->backlight) {
ddata->backlight->props.power = FB_BLANK_POWERDOWN;
backlight_update_status(ddata->backlight);
}
gpiod_set_value_cansleep(ddata->enable_gpio, 0); gpiod_set_value_cansleep(ddata->enable_gpio, 0);
regulator_disable(ddata->vcc_supply); regulator_disable(ddata->vcc_supply);
@ -209,6 +222,7 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
{ {
struct panel_drv_data *ddata = platform_get_drvdata(pdev); struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
struct device_node *bl_node;
struct omap_dss_device *in; struct omap_dss_device *in;
int r; int r;
struct display_timing timing; struct display_timing timing;
@ -236,10 +250,19 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
ddata->backlight_gpio = -ENOENT; ddata->backlight_gpio = -ENOENT;
bl_node = of_parse_phandle(node, "backlight", 0);
if (bl_node) {
ddata->backlight = of_find_backlight_by_node(bl_node);
of_node_put(bl_node);
if (!ddata->backlight)
return -EPROBE_DEFER;
}
r = of_get_display_timing(node, "panel-timing", &timing); r = of_get_display_timing(node, "panel-timing", &timing);
if (r) { if (r) {
dev_err(&pdev->dev, "failed to get video timing\n"); dev_err(&pdev->dev, "failed to get video timing\n");
return r; goto error_free_backlight;
} }
videomode_from_timing(&timing, &ddata->vm); videomode_from_timing(&timing, &ddata->vm);
@ -247,12 +270,19 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
in = omapdss_of_find_source_for_first_ep(node); in = omapdss_of_find_source_for_first_ep(node);
if (IS_ERR(in)) { if (IS_ERR(in)) {
dev_err(&pdev->dev, "failed to find video source\n"); dev_err(&pdev->dev, "failed to find video source\n");
return PTR_ERR(in); r = PTR_ERR(in);
goto error_free_backlight;
} }
ddata->in = in; ddata->in = in;
return 0; return 0;
error_free_backlight:
if (ddata->backlight)
put_device(&ddata->backlight->dev);
return r;
} }
static int panel_dpi_probe(struct platform_device *pdev) static int panel_dpi_probe(struct platform_device *pdev)
@ -321,6 +351,9 @@ static int __exit panel_dpi_remove(struct platform_device *pdev)
omap_dss_put_device(in); omap_dss_put_device(in);
if (ddata->backlight)
put_device(&ddata->backlight->dev);
return 0; return 0;
} }