diff options
author | Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> | 2014-09-02 08:51:22 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2014-09-16 20:55:27 -0400 |
commit | d898ce03675fc061f89a347a22d41271ed75c436 (patch) | |
tree | 80613f595ddcfe9dc6dd46c5178878c32b3095dd | |
parent | 12778fc14301cf24d79cd89b0129874c319d0a38 (diff) |
drm/tilcdc: panel: Add support for enable GPIO
In order to support the "enable GPIO" available in many panel devices,
this commit adds a proper devicetree binding.
By providing an enable GPIO in the devicetree, the driver can now turn
off and on the panel device, and/or the backlight device. Both the
backlight and the GPIO are optional properties.
Tested-by: Darren Etheridge <detheridge@ti.com>
Tested-by: Johannes Pointner <johannes.pointner@br-automation.com>
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | Documentation/devicetree/bindings/drm/tilcdc/panel.txt | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_panel.c | 37 |
2 files changed, 34 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/drm/tilcdc/panel.txt b/Documentation/devicetree/bindings/drm/tilcdc/panel.txt index 10a06e826b4a..4ab9e2300907 100644 --- a/Documentation/devicetree/bindings/drm/tilcdc/panel.txt +++ b/Documentation/devicetree/bindings/drm/tilcdc/panel.txt | |||
@@ -20,6 +20,7 @@ Required properties: | |||
20 | 20 | ||
21 | Optional properties: | 21 | Optional properties: |
22 | - backlight: phandle of the backlight device attached to the panel | 22 | - backlight: phandle of the backlight device attached to the panel |
23 | - enable-gpios: GPIO pin to enable or disable the panel | ||
23 | 24 | ||
24 | Recommended properties: | 25 | Recommended properties: |
25 | - pinctrl-names, pinctrl-0: the pincontrol settings to configure | 26 | - pinctrl-names, pinctrl-0: the pincontrol settings to configure |
@@ -33,6 +34,7 @@ Example: | |||
33 | pinctrl-names = "default"; | 34 | pinctrl-names = "default"; |
34 | pinctrl-0 = <&bone_lcd3_cape_lcd_pins>; | 35 | pinctrl-0 = <&bone_lcd3_cape_lcd_pins>; |
35 | backlight = <&backlight>; | 36 | backlight = <&backlight>; |
37 | enable-gpios = <&gpio3 19 0>; | ||
36 | 38 | ||
37 | panel-info { | 39 | panel-info { |
38 | ac-bias = <255>; | 40 | ac-bias = <255>; |
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index f2a5b23782fa..7a0315855e90 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/pinctrl/pinmux.h> | 18 | #include <linux/pinctrl/pinmux.h> |
19 | #include <linux/pinctrl/consumer.h> | 19 | #include <linux/pinctrl/consumer.h> |
20 | #include <linux/backlight.h> | 20 | #include <linux/backlight.h> |
21 | #include <linux/gpio/consumer.h> | ||
21 | #include <video/display_timing.h> | 22 | #include <video/display_timing.h> |
22 | #include <video/of_display_timing.h> | 23 | #include <video/of_display_timing.h> |
23 | #include <video/videomode.h> | 24 | #include <video/videomode.h> |
@@ -29,6 +30,7 @@ struct panel_module { | |||
29 | struct tilcdc_panel_info *info; | 30 | struct tilcdc_panel_info *info; |
30 | struct display_timings *timings; | 31 | struct display_timings *timings; |
31 | struct backlight_device *backlight; | 32 | struct backlight_device *backlight; |
33 | struct gpio_desc *enable_gpio; | ||
32 | }; | 34 | }; |
33 | #define to_panel_module(x) container_of(x, struct panel_module, base) | 35 | #define to_panel_module(x) container_of(x, struct panel_module, base) |
34 | 36 | ||
@@ -55,13 +57,17 @@ static void panel_encoder_dpms(struct drm_encoder *encoder, int mode) | |||
55 | { | 57 | { |
56 | struct panel_encoder *panel_encoder = to_panel_encoder(encoder); | 58 | struct panel_encoder *panel_encoder = to_panel_encoder(encoder); |
57 | struct backlight_device *backlight = panel_encoder->mod->backlight; | 59 | struct backlight_device *backlight = panel_encoder->mod->backlight; |
60 | struct gpio_desc *gpio = panel_encoder->mod->enable_gpio; | ||
58 | 61 | ||
59 | if (!backlight) | 62 | if (backlight) { |
60 | return; | 63 | backlight->props.power = mode == DRM_MODE_DPMS_ON ? |
64 | FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | ||
65 | backlight_update_status(backlight); | ||
66 | } | ||
61 | 67 | ||
62 | backlight->props.power = mode == DRM_MODE_DPMS_ON | 68 | if (gpio) |
63 | ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 69 | gpiod_set_value_cansleep(gpio, |
64 | backlight_update_status(backlight); | 70 | mode == DRM_MODE_DPMS_ON ? 1 : 0); |
65 | } | 71 | } |
66 | 72 | ||
67 | static bool panel_encoder_mode_fixup(struct drm_encoder *encoder, | 73 | static bool panel_encoder_mode_fixup(struct drm_encoder *encoder, |
@@ -369,6 +375,25 @@ static int panel_probe(struct platform_device *pdev) | |||
369 | dev_info(&pdev->dev, "found backlight\n"); | 375 | dev_info(&pdev->dev, "found backlight\n"); |
370 | } | 376 | } |
371 | 377 | ||
378 | panel_mod->enable_gpio = devm_gpiod_get(&pdev->dev, "enable"); | ||
379 | if (IS_ERR(panel_mod->enable_gpio)) { | ||
380 | ret = PTR_ERR(panel_mod->enable_gpio); | ||
381 | if (ret != -ENOENT) { | ||
382 | dev_err(&pdev->dev, "failed to request enable GPIO\n"); | ||
383 | goto fail_backlight; | ||
384 | } | ||
385 | |||
386 | /* Optional GPIO is not here, continue silently. */ | ||
387 | panel_mod->enable_gpio = NULL; | ||
388 | } else { | ||
389 | ret = gpiod_direction_output(panel_mod->enable_gpio, 0); | ||
390 | if (ret < 0) { | ||
391 | dev_err(&pdev->dev, "failed to setup GPIO\n"); | ||
392 | goto fail_backlight; | ||
393 | } | ||
394 | dev_info(&pdev->dev, "found enable GPIO\n"); | ||
395 | } | ||
396 | |||
372 | mod = &panel_mod->base; | 397 | mod = &panel_mod->base; |
373 | pdev->dev.platform_data = mod; | 398 | pdev->dev.platform_data = mod; |
374 | 399 | ||
@@ -401,6 +426,8 @@ fail_timings: | |||
401 | 426 | ||
402 | fail_free: | 427 | fail_free: |
403 | tilcdc_module_cleanup(mod); | 428 | tilcdc_module_cleanup(mod); |
429 | |||
430 | fail_backlight: | ||
404 | if (panel_mod->backlight) | 431 | if (panel_mod->backlight) |
405 | put_device(&panel_mod->backlight->dev); | 432 | put_device(&panel_mod->backlight->dev); |
406 | return ret; | 433 | return ret; |