2 * Copyright (c) 2010 Texas Instruments, Inc.
3 * Jason Kridner <jkridner@beagleboard.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 #include <status_led.h>
22 #include <asm/arch/cpu.h>
24 #include <asm/arch/sys_proto.h>
25 #include <asm/arch/gpio.h>
27 static unsigned int saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};
29 /* GPIO pins for the LEDs */
30 #define BEAGLE_LED_USR0 149
31 #define BEAGLE_LED_USR1 150
33 #ifdef STATUS_LED_GREEN
34 void green_LED_off (void)
36 __led_set (STATUS_LED_GREEN, 0);
39 void green_LED_on (void)
41 __led_set (STATUS_LED_GREEN, 1);
45 void __led_init (led_id_t mask, int state)
47 __led_set (mask, state);
50 void __led_toggle (led_id_t mask)
53 if (STATUS_LED_BIT & mask) {
54 if (STATUS_LED_ON == saved_state[0])
55 __led_set(STATUS_LED_BIT, 0);
57 __led_set(STATUS_LED_BIT, 1);
60 #ifdef STATUS_LED_BIT1
61 if (STATUS_LED_BIT1 & mask) {
62 if (STATUS_LED_ON == saved_state[1])
63 __led_set(STATUS_LED_BIT1, 0);
65 __led_set(STATUS_LED_BIT1, 1);
70 void __led_set (led_id_t mask, int state)
73 if (STATUS_LED_BIT & mask) {
74 if (!omap_request_gpio(BEAGLE_LED_USR0)) {
75 omap_set_gpio_direction(BEAGLE_LED_USR0, 0);
76 omap_set_gpio_dataout(BEAGLE_LED_USR0, state);
78 saved_state[0] = state;
81 #ifdef STATUS_LED_BIT1
82 if (STATUS_LED_BIT1 & mask) {
83 if (!omap_request_gpio(BEAGLE_LED_USR1)) {
84 omap_set_gpio_direction(BEAGLE_LED_USR1, 0);
85 omap_set_gpio_dataout(BEAGLE_LED_USR1, state);
87 saved_state[1] = state;