Linux 2.6.31.6
[linux/fpc-iii.git] / arch / arm / mach-ks8695 / leds.c
blob184ef74e4bee53151666d7d26396964d7c36bcb6
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 */
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>
17 #include <mach/gpio.h>
20 static inline void ks8695_led_on(unsigned int led)
22 gpio_set_value(led, 0);
25 static inline void ks8695_led_off(unsigned int led)
27 gpio_set_value(led, 1);
30 static inline void ks8695_led_toggle(unsigned int led)
32 unsigned long is_off = gpio_get_value(led);
33 if (is_off)
34 ks8695_led_on(led);
35 else
36 ks8695_led_off(led);
41 * Handle LED events.
43 static void ks8695_leds_event(led_event_t evt)
45 unsigned long flags;
47 local_irq_save(flags);
49 switch(evt) {
50 case led_start: /* System startup */
51 ks8695_led_on(ks8695_leds_cpu);
52 break;
54 case led_stop: /* System stop / suspend */
55 ks8695_led_off(ks8695_leds_cpu);
56 break;
58 #ifdef CONFIG_LEDS_TIMER
59 case led_timer: /* Every 50 timer ticks */
60 ks8695_led_toggle(ks8695_leds_timer);
61 break;
62 #endif
64 #ifdef CONFIG_LEDS_CPU
65 case led_idle_start: /* Entering idle state */
66 ks8695_led_off(ks8695_leds_cpu);
67 break;
69 case led_idle_end: /* Exit idle state */
70 ks8695_led_on(ks8695_leds_cpu);
71 break;
72 #endif
74 default:
75 break;
78 local_irq_restore(flags);
82 static int __init leds_init(void)
84 if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
85 return -ENODEV;
87 leds_event = ks8695_leds_event;
89 leds_event(led_start);
90 return 0;
93 __initcall(leds_init);