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 void __led_init (led_id_t mask, int state)
32 __led_set (mask, state);
35 void __led_toggle (led_id_t mask)
37 int state, toggle_gpio = 0;
39 if (!toggle_gpio && STATUS_LED_BIT & mask)
40 toggle_gpio = BEAGLE_LED_USR0;
42 #ifdef STATUS_LED_BIT1
43 if (!toggle_gpio && STATUS_LED_BIT1 & mask)
44 toggle_gpio = BEAGLE_LED_USR1;
47 if (!gpio_request(toggle_gpio, "")) {
48 gpio_direction_output(toggle_gpio, 0);
49 state = gpio_get_value(toggle_gpio);
50 gpio_set_value(toggle_gpio, !state);
55 void __led_set (led_id_t mask, int state)
58 if (STATUS_LED_BIT & mask) {
59 if (!gpio_request(BEAGLE_LED_USR0, "")) {
60 gpio_direction_output(BEAGLE_LED_USR0, 0);
61 gpio_set_value(BEAGLE_LED_USR0, state);
65 #ifdef STATUS_LED_BIT1
66 if (STATUS_LED_BIT1 & mask) {
67 if (!gpio_request(BEAGLE_LED_USR1, "")) {
68 gpio_direction_output(BEAGLE_LED_USR1, 0);
69 gpio_set_value(BEAGLE_LED_USR1, state);