2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
5 * Eric Benard <eric@eukrea.com>
8 * Markus Hubig <mhubig@imko.de>
9 * IMKO GmbH <www.imko.de>
11 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #include <asm/arch/gpio.h>
33 #include <asm/arch/at91_pmc.h>
34 #include <status_led.h>
36 static unsigned int saved_state[3] = {STATUS_LED_OFF,
37 STATUS_LED_OFF, STATUS_LED_OFF};
39 void coloured_LED_init(void)
41 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
43 /* Enable the clock */
44 writel(ATMEL_ID_PIOC, &pmc->pcer);
46 at91_set_gpio_output(CONFIG_RED_LED, 1);
47 at91_set_gpio_output(CONFIG_GREEN_LED, 1);
48 at91_set_gpio_output(CONFIG_YELLOW_LED, 1);
50 at91_set_gpio_value(CONFIG_RED_LED, 0);
51 at91_set_gpio_value(CONFIG_GREEN_LED, 1);
52 at91_set_gpio_value(CONFIG_YELLOW_LED, 0);
57 at91_set_gpio_value(CONFIG_RED_LED, 1);
58 saved_state[STATUS_LED_RED] = STATUS_LED_ON;
61 void red_led_off(void)
63 at91_set_gpio_value(CONFIG_RED_LED, 0);
64 saved_state[STATUS_LED_RED] = STATUS_LED_OFF;
67 void green_led_on(void)
69 at91_set_gpio_value(CONFIG_GREEN_LED, 1);
70 saved_state[STATUS_LED_GREEN] = STATUS_LED_ON;
73 void green_led_off(void)
75 at91_set_gpio_value(CONFIG_GREEN_LED, 0);
76 saved_state[STATUS_LED_GREEN] = STATUS_LED_OFF;
79 void yellow_led_on(void)
81 at91_set_gpio_value(CONFIG_YELLOW_LED, 1);
82 saved_state[STATUS_LED_YELLOW] = STATUS_LED_ON;
85 void yellow_led_off(void)
87 at91_set_gpio_value(CONFIG_YELLOW_LED, 0);
88 saved_state[STATUS_LED_YELLOW] = STATUS_LED_OFF;
91 void __led_init(led_id_t mask, int state)
93 __led_set(mask, state);
96 void __led_toggle(led_id_t mask)
98 if (STATUS_LED_RED == mask) {
99 if (STATUS_LED_ON == saved_state[STATUS_LED_RED])
104 } else if (STATUS_LED_GREEN == mask) {
105 if (STATUS_LED_ON == saved_state[STATUS_LED_GREEN])
110 } else if (STATUS_LED_YELLOW == mask) {
111 if (STATUS_LED_ON == saved_state[STATUS_LED_YELLOW])
118 void __led_set(led_id_t mask, int state)
120 if (STATUS_LED_RED == mask) {
121 if (STATUS_LED_ON == state)
126 } else if (STATUS_LED_GREEN == mask) {
127 if (STATUS_LED_ON == state)
132 } else if (STATUS_LED_YELLOW == mask) {
133 if (STATUS_LED_ON == state)