public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott McNutt <smcnutt@psyent.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] nios2: add gpio based status led driver
Date: Tue, 20 Apr 2010 09:19:31 -0400	[thread overview]
Message-ID: <4BCDA9E3.70904@psyent.com> (raw)
In-Reply-To: <1269665654-2609-1-git-send-email-thomas@wytron.com.tw>

Thomas,

Thomas Chou wrote:
> This patch adds a gpio based status led driver. The led mask
> is used to specify the gpio pin.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  board/altera/common/gpioled.c |   30 ++++++++++++++++++++++++++++++
>  1 files changed, 30 insertions(+), 0 deletions(-)
>  create mode 100644 board/altera/common/gpioled.c
> 
> diff --git a/board/altera/common/gpioled.c b/board/altera/common/gpioled.c
> new file mode 100644
> index 0000000..9a51fae
> --- /dev/null
> +++ b/board/altera/common/gpioled.c
> @@ -0,0 +1,30 @@
> +/*
> + * Status LED driver based on gpio
> + *
> + * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <common.h>
> +#include <status_led.h>
> +#include <asm/gpio.h>
> +
> +/* assume led is active low */
> +
> +void __led_init(led_id_t mask, int state)
> +{
> +	gpio_direction_output(mask, (state == STATUS_LED_ON) ? 0 : 1);

The direction register only exists when the PIO core hardware
is configured in bidirectional mode.

> +void __led_set(led_id_t mask, int state)
> +{
> +	gpio_set_value(mask, (state == STATUS_LED_ON) ? 0 : 1);
> +}
> +
> +void __led_toggle(led_id_t mask)
> +{
> +	gpio_set_value(mask, !gpio_get_value (mask));
> +}

If the PIO core hardware is configured in output-only mode,
reading from data returns an undefined value.

As I recall, the older designs configured the LED PIO ports
as output only ... which is why board/altera/common/epled.c
was coded in such a manner.

Regards,
--Scott

  reply	other threads:[~2010-04-20 13:19 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-27  4:54 [U-Boot] [PATCH] nios2: add gpio based status led driver Thomas Chou
2010-04-20 13:19 ` Scott McNutt [this message]
2010-04-20 15:05   ` Thomas Chou
2010-04-20 16:19     ` Scott McNutt
2010-04-21  0:33       ` Thomas Chou
2010-04-21  0:45 ` [U-Boot] [PATCH v2] misc: " Thomas Chou
2010-04-24 19:23   ` Wolfgang Denk
2010-04-24 22:07     ` Thomas Chou
2010-04-24 22:32       ` Wolfgang Denk
2010-04-24 22:59         ` Thomas Chou
2010-04-25  0:48           ` Scott McNutt
2010-04-25 18:15             ` Wolfgang Denk
2010-04-25 18:14           ` Wolfgang Denk
2010-04-28  3:51             ` Thomas Chou
2010-05-04 22:30               ` Wolfgang Denk
2010-05-04 22:53                 ` Scott McNutt
2010-05-05  0:09                 ` Thomas Chou
2010-04-30  3:34             ` [U-Boot] [PATCH 0/6] add gpio_led and altera_spi drivers Thomas Chou
2010-04-30  3:34             ` [U-Boot] [PATCH 1/6 v4] nios2: add gpio support Thomas Chou
2010-05-21 14:39               ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:39               ` [U-Boot] " Scott McNutt
2010-04-30  3:34             ` [U-Boot] [PATCH 2/6 v2] misc: add gpio based status led driver Thomas Chou
2010-05-21 14:40               ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:39               ` [U-Boot] " Scott McNutt
2010-04-30  3:34             ` [U-Boot] [PATCH 3/6 v3] nios2: add gpio support to nios2-generic board Thomas Chou
2010-04-30 14:24               ` Scott McNutt
2010-04-30 15:21                 ` Thomas Chou
2010-04-30 15:35                   ` Scott McNutt
2010-05-21 14:41               ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:40               ` [U-Boot] " Scott McNutt
2010-04-30  3:34             ` [U-Boot] [PATCH 4/6 v10] spi: add altera spi controller support Thomas Chou
2010-05-21 14:43               ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:40               ` [U-Boot] " Scott McNutt
2010-04-30  3:34             ` [U-Boot] [PATCH 5/6 v2] spi_flash: support old STMicro parts with RES Thomas Chou
2010-04-30 12:48               ` Mike Frysinger
2010-04-30 13:15                 ` Thomas Chou
2010-04-30 13:11               ` [U-Boot] [PATCH 5/6 v3] " Thomas Chou
2010-04-30 13:25                 ` Mike Frysinger
2010-05-05  7:21                 ` Mike Frysinger
2010-05-05  7:34                   ` Thomas Chou
2010-05-05 19:57                   ` Wolfgang Denk
2010-05-05 21:40                     ` Mike Frysinger
2010-05-06  0:20                     ` Thomas Chou
2010-04-30  3:34             ` [U-Boot] [PATCH 6/6 v3] nios2: add spi flash support to nios2-generic board Thomas Chou
2010-05-21 14:44               ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:52               ` [U-Boot] " Scott McNutt
2010-04-27  3:29   ` [U-Boot] [PATCH] nios2: add epcs, gpio led and mmc_spi to nios2-generic Thomas Chou
2010-04-28  3:08     ` [U-Boot] [PATCH v2] " Thomas Chou
2010-06-09  4:27   ` [U-Boot] [PATCH v2] misc: add gpio based status led driver Mike Frysinger

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=4BCDA9E3.70904@psyent.com \
    --to=smcnutt@psyent.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