diff mbox

[U-Boot,V2,3/8] video: exynos_fb: configure backlight GPIOs if specified in DT

Message ID 1425391409-25576-4-git-send-email-ajaykumar.rs@samsung.com
State Superseded
Headers show

Commit Message

Ajay Kumar March 3, 2015, 2:03 p.m. UTC
Add support to configure PWM_OUT(PWM output) GPIO and
BL_EN(backlight enable) GPIO, if provided in FIMD DT node.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
---
 doc/device-tree-bindings/video/exynos-fb.txt |    2 ++
 drivers/video/exynos_fb.c                    |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Simon Glass March 3, 2015, 3:04 p.m. UTC | #1
Hi Ajay,

On 3 March 2015 at 07:03, Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
> Add support to configure PWM_OUT(PWM output) GPIO and
> BL_EN(backlight enable) GPIO, if provided in FIMD DT node.
>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
> ---
>  doc/device-tree-bindings/video/exynos-fb.txt |    2 ++
>  drivers/video/exynos_fb.c                    |   23 +++++++++++++++++++++++
>  2 files changed, 25 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
(with one suggested change below)

Tested on Pi.

Tested-by: Simon Glass <sjg@chromium.org>


> diff --git a/doc/device-tree-bindings/video/exynos-fb.txt b/doc/device-tree-bindings/video/exynos-fb.txt
> index dc4e44f..b022f61 100644
> --- a/doc/device-tree-bindings/video/exynos-fb.txt
> +++ b/doc/device-tree-bindings/video/exynos-fb.txt
> @@ -61,6 +61,8 @@ Board(panel specific):
>                                 disabled with compatible string
>                                 "samsung,sysmmu-v3.3", with a "reg" property
>                                 holding the register address of FIMD sysmmu.
> +       samsung,pwm-out-gpio: PWM output GPIO.
> +       samsung,bl-en-gpio: backlight enable GPIO.
>
>  Example:
>  SOC specific part:
> diff --git a/drivers/video/exynos_fb.c b/drivers/video/exynos_fb.c
> index c5d7330..be85ed8 100644
> --- a/drivers/video/exynos_fb.c
> +++ b/drivers/video/exynos_fb.c
> @@ -19,6 +19,7 @@
>  #include <asm/arch/mipi_dsim.h>
>  #include <asm/arch/dp_info.h>
>  #include <asm/arch/system.h>
> +#include <asm/gpio.h>
>  #include <asm-generic/errno.h>
>
>  #include "exynos_fb.h"
> @@ -102,6 +103,10 @@ __weak int exynos_lcd_misc_init(vidinfo_t *vid)
>
>  static void lcd_panel_on(vidinfo_t *vid)
>  {
> +       struct gpio_desc pwm_out_gpio;
> +       struct gpio_desc bl_en_gpio;
> +       unsigned int node;
> +
>         udelay(vid->init_delay);
>
>         exynos_backlight_reset();
> @@ -121,6 +126,24 @@ static void lcd_panel_on(vidinfo_t *vid)
>
>         exynos_backlight_on(1);
>
> +#ifdef CONFIG_OF_CONTROL
> +       node = fdtdec_next_compatible(gd->fdt_blob, 0,
> +                                               COMPAT_SAMSUNG_EXYNOS_FIMD);
> +       if (node <= 0) {
> +               debug("FIMD: Can't get device node for FIMD\n");
> +               return;
> +       }
> +       gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,pwm-out-gpio",
> +                                  0, &pwm_out_gpio, GPIOD_IS_OUT);
> +       if (dm_gpio_is_valid(&pwm_out_gpio))
> +               dm_gpio_set_value(&pwm_out_gpio, 1);

Instead of these two lines you can use GPIOD_IS_OUT |
GPIOD_IS_OUT_ACTIVE in the call above. That will make the GPIO an
output and set it high.

> +
> +       gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,bl-en-gpio", 0,
> +                                  &bl_en_gpio, GPIOD_IS_OUT);
> +       if (dm_gpio_is_valid(&bl_en_gpio))
> +               dm_gpio_set_value(&bl_en_gpio, 1);

Here also.

> +
> +#endif
>         exynos_cfg_ldo();
>
>         exynos_enable_ldo(1);
> --
> 1.7.9.5
>

Regards,
SIimon
diff mbox

Patch

diff --git a/doc/device-tree-bindings/video/exynos-fb.txt b/doc/device-tree-bindings/video/exynos-fb.txt
index dc4e44f..b022f61 100644
--- a/doc/device-tree-bindings/video/exynos-fb.txt
+++ b/doc/device-tree-bindings/video/exynos-fb.txt
@@ -61,6 +61,8 @@  Board(panel specific):
 				disabled with compatible string
 				"samsung,sysmmu-v3.3", with a "reg" property
 				holding the register address of FIMD sysmmu.
+	samsung,pwm-out-gpio: PWM output GPIO.
+	samsung,bl-en-gpio: backlight enable GPIO.
 
 Example:
 SOC specific part:
diff --git a/drivers/video/exynos_fb.c b/drivers/video/exynos_fb.c
index c5d7330..be85ed8 100644
--- a/drivers/video/exynos_fb.c
+++ b/drivers/video/exynos_fb.c
@@ -19,6 +19,7 @@ 
 #include <asm/arch/mipi_dsim.h>
 #include <asm/arch/dp_info.h>
 #include <asm/arch/system.h>
+#include <asm/gpio.h>
 #include <asm-generic/errno.h>
 
 #include "exynos_fb.h"
@@ -102,6 +103,10 @@  __weak int exynos_lcd_misc_init(vidinfo_t *vid)
 
 static void lcd_panel_on(vidinfo_t *vid)
 {
+	struct gpio_desc pwm_out_gpio;
+	struct gpio_desc bl_en_gpio;
+	unsigned int node;
+
 	udelay(vid->init_delay);
 
 	exynos_backlight_reset();
@@ -121,6 +126,24 @@  static void lcd_panel_on(vidinfo_t *vid)
 
 	exynos_backlight_on(1);
 
+#ifdef CONFIG_OF_CONTROL
+	node = fdtdec_next_compatible(gd->fdt_blob, 0,
+						COMPAT_SAMSUNG_EXYNOS_FIMD);
+	if (node <= 0) {
+		debug("FIMD: Can't get device node for FIMD\n");
+		return;
+	}
+	gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,pwm-out-gpio",
+				   0, &pwm_out_gpio, GPIOD_IS_OUT);
+	if (dm_gpio_is_valid(&pwm_out_gpio))
+		dm_gpio_set_value(&pwm_out_gpio, 1);
+
+	gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,bl-en-gpio", 0,
+				   &bl_en_gpio, GPIOD_IS_OUT);
+	if (dm_gpio_is_valid(&bl_en_gpio))
+		dm_gpio_set_value(&bl_en_gpio, 1);
+
+#endif
 	exynos_cfg_ldo();
 
 	exynos_enable_ldo(1);