2 * Copyright (c) 2010 Texas Instruments, Inc.
3 * Jason Kridner <jkridner@beagleboard.org>
5 * SPDX-License-Identifier: GPL-2.0+
8 #include <status_led.h>
9 #include <asm/arch/cpu.h>
11 #include <asm/arch/sys_proto.h>
14 /* GPIO pins for the LEDs */
15 #define BEAGLE_LED_USR0 150
16 #define BEAGLE_LED_USR1 149
18 #ifdef STATUS_LED_GREEN
19 void green_led_off(void)
21 __led_set (STATUS_LED_GREEN, 0);
24 void green_led_on(void)
26 __led_set (STATUS_LED_GREEN, 1);
30 static int get_led_gpio(led_id_t mask)
33 if (STATUS_LED_BIT & mask)
34 return BEAGLE_LED_USR0;
36 #ifdef STATUS_LED_BIT1
37 if (STATUS_LED_BIT1 & mask)
38 return BEAGLE_LED_USR1;
44 void __led_init (led_id_t mask, int state)
48 toggle_gpio = get_led_gpio(mask);
50 if (toggle_gpio && !gpio_request(toggle_gpio, "led"))
51 __led_set(mask, state);
54 void __led_toggle (led_id_t mask)
56 int state, toggle_gpio;
58 toggle_gpio = get_led_gpio(mask);
60 state = gpio_get_value(toggle_gpio);
61 gpio_direction_output(toggle_gpio, !state);
65 void __led_set (led_id_t mask, int state)
69 toggle_gpio = get_led_gpio(mask);
71 gpio_direction_output(toggle_gpio, state);