diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /arch/arm/mach-at91/leds.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'arch/arm/mach-at91/leds.c')
-rw-r--r-- | arch/arm/mach-at91/leds.c | 109 |
1 files changed, 107 insertions, 2 deletions
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c index 3e22978b554..0415a839e1a 100644 --- a/arch/arm/mach-at91/leds.c +++ b/arch/arm/mach-at91/leds.c | |||
@@ -9,13 +9,13 @@ | |||
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/gpio.h> | ||
13 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
14 | #include <linux/module.h> | 13 | #include <linux/module.h> |
15 | #include <linux/init.h> | 14 | #include <linux/init.h> |
16 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
17 | 16 | ||
18 | #include "board.h" | 17 | #include <mach/board.h> |
18 | #include <mach/gpio.h> | ||
19 | 19 | ||
20 | 20 | ||
21 | /* ------------------------------------------------------------------------- */ | 21 | /* ------------------------------------------------------------------------- */ |
@@ -90,3 +90,108 @@ void __init at91_pwm_leds(struct gpio_led *leds, int nr) | |||
90 | #else | 90 | #else |
91 | void __init at91_pwm_leds(struct gpio_led *leds, int nr){} | 91 | void __init at91_pwm_leds(struct gpio_led *leds, int nr){} |
92 | #endif | 92 | #endif |
93 | |||
94 | |||
95 | /* ------------------------------------------------------------------------- */ | ||
96 | |||
97 | #if defined(CONFIG_LEDS) | ||
98 | |||
99 | #include <asm/leds.h> | ||
100 | |||
101 | /* | ||
102 | * Old ARM-specific LED framework; not fully functional when generic time is | ||
103 | * in use. | ||
104 | */ | ||
105 | |||
106 | static u8 at91_leds_cpu; | ||
107 | static u8 at91_leds_timer; | ||
108 | |||
109 | static inline void at91_led_on(unsigned int led) | ||
110 | { | ||
111 | at91_set_gpio_value(led, 0); | ||
112 | } | ||
113 | |||
114 | static inline void at91_led_off(unsigned int led) | ||
115 | { | ||
116 | at91_set_gpio_value(led, 1); | ||
117 | } | ||
118 | |||
119 | static inline void at91_led_toggle(unsigned int led) | ||
120 | { | ||
121 | unsigned long is_off = at91_get_gpio_value(led); | ||
122 | if (is_off) | ||
123 | at91_led_on(led); | ||
124 | else | ||
125 | at91_led_off(led); | ||
126 | } | ||
127 | |||
128 | |||
129 | /* | ||
130 | * Handle LED events. | ||
131 | */ | ||
132 | static void at91_leds_event(led_event_t evt) | ||
133 | { | ||
134 | unsigned long flags; | ||
135 | |||
136 | local_irq_save(flags); | ||
137 | |||
138 | switch(evt) { | ||
139 | case led_start: /* System startup */ | ||
140 | at91_led_on(at91_leds_cpu); | ||
141 | break; | ||
142 | |||
143 | case led_stop: /* System stop / suspend */ | ||
144 | at91_led_off(at91_leds_cpu); | ||
145 | break; | ||
146 | |||
147 | #ifdef CONFIG_LEDS_TIMER | ||
148 | case led_timer: /* Every 50 timer ticks */ | ||
149 | at91_led_toggle(at91_leds_timer); | ||
150 | break; | ||
151 | #endif | ||
152 | |||
153 | #ifdef CONFIG_LEDS_CPU | ||
154 | case led_idle_start: /* Entering idle state */ | ||
155 | at91_led_off(at91_leds_cpu); | ||
156 | break; | ||
157 | |||
158 | case led_idle_end: /* Exit idle state */ | ||
159 | at91_led_on(at91_leds_cpu); | ||
160 | break; | ||
161 | #endif | ||
162 | |||
163 | default: | ||
164 | break; | ||
165 | } | ||
166 | |||
167 | local_irq_restore(flags); | ||
168 | } | ||
169 | |||
170 | |||
171 | static int __init leds_init(void) | ||
172 | { | ||
173 | if (!at91_leds_timer || !at91_leds_cpu) | ||
174 | return -ENODEV; | ||
175 | |||
176 | leds_event = at91_leds_event; | ||
177 | |||
178 | leds_event(led_start); | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | __initcall(leds_init); | ||
183 | |||
184 | |||
185 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) | ||
186 | { | ||
187 | /* Enable GPIO to access the LEDs */ | ||
188 | at91_set_gpio_output(cpu_led, 1); | ||
189 | at91_set_gpio_output(timer_led, 1); | ||
190 | |||
191 | at91_leds_cpu = cpu_led; | ||
192 | at91_leds_timer = timer_led; | ||
193 | } | ||
194 | |||
195 | #else | ||
196 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} | ||
197 | #endif | ||