at91: Add command to control GPIO LEDs from the console
PATCH 1/1 at91: Add command to control GPIO LEDs from the console
This patch allows any at91 board implementing the GPIO LED API to control vendor specific LEDs from the console.
Adding configuration items CONFIG_AT91_LED and CONFIG_CMD_LED enables the command.
Moreover the GPIO Pins have to be defined by CONFIG_GPIO_LEDS See doc/README.LED for detailed information.
Usage:
led [LED_number] [on|off]
--- cpu/arm926ejs/at91/Makefile | 1 + cpu/arm926ejs/at91/cmd_led.c | 60 +++++++++++++++++++++++++++++++++++++++ cpu/arm926ejs/at91/led.c | 29 +++++++++++++++++++ doc/README.LED | 40 ++++++++++++++++++++++++++ include/asm-arm/arch-at91/led.h | 42 +++++++++++++++++++++++++++ 5 files changed, 172 insertions(+), 0 deletions(-) create mode 100644 cpu/arm926ejs/at91/cmd_led.c create mode 100644 include/asm-arm/arch-at91/led.h
cpu/arm926ejs/at91/Makefile +1 -0
@@ -54,6 +54,7 @@ ifdef CONFIG_AT91SAM9RL COBJS-y += at91sam9rl_serial.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o endif +COBJS-$(CONFIG_CMD_LED) += cmd_led.o COBJS-$(CONFIG_AT91_LED) += led.o COBJS-y += clock.o COBJS-y += cpu.o
cpu/arm926ejs/at91/cmd_led.c new file +60 -0
60 lines not on this page · raw message
cpu/arm926ejs/at91/led.c +29 -0
@@ -3,6 +3,10 @@* Stelian Pop <[email protected]> * Lead Tech Design <www.leadtechdesign.com> * +* (C) Copyright 2009 +* Daniel Gorsulowski <[email protected]> +* esd electronic system design gmbh <www.esd.eu> +* * See file CREDITS for list of people who contributed to this * project. *
@@ -27,6 +31,31 @@#include <asm/arch/gpio.h> #include <asm/arch/io.h> +#ifdef CONFIG_AT91_LED + +#if defined(CONFIG_AT91RM9200 ) +#include <asm/arch/at91rm9200.h> +#elif defined(CONFIG_AT91SAM9260 ) || defined(CONFIG_AT91SAM9G20 ) +#include <asm/arch/at91sam9260.h> +#elif defined(CONFIG_AT91SAM9261 ) +#include <asm/arch/at91sam9261.h> +#elif defined(CONFIG_AT91SAM9263 ) +#include <asm/arch/at91sam9263.h> +#elif defined(CONFIG_AT91SAM9RL ) +#include <asm/arch/at91sam9rl.h> +#elif defined(CONFIG_AT91CAP9 ) +#include <asm/arch/at91cap9.h> +#endif + +#include <asm/arch/led.h> + +void user_led (ulong led_nr,unsigned on) +{ +at91_set_gpio_value (leds[led_nr], on); +} + +#endif /* CONFIG_AT91_LED */ +#ifdef CONFIG_RED_LED void red_LED_on (void ) {
doc/README.LED +40 -0
@@ -76,3 +76,43 @@ TBD : Describe older board dependent macros similar to what is done for CONFIG_TQM8xxL. TBD : Describe general support via asm/status_led.h + + +GPIO LEDs +======================================== + +GPIO LEDs are presently only supported by at91. +this README describes the usage of the GPIO LED API. + +The API is defined by the include file include/asm-arm/arch-at91/led.h + +The first step is to define CONFIG_AT91_LED, CONFIG_LED_MAX and CONFIG_GPIO_LEDS +in the board config file. +I.e.: + /* LED */ + #define CONFIG_AT91_LED + #define CONFIG_LED_MAX ARRAY_SIZE(leds) + #define CONFIG_GPIO_LEDS { \ + AT91_PIN_PB8, \ + AT91_PIN_PB7 \ + } + +The second step is to initialize the Peripheral Clock Controller and the GPIO +pins in the vendor specific board code. +I.e.: + #ifdef CONFIG_AT91_LED + /* Enable clock */ + at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_PIOB | + 1 << AT91SAM9263_ID_PIOCDE); + + /* Initialize GPIO pins */ + int i; + for(i = 0; i < CONFIG_LED_MAX; i++) { + at91_set_gpio_output(leds[i], 1); + at91_set_gpio_value(leds[i], 1); + } + #endif + +Now a new command "led" will be available in the U-Boot console. +Usage: +led [LED_number] [on|off]
include/asm-arm/arch-at91/led.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.6.1
PATCH 1/1 at91: Add command to control GPIO LEDs from the console
Quoted 10 lines · Daniel Gorsulowski
This patch allows any at91 board implementing the GPIO LED API to control vendor specific LEDs from the console.
Adding configuration items
CONFIG_AT91_LEDandCONFIG_CMD_LEDenables the command.
Moreover the GPIO Pins have to be defined byCONFIG_GPIO_LEDSSee doc/README.LED for detailed information.Usage:
led [LED_number] [on|off]
why create a new led API?
the best way will be to extent the current collor led api by using something like this
why create a new led API?
the best way will be to extent the current collor led api by using something like this
#define LED_RED 0
#define LED_GREEN 1
#define LED_YELLOW 2
#define LED_BLUE 3
.macro led_red_off
ldr r0, =LED_RED mov r1, #0 bl led_on_off
.endm
.macro led_red_on
ldr r0, =LED_RED mov r1, #1 bl led_on_off
.endm
.macro led_green_off
ldr r0, =LED_GREEN mov r1, #0 bl led_on_off
.endm
.macro led_green_on
ldr r0, =LED_GREN mov r1, #1 bl led_on_off
.endm
.macro led_yellow_off
ldr r0, =LED_YELLOW mov r1, #0 bl led_on_off
.endm
.macro led_yellow_on
ldr r0, =LED_YELLOW mov r1, #1 bl led_on_off
.endm
.macro led_blue_off
ldr r0, =LED_BLUE mov r1, #0 bl led_on_off
.endm
.macro led_blue_on
ldr r0, =LED_BLUE mov r1, #1 bl led_on_off
.endm
and we need to keep the coloured led name and number and if needed extendit as done for the zoom2
and please do not do it only for at91
Best Regards,
J.