diff mbox

[U-Boot,v5,20/33] ARM: i.MX6: sabresd: Add dm_gpio_* for backlight

Message ID 1493910702-6751-21-git-send-email-jagan@openedev.com
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Jagan Teki May 4, 2017, 3:11 p.m. UTC
From: Jagan Teki <jagan@amarulasolutions.com>

For OF_CONTROL, gpio's need to configure through
dm_gpio_* calls instead of non-dm gpio code, So
add dm_gpio_* calls for dts supported code.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 board/freescale/mx6sabresd/mx6sabresd.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Fabio Estevam May 11, 2017, 5:23 p.m. UTC | #1
On Thu, May 4, 2017 at 12:11 PM, Jagan Teki <jagan@openedev.com> wrote:
> From: Jagan Teki <jagan@amarulasolutions.com>
>
> For OF_CONTROL, gpio's need to configure through
> dm_gpio_* calls instead of non-dm gpio code, So
> add dm_gpio_* calls for dts supported code.
>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: Michael Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  board/freescale/mx6sabresd/mx6sabresd.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
> index 3f73b9b..1df81b9 100644
> --- a/board/freescale/mx6sabresd/mx6sabresd.c
> +++ b/board/freescale/mx6sabresd/mx6sabresd.c
> @@ -190,7 +190,29 @@ static iomux_v3_cfg_t const bl_pads[] = {
>  static void enable_backlight(void)
>  {
>         imx_iomux_v3_setup_multiple_pads(bl_pads, ARRAY_SIZE(bl_pads));
> +
> +#ifdef CONFIG_OF_CONTROL
> +       struct gpio_desc backlight;
> +       int ret;
> +
> +       /* Set Brightness to high */
> +       ret = dm_gpio_lookup_name("GPIO1_21", &backlight);

Can't we avoid such hardcoded GPIO and use dts to retrieve it?
Jagan Teki May 18, 2017, 8:30 a.m. UTC | #2
On Thu, May 11, 2017 at 10:53 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Thu, May 4, 2017 at 12:11 PM, Jagan Teki <jagan@openedev.com> wrote:
>> From: Jagan Teki <jagan@amarulasolutions.com>
>>
>> For OF_CONTROL, gpio's need to configure through
>> dm_gpio_* calls instead of non-dm gpio code, So
>> add dm_gpio_* calls for dts supported code.
>>
>> Cc: Stefano Babic <sbabic@denx.de>
>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
>> Cc: Michael Trimarchi <michael@amarulasolutions.com>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> ---
>>  board/freescale/mx6sabresd/mx6sabresd.c | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>
>> diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
>> index 3f73b9b..1df81b9 100644
>> --- a/board/freescale/mx6sabresd/mx6sabresd.c
>> +++ b/board/freescale/mx6sabresd/mx6sabresd.c
>> @@ -190,7 +190,29 @@ static iomux_v3_cfg_t const bl_pads[] = {
>>  static void enable_backlight(void)
>>  {
>>         imx_iomux_v3_setup_multiple_pads(bl_pads, ARRAY_SIZE(bl_pads));
>> +
>> +#ifdef CONFIG_OF_CONTROL
>> +       struct gpio_desc backlight;
>> +       int ret;
>> +
>> +       /* Set Brightness to high */
>> +       ret = dm_gpio_lookup_name("GPIO1_21", &backlight);
>
> Can't we avoid such hardcoded GPIO and use dts to retrieve it?

I think this backlight IMX_GPIO_NR(1, 21) gpio is related to board
code here in U-boot, couldn't see the node related to this on dts.

thanks!
Fabio Estevam May 18, 2017, 10:38 a.m. UTC | #3
Hi Jagan,

On Thu, May 18, 2017 at 5:30 AM, Jagan Teki <jagannadh.teki@gmail.com> wrote:

> I think this backlight IMX_GPIO_NR(1, 21) gpio is related to board
> code here in U-boot, couldn't see the node related to this on dts.

In U-Boot MX6QDL_PAD_SD1_DAT3__GPIO1_IO21 is used to as GPIO and when
it is at 1, it sets the backlight with the maximum bright.

In the mainline kernel dts we describe this pin as described as
MX6QDL_PAD_SD1_DAT3__PWM1_OUT and it is used as PWM to drive the
backlight.

Ideally we should also have PWM, backlight support in DM, but if this
is not avalaible today we can use the method you proposed.

Regards,

Fabio Estevam
diff mbox

Patch

diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index 3f73b9b..1df81b9 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -190,7 +190,29 @@  static iomux_v3_cfg_t const bl_pads[] = {
 static void enable_backlight(void)
 {
 	imx_iomux_v3_setup_multiple_pads(bl_pads, ARRAY_SIZE(bl_pads));
+
+#ifdef CONFIG_OF_CONTROL
+	struct gpio_desc backlight;
+	int ret;
+
+	/* Set Brightness to high */
+	ret = dm_gpio_lookup_name("GPIO1_21", &backlight);
+	if (ret) {
+		printf("Cannot get GPIO1_21\n");
+		return;
+	}
+
+	ret = dm_gpio_request(&backlight, "backlight");
+	if (ret) {
+		printf("Cannot request GPIO1_21\n");
+		return;
+	}
+
+	dm_gpio_set_dir_flags(&backlight, GPIOD_IS_OUT);
+	dm_gpio_set_value(&backlight, 1);
+#else
 	gpio_direction_output(DISP0_PWR_EN, 1);
+#endif
 }
 
 static void enable_rgb(struct display_info_t const *dev)