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
27static unsigned int saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};
28
29
30
31
32
33
34
35#define ZOOM2_LED_RED 173
36#define ZOOM2_LED_BLUE 154
37#define ZOOM2_LED_BLUE2 61
38
39void red_led_off(void)
40{
41
42 if (!gpio_request(ZOOM2_LED_RED, "")) {
43 gpio_direction_output(ZOOM2_LED_RED, 0);
44 gpio_set_value(ZOOM2_LED_RED, 0);
45 }
46 saved_state[STATUS_LED_RED] = STATUS_LED_OFF;
47}
48
49void blue_led_off(void)
50{
51
52 if (!gpio_request(ZOOM2_LED_BLUE, "")) {
53 gpio_direction_output(ZOOM2_LED_BLUE, 0);
54 gpio_set_value(ZOOM2_LED_BLUE, 0);
55 }
56
57
58 if (!gpio_request(ZOOM2_LED_BLUE2, "")) {
59 gpio_direction_output(ZOOM2_LED_BLUE2, 0);
60 gpio_set_value(ZOOM2_LED_BLUE2, 0);
61 }
62 saved_state[STATUS_LED_BLUE] = STATUS_LED_OFF;
63}
64
65void red_led_on(void)
66{
67 blue_led_off();
68
69
70 if (!gpio_request(ZOOM2_LED_RED, "")) {
71 gpio_direction_output(ZOOM2_LED_RED, 0);
72 gpio_set_value(ZOOM2_LED_RED, 1);
73 }
74 saved_state[STATUS_LED_RED] = STATUS_LED_ON;
75}
76
77void blue_led_on(void)
78{
79 red_led_off();
80
81
82 if (!gpio_request(ZOOM2_LED_BLUE, "")) {
83 gpio_direction_output(ZOOM2_LED_BLUE, 0);
84 gpio_set_value(ZOOM2_LED_BLUE, 1);
85 }
86
87
88 if (!gpio_request(ZOOM2_LED_BLUE2, "")) {
89 gpio_direction_output(ZOOM2_LED_BLUE2, 0);
90 gpio_set_value(ZOOM2_LED_BLUE2, 1);
91 }
92
93 saved_state[STATUS_LED_BLUE] = STATUS_LED_ON;
94}
95
96void __led_init (led_id_t mask, int state)
97{
98 __led_set (mask, state);
99}
100
101void __led_toggle (led_id_t mask)
102{
103 if (STATUS_LED_BLUE == mask) {
104 if (STATUS_LED_ON == saved_state[STATUS_LED_BLUE])
105 blue_led_off();
106 else
107 blue_led_on();
108 } else if (STATUS_LED_RED == mask) {
109 if (STATUS_LED_ON == saved_state[STATUS_LED_RED])
110 red_led_off();
111 else
112 red_led_on();
113 }
114}
115
116void __led_set (led_id_t mask, int state)
117{
118 if (STATUS_LED_BLUE == mask) {
119 if (STATUS_LED_ON == state)
120 blue_led_on();
121 else
122 blue_led_off();
123 } else if (STATUS_LED_RED == mask) {
124 if (STATUS_LED_ON == state)
125 red_led_on();
126 else
127 red_led_off();
128 }
129}
130