2 * Copyright (C) 2010, 2009 Matthias Kaehlcke <matthias@kaehlcke.net>
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <asm/arch/ep93xx.h>
26 #include <status_led.h>
28 static uint8_t saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};
29 static uint32_t gpio_pin[2] = {1 << STATUS_LED_GREEN,
32 inline void switch_LED_on(uint8_t led)
34 register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
36 writel(readl(&gpio->pedr) | gpio_pin[led], &gpio->pedr);
37 saved_state[led] = STATUS_LED_ON;
40 inline void switch_LED_off(uint8_t led)
42 register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
44 writel(readl(&gpio->pedr) & ~gpio_pin[led], &gpio->pedr);
45 saved_state[led] = STATUS_LED_OFF;
50 switch_LED_on(STATUS_LED_RED);
53 void red_led_off(void)
55 switch_LED_off(STATUS_LED_RED);
58 void green_led_on(void)
60 switch_LED_on(STATUS_LED_GREEN);
63 void green_led_off(void)
65 switch_LED_off(STATUS_LED_GREEN);
68 void __led_init(led_id_t mask, int state)
70 __led_set(mask, state);
73 void __led_toggle(led_id_t mask)
75 if (STATUS_LED_RED == mask) {
76 if (STATUS_LED_ON == saved_state[STATUS_LED_RED])
80 } else if (STATUS_LED_GREEN == mask) {
81 if (STATUS_LED_ON == saved_state[STATUS_LED_GREEN])
88 void __led_set(led_id_t mask, int state)
90 if (STATUS_LED_RED == mask) {
91 if (STATUS_LED_ON == state)
95 } else if (STATUS_LED_GREEN == mask) {
96 if (STATUS_LED_ON == state)