ecryptfs: propagate key errors up at mount time
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-ks8695 / leds.c
blobd61762ae50d88513482e99734263a2dbcf21545a
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/mach-types.h>
16 #include <asm/leds.h>
17 #include <asm/arch/devices.h>
18 #include <asm/arch/gpio.h>
21 static inline void ks8695_led_on(unsigned int led)
23 gpio_set_value(led, 0);
26 static inline void ks8695_led_off(unsigned int led)
28 gpio_set_value(led, 1);
31 static inline void ks8695_led_toggle(unsigned int led)
33 unsigned long is_off = gpio_get_value(led);
34 if (is_off)
35 ks8695_led_on(led);
36 else
37 ks8695_led_off(led);
42 * Handle LED events.
44 static void ks8695_leds_event(led_event_t evt)
46 unsigned long flags;
48 local_irq_save(flags);
50 switch(evt) {
51 case led_start: /* System startup */
52 ks8695_led_on(ks8695_leds_cpu);
53 break;
55 case led_stop: /* System stop / suspend */
56 ks8695_led_off(ks8695_leds_cpu);
57 break;
59 #ifdef CONFIG_LEDS_TIMER
60 case led_timer: /* Every 50 timer ticks */
61 ks8695_led_toggle(ks8695_leds_timer);
62 break;
63 #endif
65 #ifdef CONFIG_LEDS_CPU
66 case led_idle_start: /* Entering idle state */
67 ks8695_led_off(ks8695_leds_cpu);
68 break;
70 case led_idle_end: /* Exit idle state */
71 ks8695_led_on(ks8695_leds_cpu);
72 break;
73 #endif
75 default:
76 break;
79 local_irq_restore(flags);
83 static int __init leds_init(void)
85 if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
86 return -ENODEV;
88 leds_event = ks8695_leds_event;
90 leds_event(led_start);
91 return 0;
94 __initcall(leds_init);