public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Eric Bénard" <eric@eukrea.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/7] gpio-led: Fix __led_toggle support to first set GPIO as input
Date: Sat, 28 Sep 2013 15:12:53 +0200	[thread overview]
Message-ID: <20130928151253.0c59b8dc@e6520eb> (raw)
In-Reply-To: <1380338659-7896-5-git-send-email-otavio@ossystems.com.br>

Hi Otavio,

Le Sat, 28 Sep 2013 00:24:16 -0300,
Otavio Salvador <otavio@ossystems.com.br> a ?crit :

> The GPIO need to be set as input before reading its current value and
> set back to output for setting it; this fixes the non-working
> 'led <id> toggle' for GPIO based LEDs.
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
>  drivers/misc/gpio_led.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/gpio_led.c b/drivers/misc/gpio_led.c
> index 6afb986..1882751 100644
> --- a/drivers/misc/gpio_led.c
> +++ b/drivers/misc/gpio_led.c
> @@ -22,5 +22,6 @@ void __led_set(led_id_t mask, int state)
>  
>  void __led_toggle(led_id_t mask)
>  {
> -	gpio_set_value(mask, !gpio_get_value(mask));
> +	gpio_direction_input(mask);
> +	__led_set(mask, !gpio_get_value(mask));
>  }

How can that work on a hardware point of view ?
If you configure the gpio as an input it isn't any more driven as an
output so the value you read depends on the way the led is wired (and
maybe also on internal pull up/down) and not on the way it was
previously driven when the gpio was an output.

Maybe the real fix would be to check why gpio_get_value doesn't return
the level of the gpio when it's configured as an output.

Eric

  reply	other threads:[~2013-09-28 13:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28  3:24 [U-Boot] [PATCH 1/7] mtd: Fix function description in part_validate comment Otavio Salvador
2013-09-28  3:24 ` [U-Boot] [PATCH 2/7] doc: Fix a typo in the description in doc/README.JFFS2_NAND Otavio Salvador
2013-09-28  3:24 ` [U-Boot] [PATCH 3/7] include/linux/fb.h: Add a missing include for 'list.h' Otavio Salvador
2013-09-28 16:46   ` Fabio Estevam
2013-09-28  3:24 ` [U-Boot] [PATCH 4/7] gpio-led: Use __led_set in __led_init code Otavio Salvador
2013-09-28  3:24 ` [U-Boot] [PATCH 5/7] gpio-led: Fix __led_toggle support to first set GPIO as input Otavio Salvador
2013-09-28 13:12   ` Eric Bénard [this message]
2013-09-28 16:35     ` Fabio Estevam
2013-09-28 19:05       ` Otavio Salvador
2013-09-28  3:24 ` [U-Boot] [PATCH 6/7] status_led: Add support for inverted LEDs Otavio Salvador
2013-09-28 14:17   ` Benoît Thébaudeau
2013-09-28 16:49     ` Fabio Estevam
2013-09-28 19:08       ` Otavio Salvador
2013-09-29 13:40         ` Benoît Thébaudeau
2013-09-28  3:24 ` [U-Boot] [PATCH 7/7] cmd_led: Add support for inverted BIT leds Otavio Salvador
2013-09-28 13:06 ` [U-Boot] [PATCH 1/7] mtd: Fix function description in part_validate comment Eric Bénard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130928151253.0c59b8dc@e6520eb \
    --to=eric@eukrea.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox