diff options
author | Andrew Victor <linux@maxim.org.za> | 2008-04-15 16:13:33 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-04-17 10:58:25 -0400 |
commit | fdb72fd84c26438a7dd754a1cc74890aca7f1b77 (patch) | |
tree | d3cfa375d72baf7fb4491eadb364428e8dfb56ab /arch/arm/mach-ks8695/leds.c | |
parent | 05dda977f2574c3341abef9b74c27d2b362e1e3a (diff) |
[ARM] 4981/1: [KS8695] Simple LED driver
Simple gpio-connected LED driver for KS8695 platforms.
(Based on old AT91 LED driver)
Signed-off-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-ks8695/leds.c')
-rw-r--r-- | arch/arm/mach-ks8695/leds.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/arch/arm/mach-ks8695/leds.c b/arch/arm/mach-ks8695/leds.c new file mode 100644 index 000000000000..d61762ae50d8 --- /dev/null +++ b/arch/arm/mach-ks8695/leds.c | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | * LED driver for KS8695-based boards. | ||
3 | * | ||
4 | * Copyright (C) Andrew Victor | ||
5 | * | ||
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 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | |||
15 | #include <asm/mach-types.h> | ||
16 | #include <asm/leds.h> | ||
17 | #include <asm/arch/devices.h> | ||
18 | #include <asm/arch/gpio.h> | ||
19 | |||
20 | |||
21 | static inline void ks8695_led_on(unsigned int led) | ||
22 | { | ||
23 | gpio_set_value(led, 0); | ||
24 | } | ||
25 | |||
26 | static inline void ks8695_led_off(unsigned int led) | ||
27 | { | ||
28 | gpio_set_value(led, 1); | ||
29 | } | ||
30 | |||
31 | static inline void ks8695_led_toggle(unsigned int led) | ||
32 | { | ||
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); | ||
38 | } | ||
39 | |||
40 | |||
41 | /* | ||
42 | * Handle LED events. | ||
43 | */ | ||
44 | static void ks8695_leds_event(led_event_t evt) | ||
45 | { | ||
46 | unsigned long flags; | ||
47 | |||
48 | local_irq_save(flags); | ||
49 | |||
50 | switch(evt) { | ||
51 | case led_start: /* System startup */ | ||
52 | ks8695_led_on(ks8695_leds_cpu); | ||
53 | break; | ||
54 | |||
55 | case led_stop: /* System stop / suspend */ | ||
56 | ks8695_led_off(ks8695_leds_cpu); | ||
57 | break; | ||
58 | |||
59 | #ifdef CONFIG_LEDS_TIMER | ||
60 | case led_timer: /* Every 50 timer ticks */ | ||
61 | ks8695_led_toggle(ks8695_leds_timer); | ||
62 | break; | ||
63 | #endif | ||
64 | |||
65 | #ifdef CONFIG_LEDS_CPU | ||
66 | case led_idle_start: /* Entering idle state */ | ||
67 | ks8695_led_off(ks8695_leds_cpu); | ||
68 | break; | ||
69 | |||
70 | case led_idle_end: /* Exit idle state */ | ||
71 | ks8695_led_on(ks8695_leds_cpu); | ||
72 | break; | ||
73 | #endif | ||
74 | |||
75 | default: | ||
76 | break; | ||
77 | } | ||
78 | |||
79 | local_irq_restore(flags); | ||
80 | } | ||
81 | |||
82 | |||
83 | static int __init leds_init(void) | ||
84 | { | ||
85 | if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1)) | ||
86 | return -ENODEV; | ||
87 | |||
88 | leds_event = ks8695_leds_event; | ||
89 | |||
90 | leds_event(led_start); | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | __initcall(leds_init); | ||