[U-Boot] [PATCH] nios2: add gpio based status led driver

Thomas Chou
2010-04-20T15:05:37Z

On 04/20/2010 09:19 PM, Scott McNutt wrote:
>> +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.

> 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.
>
Hi Scott,

This is not for Altera PIO interface. I followed the gpio interface of
Linux, linux-2.6/Documentation/gpio.txt, and created a trivial bit
addressing gpio core, which uses fewer LE and doesn't required interrupt
disabled to write a bit. With this core, all output pins are
bidirectional and can be read. I used it to access i2c, one-wire, leds,
buttons and nand flash busy flag in nios2 linux. I didn't add irq
support, because input layer of linux can do debounce. Please look at
http://nioswiki.com/GPIO.

Best regards,
Thomas