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>
15 #include <asm/mach-types.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);
44 static void ks8695_leds_event(led_event_t evt)
48 local_irq_save(flags);
51 case led_start: /* System startup */
52 ks8695_led_on(ks8695_leds_cpu);
55 case led_stop: /* System stop / suspend */
56 ks8695_led_off(ks8695_leds_cpu);
59 #ifdef CONFIG_LEDS_TIMER
60 case led_timer: /* Every 50 timer ticks */
61 ks8695_led_toggle(ks8695_leds_timer);
65 #ifdef CONFIG_LEDS_CPU
66 case led_idle_start: /* Entering idle state */
67 ks8695_led_off(ks8695_leds_cpu);
70 case led_idle_end: /* Exit idle state */
71 ks8695_led_on(ks8695_leds_cpu);
79 local_irq_restore(flags);
83 static int __init leds_init(void)
85 if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
88 leds_event = ks8695_leds_event;
90 leds_event(led_start);
94 __initcall(leds_init);