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.
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.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);
43 static void ks8695_leds_event(led_event_t evt)
47 local_irq_save(flags);
50 case led_start: /* System startup */
51 ks8695_led_on(ks8695_leds_cpu);
54 case led_stop: /* System stop / suspend */
55 ks8695_led_off(ks8695_leds_cpu);
58 #ifdef CONFIG_LEDS_TIMER
59 case led_timer: /* Every 50 timer ticks */
60 ks8695_led_toggle(ks8695_leds_timer);
64 #ifdef CONFIG_LEDS_CPU
65 case led_idle_start: /* Entering idle state */
66 ks8695_led_off(ks8695_leds_cpu);
69 case led_idle_end: /* Exit idle state */
70 ks8695_led_on(ks8695_leds_cpu);
78 local_irq_restore(flags);
82 static int __init leds_init(void)
84 if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
87 leds_event = ks8695_leds_event;
89 leds_event(led_start);
93 __initcall(leds_init);