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.
10 #include <linux/gpio.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.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
);
42 static void ks8695_leds_event(led_event_t evt
)
46 local_irq_save(flags
);
49 case led_start
: /* System startup */
50 ks8695_led_on(ks8695_leds_cpu
);
53 case led_stop
: /* System stop / suspend */
54 ks8695_led_off(ks8695_leds_cpu
);
57 #ifdef CONFIG_LEDS_TIMER
58 case led_timer
: /* Every 50 timer ticks */
59 ks8695_led_toggle(ks8695_leds_timer
);
63 #ifdef CONFIG_LEDS_CPU
64 case led_idle_start
: /* Entering idle state */
65 ks8695_led_off(ks8695_leds_cpu
);
68 case led_idle_end
: /* Exit idle state */
69 ks8695_led_on(ks8695_leds_cpu
);
77 local_irq_restore(flags
);
81 static int __init
leds_init(void)
83 if ((ks8695_leds_timer
== -1) || (ks8695_leds_cpu
== -1))
86 leds_event
= ks8695_leds_event
;
88 leds_event(led_start
);
92 __initcall(leds_init
);