1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <common.h>
21#include <status_led.h>
22#include <asm/arch/cpu.h>
23#include <asm/io.h>
24#include <asm/arch/sys_proto.h>
25#include <asm/gpio.h>
26
27
28#define BEAGLE_LED_USR0 150
29#define BEAGLE_LED_USR1 149
30
31#ifdef STATUS_LED_GREEN
32void green_led_off(void)
33{
34 __led_set (STATUS_LED_GREEN, 0);
35}
36
37void green_led_on(void)
38{
39 __led_set (STATUS_LED_GREEN, 1);
40}
41#endif
42
43void __led_init (led_id_t mask, int state)
44{
45 __led_set (mask, state);
46}
47
48void __led_toggle (led_id_t mask)
49{
50 int state, toggle_gpio = 0;
51#ifdef STATUS_LED_BIT
52 if (!toggle_gpio && STATUS_LED_BIT & mask)
53 toggle_gpio = BEAGLE_LED_USR0;
54#endif
55#ifdef STATUS_LED_BIT1
56 if (!toggle_gpio && STATUS_LED_BIT1 & mask)
57 toggle_gpio = BEAGLE_LED_USR1;
58#endif
59 if (toggle_gpio) {
60 if (!gpio_request(toggle_gpio, "")) {
61 gpio_direction_output(toggle_gpio, 0);
62 state = gpio_get_value(toggle_gpio);
63 gpio_set_value(toggle_gpio, !state);
64 }
65 }
66}
67
68void __led_set (led_id_t mask, int state)
69{
70#ifdef STATUS_LED_BIT
71 if (STATUS_LED_BIT & mask) {
72 if (!gpio_request(BEAGLE_LED_USR0, "")) {
73 gpio_direction_output(BEAGLE_LED_USR0, 0);
74 gpio_set_value(BEAGLE_LED_USR0, state);
75 }
76 }
77#endif
78#ifdef STATUS_LED_BIT1
79 if (STATUS_LED_BIT1 & mask) {
80 if (!gpio_request(BEAGLE_LED_USR1, "")) {
81 gpio_direction_output(BEAGLE_LED_USR1, 0);
82 gpio_set_value(BEAGLE_LED_USR1, state);
83 }
84 }
85#endif
86}
87