aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2016-09-09 06:33:06 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-04-03 05:36:40 -0400
commit39135a305a0f0a82d60ceb79dcbf094fc4e70123 (patch)
tree8054c0f96d988a9fb34d0e1d3a1a78c1e85ae426
parent4573ebe5ec3121dd4e6f3e8f0c5feba01a235251 (diff)
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>
-rw-r--r--Documentation/devicetree/bindings/display/panel/panel-dpi.txt3
-rw-r--r--drivers/gpu/drm/omapdrm/displays/panel-dpi.c37
2 files changed, 38 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/display/panel/panel-dpi.txt b/Documentation/devicetree/bindings/display/panel/panel-dpi.txt
index d4add13e592d..6b203bc4d932 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-dpi.txt
+++ b/Documentation/devicetree/bindings/display/panel/panel-dpi.txt
@@ -9,6 +9,7 @@ Optional properties:
9- enable-gpios: panel enable gpio 9- enable-gpios: panel enable gpio
10- reset-gpios: GPIO to control the RESET pin 10- reset-gpios: GPIO to control the RESET pin
11- vcc-supply: phandle of regulator that will be used to enable power to the display 11- vcc-supply: phandle of regulator that will be used to enable power to the display
12- backlight: phandle of the backlight device
12 13
13Required nodes: 14Required nodes:
14- "panel-timing" containing video timings 15- "panel-timing" containing video timings
@@ -22,6 +23,8 @@ lcd0: display@0 {
22 compatible = "samsung,lte430wq-f0c", "panel-dpi"; 23 compatible = "samsung,lte430wq-f0c", "panel-dpi";
23 label = "lcd"; 24 label = "lcd";
24 25
26 backlight = <&backlight>;
27
25 port { 28 port {
26 lcd_in: endpoint { 29 lcd_in: endpoint {
27 remote-endpoint = <&dpi_out>; 30 remote-endpoint = <&dpi_out>;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 38003208d9ca..04ce8c5f2954 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -16,6 +16,7 @@
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/of_gpio.h> 17#include <linux/of_gpio.h>
18#include <linux/regulator/consumer.h> 18#include <linux/regulator/consumer.h>
19#include <linux/backlight.h>
19 20
20#include <video/omap-panel-data.h> 21#include <video/omap-panel-data.h>
21#include <video/of_display_timing.h> 22#include <video/of_display_timing.h>
@@ -30,6 +31,8 @@ struct panel_drv_data {
30 31
31 struct videomode vm; 32 struct videomode vm;
32 33
34 struct backlight_device *backlight;
35
33 /* used for non-DT boot, to be removed */ 36 /* used for non-DT boot, to be removed */
34 int backlight_gpio; 37 int backlight_gpio;
35 38
@@ -97,6 +100,11 @@ static int panel_dpi_enable(struct omap_dss_device *dssdev)
97 if (gpio_is_valid(ddata->backlight_gpio)) 100 if (gpio_is_valid(ddata->backlight_gpio))
98 gpio_set_value_cansleep(ddata->backlight_gpio, 1); 101 gpio_set_value_cansleep(ddata->backlight_gpio, 1);
99 102
103 if (ddata->backlight) {
104 ddata->backlight->props.power = FB_BLANK_UNBLANK;
105 backlight_update_status(ddata->backlight);
106 }
107
100 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; 108 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
101 109
102 return 0; 110 return 0;
@@ -113,6 +121,11 @@ static void panel_dpi_disable(struct omap_dss_device *dssdev)
113 if (gpio_is_valid(ddata->backlight_gpio)) 121 if (gpio_is_valid(ddata->backlight_gpio))
114 gpio_set_value_cansleep(ddata->backlight_gpio, 0); 122 gpio_set_value_cansleep(ddata->backlight_gpio, 0);
115 123
124 if (ddata->backlight) {
125 ddata->backlight->props.power = FB_BLANK_POWERDOWN;
126 backlight_update_status(ddata->backlight);
127 }
128
116 gpiod_set_value_cansleep(ddata->enable_gpio, 0); 129 gpiod_set_value_cansleep(ddata->enable_gpio, 0);
117 regulator_disable(ddata->vcc_supply); 130 regulator_disable(ddata->vcc_supply);
118 131
@@ -209,6 +222,7 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
209{ 222{
210 struct panel_drv_data *ddata = platform_get_drvdata(pdev); 223 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
211 struct device_node *node = pdev->dev.of_node; 224 struct device_node *node = pdev->dev.of_node;
225 struct device_node *bl_node;
212 struct omap_dss_device *in; 226 struct omap_dss_device *in;
213 int r; 227 int r;
214 struct display_timing timing; 228 struct display_timing timing;
@@ -236,10 +250,19 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
236 250
237 ddata->backlight_gpio = -ENOENT; 251 ddata->backlight_gpio = -ENOENT;
238 252
253 bl_node = of_parse_phandle(node, "backlight", 0);
254 if (bl_node) {
255 ddata->backlight = of_find_backlight_by_node(bl_node);
256 of_node_put(bl_node);
257
258 if (!ddata->backlight)
259 return -EPROBE_DEFER;
260 }
261
239 r = of_get_display_timing(node, "panel-timing", &timing); 262 r = of_get_display_timing(node, "panel-timing", &timing);
240 if (r) { 263 if (r) {
241 dev_err(&pdev->dev, "failed to get video timing\n"); 264 dev_err(&pdev->dev, "failed to get video timing\n");
242 return r; 265 goto error_free_backlight;
243 } 266 }
244 267
245 videomode_from_timing(&timing, &ddata->vm); 268 videomode_from_timing(&timing, &ddata->vm);
@@ -247,12 +270,19 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
247 in = omapdss_of_find_source_for_first_ep(node); 270 in = omapdss_of_find_source_for_first_ep(node);
248 if (IS_ERR(in)) { 271 if (IS_ERR(in)) {
249 dev_err(&pdev->dev, "failed to find video source\n"); 272 dev_err(&pdev->dev, "failed to find video source\n");
250 return PTR_ERR(in); 273 r = PTR_ERR(in);
274 goto error_free_backlight;
251 } 275 }
252 276
253 ddata->in = in; 277 ddata->in = in;
254 278
255 return 0; 279 return 0;
280
281error_free_backlight:
282 if (ddata->backlight)
283 put_device(&ddata->backlight->dev);
284
285 return r;
256} 286}
257 287
258static int panel_dpi_probe(struct platform_device *pdev) 288static int panel_dpi_probe(struct platform_device *pdev)
@@ -321,6 +351,9 @@ static int __exit panel_dpi_remove(struct platform_device *pdev)
321 351
322 omap_dss_put_device(in); 352 omap_dss_put_device(in);
323 353
354 if (ddata->backlight)
355 put_device(&ddata->backlight->dev);
356
324 return 0; 357 return 0;
325} 358}
326 359