aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ks8695
diff options
context:
space:
mode:
authorAndrew Victor <linux@maxim.org.za>2008-04-15 16:13:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-04-17 10:58:25 -0400
commitfdb72fd84c26438a7dd754a1cc74890aca7f1b77 (patch)
treed3cfa375d72baf7fb4491eadb364428e8dfb56ab /arch/arm/mach-ks8695
parent05dda977f2574c3341abef9b74c27d2b362e1e3a (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')
-rw-r--r--arch/arm/mach-ks8695/Makefile3
-rw-r--r--arch/arm/mach-ks8695/devices.c21
-rw-r--r--arch/arm/mach-ks8695/leds.c94
3 files changed, 118 insertions, 0 deletions
diff --git a/arch/arm/mach-ks8695/Makefile b/arch/arm/mach-ks8695/Makefile
index 730a3af12c98..ade42b73afbb 100644
--- a/arch/arm/mach-ks8695/Makefile
+++ b/arch/arm/mach-ks8695/Makefile
@@ -11,5 +11,8 @@ obj- :=
11# PCI support is optional 11# PCI support is optional
12obj-$(CONFIG_PCI) += pci.o 12obj-$(CONFIG_PCI) += pci.o
13 13
14# LEDs
15obj-$(CONFIG_LEDS) += leds.o
16
14# Board-specific support 17# Board-specific support
15obj-$(CONFIG_MACH_KS8695) += board-micrel.o 18obj-$(CONFIG_MACH_KS8695) += board-micrel.o
diff --git a/arch/arm/mach-ks8695/devices.c b/arch/arm/mach-ks8695/devices.c
index 386593f8ac65..3db2ec61d06f 100644
--- a/arch/arm/mach-ks8695/devices.c
+++ b/arch/arm/mach-ks8695/devices.c
@@ -176,6 +176,27 @@ static void __init ks8695_add_device_watchdog(void) {}
176#endif 176#endif
177 177
178 178
179/* --------------------------------------------------------------------
180 * LEDs
181 * -------------------------------------------------------------------- */
182
183#if defined(CONFIG_LEDS)
184short ks8695_leds_cpu = -1;
185short ks8695_leds_timer = -1;
186
187void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
188{
189 /* Enable GPIO to access the LEDs */
190 gpio_direction_output(cpu_led, 1);
191 gpio_direction_output(timer_led, 1);
192
193 ks8695_leds_cpu = cpu_led;
194 ks8695_leds_timer = timer_led;
195}
196#else
197void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
198#endif
199
179/* -------------------------------------------------------------------- */ 200/* -------------------------------------------------------------------- */
180 201
181/* 202/*
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
21static inline void ks8695_led_on(unsigned int led)
22{
23 gpio_set_value(led, 0);
24}
25
26static inline void ks8695_led_off(unsigned int led)
27{
28 gpio_set_value(led, 1);
29}
30
31static 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 */
44static 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
83static 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);