Adding support for MOXA ART SoC. Testing port of linux-2.6.32.60-moxart.
[linux-3.6.7-moxart.git] / arch / arm / mach-ks8695 / leds.c
blob4bd707547293189bcae0ce588ad30f2b05bf1d20
1 /*
2 * LED driver for KS8695-based boards.
4 * Copyright (C) Andrew Victor
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #include <linux/gpio.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
15 #include <asm/leds.h>
16 #include <mach/devices.h>
19 static inline void ks8695_led_on(unsigned int led)
21 gpio_set_value(led, 0);
24 static inline void ks8695_led_off(unsigned int led)
26 gpio_set_value(led, 1);
29 static inline void ks8695_led_toggle(unsigned int led)
31 unsigned long is_off = gpio_get_value(led);
32 if (is_off)
33 ks8695_led_on(led);
34 else
35 ks8695_led_off(led);
40 * Handle LED events.
42 static void ks8695_leds_event(led_event_t evt)
44 unsigned long flags;
46 local_irq_save(flags);
48 switch(evt) {
49 case led_start: /* System startup */
50 ks8695_led_on(ks8695_leds_cpu);
51 break;
53 case led_stop: /* System stop / suspend */
54 ks8695_led_off(ks8695_leds_cpu);
55 break;
57 #ifdef CONFIG_LEDS_TIMER
58 case led_timer: /* Every 50 timer ticks */
59 ks8695_led_toggle(ks8695_leds_timer);
60 break;
61 #endif
63 #ifdef CONFIG_LEDS_CPU
64 case led_idle_start: /* Entering idle state */
65 ks8695_led_off(ks8695_leds_cpu);
66 break;
68 case led_idle_end: /* Exit idle state */
69 ks8695_led_on(ks8695_leds_cpu);
70 break;
71 #endif
73 default:
74 break;
77 local_irq_restore(flags);
81 static int __init leds_init(void)
83 if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
84 return -ENODEV;
86 leds_event = ks8695_leds_event;
88 leds_event(led_start);
89 return 0;
92 __initcall(leds_init);