1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2010 Texas Instruments, Inc.
4 * Jason Kridner <jkridner@beagleboard.org>
7 #include <status_led.h>
8 #include <asm/arch/cpu.h>
10 #include <asm/arch/sys_proto.h>
13 /* GPIO pins for the LEDs */
14 #define BEAGLE_LED_USR0 150
15 #define BEAGLE_LED_USR1 149
17 #ifdef CONFIG_LED_STATUS_GREEN
18 void green_led_off(void)
20 __led_set(CONFIG_LED_STATUS_GREEN, 0);
23 void green_led_on(void)
25 __led_set(CONFIG_LED_STATUS_GREEN, 1);
29 static int get_led_gpio(led_id_t mask)
31 #ifdef CONFIG_LED_STATUS0
32 if (CONFIG_LED_STATUS_BIT & mask)
33 return BEAGLE_LED_USR0;
35 #ifdef CONFIG_LED_STATUS1
36 if (CONFIG_LED_STATUS_BIT1 & mask)
37 return BEAGLE_LED_USR1;
43 void __led_init (led_id_t mask, int state)
47 toggle_gpio = get_led_gpio(mask);
49 if (toggle_gpio && !gpio_request(toggle_gpio, "led"))
50 __led_set(mask, state);
53 void __led_toggle (led_id_t mask)
55 int state, toggle_gpio;
57 toggle_gpio = get_led_gpio(mask);
59 state = gpio_get_value(toggle_gpio);
60 gpio_direction_output(toggle_gpio, !state);
64 void __led_set (led_id_t mask, int state)
68 toggle_gpio = get_led_gpio(mask);
70 gpio_direction_output(toggle_gpio, state);