aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-08-13 10:45:48 -0400
committerArnd Bergmann <arnd@arndb.de>2012-08-13 10:45:48 -0400
commit19e4ab54e7f5fe46a3c931afa7e786f11d57b558 (patch)
treeaeada0b9d0800b94cb795020a856c625ddc4f41c /arch
parent0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff)
parentfa8bbb13ab49e77c00fa09e5504ec25b7176fb4b (diff)
Merge branch 'for-arm-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds into next/drivers
From Bryan Wu <bryan.wu@canonical.com>: Based on Linus Walleij's ARM LED consolidation work, this patchset introduce a new generic led trigger for CPU not only for ARM but also for others. For enabling CPU idle event, CPU arch code should call ledtrig_cpu() stub to trigger idle start or idle end event. These patches convert old style LED driver in arch/arm to gpio_led or new led driver interface. Against 3.5 release and build successfully for all the machines. Test ledtrig-cpu driver on OMAP4 Panda board. v9 --> v10 * fix compiling issue on versatile_defconfig reported by Russell King * rebase to 3.5 kernel and move patches to new git tree v8 --> v9: * use mutex to replace rw_sema pointed out by Tim Gardner * add a new struct led_trigger_cpu * add lock_is_inited to record mutex lock initialization v6 --> v7: * add a patch to unify the led-trigger name * fix some typo pointed * use BUG_ON to detect CPU numbers during building stage v5 --> v6: * replace __get_cpu_var() to per_cpu() * remove smp_processor_id() which is wrong with for_each_possible_cpu() * test on real OMAP4 Panda board * add comments about CPU hotplug in the CPU LED trigger driver v4 --> v5: * rebase all the patches on top of latest linux-next * replace on_each_cpu() with for_each_possible_cpu() * add some description of ledtrig_cpu() API * remove old leds code from driver nwflash.c, which should use a new led trigger then * this trigger driver can be built as module now v3 --> v4: * fix a typo pointed by Jochen Friedrich * fix some building errors * add Reviewed-by and Tested-by into patch log v2 --> v3: * almost rewrote the whole ledtrig-cpu driver, which is more simple * every CPU will have a per-CPU trigger * cpu trigger can be assigned to any leds * fix a lockdep issue in led-trigger common code * other fix according to review v1 --> v2: * remove select operations in Kconfig of every machines * add back supporting of led in core module of mach-integrator * solidate name scheme in ledtrig-cpu.c * add comments of CPU_LED_* cpu led events * fold patches of RealView and Versatile together * add machine_is_ check during assabet led driver init * add some Acked-by in patch logs * remove code for simpad machine in machine-sa11000, since Jochen Friedrich introduced gpiolib and gpio-led driver for simpad * on Assabet and Netwinder machine, LED operations is reversed like: setting bit means turn off leds clearing bit means turn on leds * add a new function to read CM_CTRL register for led driver * 'for-arm-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: ARM: use new LEDS CPU trigger stub to replace old one ARM: mach-sa1100: retire custom LED code ARM: mach-omap1: retire custom LED code ARM: mach-pnx4008: remove including old leds event API header file ARM: plat-samsung: remove including old leds event API header file ARM: mach-pxa: retire custom LED code char: nwflash: remove old led event code ARM: mach-footbridge: retire custom LED code ARM: mach-ebsa110: retire custom LED code ARM: mach-clps711x: retire custom LED code of P720T machine ARM: mach-integrator: retire custom LED code ARM: mach-integrator: move CM_CTRL to header file for accessing by other functions ARM: mach-orion5x: convert custom LED code to gpio_led and LED CPU trigger ARM: mach-shark: retire custom LED code ARM: mach-ks8695: remove leds driver, since nobody use it ARM: mach-realview and mach-versatile: retire custom LED code ARM: at91: convert old leds drivers to gpio_led and led_trigger drivers led-triggers: create a trigger for CPU activity Conflicts: arch/arm/mach-clps711x/p720t.c arch/arm/mach-sa1100/leds-cerf.c arch/arm/mach-sa1100/leds-lart.c Let's hope this is the last time we pull this and it doesn't cause more trouble. I have verified that version 10 causes no build warnings or errors any more, and the patches still look good. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/Kconfig53
-rw-r--r--arch/arm/include/asm/leds.h50
-rw-r--r--arch/arm/kernel/Makefile1
-rw-r--r--arch/arm/kernel/leds.c121
-rw-r--r--arch/arm/kernel/process.c6
-rw-r--r--arch/arm/kernel/time.c17
-rw-r--r--arch/arm/mach-at91/board-csb337.c2
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c18
-rw-r--r--arch/arm/mach-at91/board-eco920.c22
-rw-r--r--arch/arm/mach-at91/board-kafa.c17
-rw-r--r--arch/arm/mach-at91/board-kb9202.c23
-rw-r--r--arch/arm/mach-at91/board-rm9200dk.c3
-rw-r--r--arch/arm/mach-at91/board-rm9200ek.c3
-rw-r--r--arch/arm/mach-at91/board-rsi-ews.c3
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c23
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c3
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c3
-rw-r--r--arch/arm/mach-at91/include/mach/board.h1
-rw-r--r--arch/arm/mach-at91/leds.c105
-rw-r--r--arch/arm/mach-clps711x/Makefile2
-rw-r--r--arch/arm/mach-clps711x/common.c1
-rw-r--r--arch/arm/mach-clps711x/p720t-leds.c63
-rw-r--r--arch/arm/mach-clps711x/p720t.c62
-rw-r--r--arch/arm/mach-ebsa110/Makefile4
-rw-r--r--arch/arm/mach-ebsa110/leds.c81
-rw-r--r--arch/arm/mach-footbridge/Makefile4
-rw-r--r--arch/arm/mach-footbridge/ebsa285-leds.c138
-rw-r--r--arch/arm/mach-footbridge/ebsa285.c81
-rw-r--r--arch/arm/mach-footbridge/netwinder-hw.c112
-rw-r--r--arch/arm/mach-footbridge/netwinder-leds.c138
-rw-r--r--arch/arm/mach-integrator/Makefile3
-rw-r--r--arch/arm/mach-integrator/core.c3
-rw-r--r--arch/arm/mach-integrator/include/mach/cm.h2
-rw-r--r--arch/arm/mach-integrator/leds.c161
-rw-r--r--arch/arm/mach-ks8695/Makefile3
-rw-r--r--arch/arm/mach-ks8695/devices.c21
-rw-r--r--arch/arm/mach-ks8695/include/mach/devices.h5
-rw-r--r--arch/arm/mach-ks8695/leds.c92
-rw-r--r--arch/arm/mach-omap1/Makefile8
-rw-r--r--arch/arm/mach-omap1/board-h2.c32
-rw-r--r--arch/arm/mach-omap1/board-h3.c32
-rw-r--r--arch/arm/mach-omap1/board-osk.c33
-rw-r--r--arch/arm/mach-omap1/leds-h2p2-debug.c166
-rw-r--r--arch/arm/mach-omap1/leds-innovator.c98
-rw-r--r--arch/arm/mach-omap1/leds-osk.c113
-rw-r--r--arch/arm/mach-omap1/leds.c69
-rw-r--r--arch/arm/mach-omap1/leds.h3
-rw-r--r--arch/arm/mach-omap1/time.c1
-rw-r--r--arch/arm/mach-omap1/timer32k.c1
-rw-r--r--arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c1
-rw-r--r--arch/arm/mach-orion5x/rd88f5181l-ge-setup.c1
-rw-r--r--arch/arm/mach-orion5x/rd88f5182-setup.c72
-rw-r--r--arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c1
-rw-r--r--arch/arm/mach-pnx4008/time.c1
-rw-r--r--arch/arm/mach-pxa/Makefile8
-rw-r--r--arch/arm/mach-pxa/idp.c81
-rw-r--r--arch/arm/mach-pxa/leds-idp.c115
-rw-r--r--arch/arm/mach-pxa/leds-lubbock.c124
-rw-r--r--arch/arm/mach-pxa/leds-mainstone.c119
-rw-r--r--arch/arm/mach-pxa/leds.c32
-rw-r--r--arch/arm/mach-pxa/leds.h13
-rw-r--r--arch/arm/mach-pxa/lubbock.c95
-rw-r--r--arch/arm/mach-pxa/mainstone.c94
-rw-r--r--arch/arm/mach-realview/core.c39
-rw-r--r--arch/arm/mach-realview/core.h2
-rw-r--r--arch/arm/mach-realview/realview_eb.c5
-rw-r--r--arch/arm/mach-realview/realview_pb1176.c5
-rw-r--r--arch/arm/mach-realview/realview_pb11mp.c5
-rw-r--r--arch/arm/mach-realview/realview_pba8.c5
-rw-r--r--arch/arm/mach-realview/realview_pbx.c5
-rw-r--r--arch/arm/mach-sa1100/Makefile9
-rw-r--r--arch/arm/mach-sa1100/assabet.c85
-rw-r--r--arch/arm/mach-sa1100/badge4.c30
-rw-r--r--arch/arm/mach-sa1100/cerf.c42
-rw-r--r--arch/arm/mach-sa1100/hackkit.c32
-rw-r--r--arch/arm/mach-sa1100/lart.c26
-rw-r--r--arch/arm/mach-sa1100/leds-assabet.c113
-rw-r--r--arch/arm/mach-sa1100/leds-badge4.c110
-rw-r--r--arch/arm/mach-sa1100/leds-cerf.c110
-rw-r--r--arch/arm/mach-sa1100/leds-hackkit.c111
-rw-r--r--arch/arm/mach-sa1100/leds-lart.c101
-rw-r--r--arch/arm/mach-sa1100/leds.c50
-rw-r--r--arch/arm/mach-sa1100/leds.h13
-rw-r--r--arch/arm/mach-shark/Makefile4
-rw-r--r--arch/arm/mach-shark/core.c1
-rw-r--r--arch/arm/mach-shark/leds.c220
-rw-r--r--arch/arm/mach-versatile/core.c5
-rw-r--r--arch/arm/plat-omap/Kconfig3
-rw-r--r--arch/arm/plat-omap/debug-leds.c293
-rw-r--r--arch/arm/plat-samsung/time.c1
-rw-r--r--arch/arm/plat-versatile/Kconfig4
-rw-r--r--arch/arm/plat-versatile/leds.c8
92 files changed, 1251 insertions, 2949 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e91c7cdc6fe5..ac353cf0180b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1787,59 +1787,6 @@ config FORCE_MAX_ZONEORDER
1787 This config option is actually maximum order plus one. For example, 1787 This config option is actually maximum order plus one. For example,
1788 a value of 11 means that the largest free memory block is 2^10 pages. 1788 a value of 11 means that the largest free memory block is 2^10 pages.
1789 1789
1790config LEDS
1791 bool "Timer and CPU usage LEDs"
1792 depends on ARCH_CDB89712 || ARCH_EBSA110 || \
1793 ARCH_EBSA285 || ARCH_INTEGRATOR || \
1794 ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \
1795 ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \
1796 ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \
1797 ARCH_AT91 || ARCH_DAVINCI || \
1798 ARCH_KS8695 || MACH_RD88F5182 || ARCH_REALVIEW
1799 help
1800 If you say Y here, the LEDs on your machine will be used
1801 to provide useful information about your current system status.
1802
1803 If you are compiling a kernel for a NetWinder or EBSA-285, you will
1804 be able to select which LEDs are active using the options below. If
1805 you are compiling a kernel for the EBSA-110 or the LART however, the
1806 red LED will simply flash regularly to indicate that the system is
1807 still functional. It is safe to say Y here if you have a CATS
1808 system, but the driver will do nothing.
1809
1810config LEDS_TIMER
1811 bool "Timer LED" if (!ARCH_CDB89712 && !ARCH_OMAP) || \
1812 OMAP_OSK_MISTRAL || MACH_OMAP_H2 \
1813 || MACH_OMAP_PERSEUS2
1814 depends on LEDS
1815 depends on !GENERIC_CLOCKEVENTS
1816 default y if ARCH_EBSA110
1817 help
1818 If you say Y here, one of the system LEDs (the green one on the
1819 NetWinder, the amber one on the EBSA285, or the red one on the LART)
1820 will flash regularly to indicate that the system is still
1821 operational. This is mainly useful to kernel hackers who are
1822 debugging unstable kernels.
1823
1824 The LART uses the same LED for both Timer LED and CPU usage LED
1825 functions. You may choose to use both, but the Timer LED function
1826 will overrule the CPU usage LED.
1827
1828config LEDS_CPU
1829 bool "CPU usage LED" if (!ARCH_CDB89712 && !ARCH_EBSA110 && \
1830 !ARCH_OMAP) \
1831 || OMAP_OSK_MISTRAL || MACH_OMAP_H2 \
1832 || MACH_OMAP_PERSEUS2
1833 depends on LEDS
1834 help
1835 If you say Y here, the red LED will be used to give a good real
1836 time indication of CPU usage, by lighting whenever the idle task
1837 is not currently executing.
1838
1839 The LART uses the same LED for both Timer LED and CPU usage LED
1840 functions. You may choose to use both, but the Timer LED function
1841 will overrule the CPU usage LED.
1842
1843config ALIGNMENT_TRAP 1790config ALIGNMENT_TRAP
1844 bool 1791 bool
1845 depends on CPU_CP15_MMU 1792 depends on CPU_CP15_MMU
diff --git a/arch/arm/include/asm/leds.h b/arch/arm/include/asm/leds.h
deleted file mode 100644
index c545739f39b7..000000000000
--- a/arch/arm/include/asm/leds.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * arch/arm/include/asm/leds.h
3 *
4 * Copyright (C) 1998 Russell King
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 * Event-driven interface for LEDs on machines
11 * Added led_start and led_stop- Alex Holden, 28th Dec 1998.
12 */
13#ifndef ASM_ARM_LEDS_H
14#define ASM_ARM_LEDS_H
15
16
17typedef enum {
18 led_idle_start,
19 led_idle_end,
20 led_timer,
21 led_start,
22 led_stop,
23 led_claim, /* override idle & timer leds */
24 led_release, /* restore idle & timer leds */
25 led_start_timer_mode,
26 led_stop_timer_mode,
27 led_green_on,
28 led_green_off,
29 led_amber_on,
30 led_amber_off,
31 led_red_on,
32 led_red_off,
33 led_blue_on,
34 led_blue_off,
35 /*
36 * I want this between led_timer and led_start, but
37 * someone has decided to export this to user space
38 */
39 led_halted
40} led_event_t;
41
42/* Use this routine to handle LEDs */
43
44#ifdef CONFIG_LEDS
45extern void (*leds_event)(led_event_t);
46#else
47#define leds_event(e)
48#endif
49
50#endif
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 7ad2d5cf7008..8951577c4ced 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -21,7 +21,6 @@ obj-y := elf.o entry-armv.o entry-common.o irq.o opcodes.o \
21 21
22obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += compat.o 22obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += compat.o
23 23
24obj-$(CONFIG_LEDS) += leds.o
25obj-$(CONFIG_OC_ETM) += etm.o 24obj-$(CONFIG_OC_ETM) += etm.o
26obj-$(CONFIG_CPU_IDLE) += cpuidle.o 25obj-$(CONFIG_CPU_IDLE) += cpuidle.o
27obj-$(CONFIG_ISA_DMA_API) += dma.o 26obj-$(CONFIG_ISA_DMA_API) += dma.o
diff --git a/arch/arm/kernel/leds.c b/arch/arm/kernel/leds.c
deleted file mode 100644
index 1911dae19e4f..000000000000
--- a/arch/arm/kernel/leds.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * LED support code, ripped out of arch/arm/kernel/time.c
3 *
4 * Copyright (C) 1994-2001 Russell King
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#include <linux/export.h>
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/syscore_ops.h>
14#include <linux/string.h>
15
16#include <asm/leds.h>
17
18static void dummy_leds_event(led_event_t evt)
19{
20}
21
22void (*leds_event)(led_event_t) = dummy_leds_event;
23
24struct leds_evt_name {
25 const char name[8];
26 int on;
27 int off;
28};
29
30static const struct leds_evt_name evt_names[] = {
31 { "amber", led_amber_on, led_amber_off },
32 { "blue", led_blue_on, led_blue_off },
33 { "green", led_green_on, led_green_off },
34 { "red", led_red_on, led_red_off },
35};
36
37static ssize_t leds_store(struct device *dev,
38 struct device_attribute *attr,
39 const char *buf, size_t size)
40{
41 int ret = -EINVAL, len = strcspn(buf, " ");
42
43 if (len > 0 && buf[len] == '\0')
44 len--;
45
46 if (strncmp(buf, "claim", len) == 0) {
47 leds_event(led_claim);
48 ret = size;
49 } else if (strncmp(buf, "release", len) == 0) {
50 leds_event(led_release);
51 ret = size;
52 } else {
53 int i;
54
55 for (i = 0; i < ARRAY_SIZE(evt_names); i++) {
56 if (strlen(evt_names[i].name) != len ||
57 strncmp(buf, evt_names[i].name, len) != 0)
58 continue;
59 if (strncmp(buf+len, " on", 3) == 0) {
60 leds_event(evt_names[i].on);
61 ret = size;
62 } else if (strncmp(buf+len, " off", 4) == 0) {
63 leds_event(evt_names[i].off);
64 ret = size;
65 }
66 break;
67 }
68 }
69 return ret;
70}
71
72static DEVICE_ATTR(event, 0200, NULL, leds_store);
73
74static struct bus_type leds_subsys = {
75 .name = "leds",
76 .dev_name = "leds",
77};
78
79static struct device leds_device = {
80 .id = 0,
81 .bus = &leds_subsys,
82};
83
84static int leds_suspend(void)
85{
86 leds_event(led_stop);
87 return 0;
88}
89
90static void leds_resume(void)
91{
92 leds_event(led_start);
93}
94
95static void leds_shutdown(void)
96{
97 leds_event(led_halted);
98}
99
100static struct syscore_ops leds_syscore_ops = {
101 .shutdown = leds_shutdown,
102 .suspend = leds_suspend,
103 .resume = leds_resume,
104};
105
106static int __init leds_init(void)
107{
108 int ret;
109 ret = subsys_system_register(&leds_subsys, NULL);
110 if (ret == 0)
111 ret = device_register(&leds_device);
112 if (ret == 0)
113 ret = device_create_file(&leds_device, &dev_attr_event);
114 if (ret == 0)
115 register_syscore_ops(&leds_syscore_ops);
116 return ret;
117}
118
119device_initcall(leds_init);
120
121EXPORT_SYMBOL(leds_event);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 693b744fd572..04eea22d7958 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -31,9 +31,9 @@
31#include <linux/random.h> 31#include <linux/random.h>
32#include <linux/hw_breakpoint.h> 32#include <linux/hw_breakpoint.h>
33#include <linux/cpuidle.h> 33#include <linux/cpuidle.h>
34#include <linux/leds.h>
34 35
35#include <asm/cacheflush.h> 36#include <asm/cacheflush.h>
36#include <asm/leds.h>
37#include <asm/processor.h> 37#include <asm/processor.h>
38#include <asm/thread_notify.h> 38#include <asm/thread_notify.h>
39#include <asm/stacktrace.h> 39#include <asm/stacktrace.h>
@@ -189,7 +189,7 @@ void cpu_idle(void)
189 while (1) { 189 while (1) {
190 tick_nohz_idle_enter(); 190 tick_nohz_idle_enter();
191 rcu_idle_enter(); 191 rcu_idle_enter();
192 leds_event(led_idle_start); 192 ledtrig_cpu(CPU_LED_IDLE_START);
193 while (!need_resched()) { 193 while (!need_resched()) {
194#ifdef CONFIG_HOTPLUG_CPU 194#ifdef CONFIG_HOTPLUG_CPU
195 if (cpu_is_offline(smp_processor_id())) 195 if (cpu_is_offline(smp_processor_id()))
@@ -220,7 +220,7 @@ void cpu_idle(void)
220 } else 220 } else
221 local_irq_enable(); 221 local_irq_enable();
222 } 222 }
223 leds_event(led_idle_end); 223 ledtrig_cpu(CPU_LED_IDLE_END);
224 rcu_idle_exit(); 224 rcu_idle_exit();
225 tick_nohz_idle_exit(); 225 tick_nohz_idle_exit();
226 schedule_preempt_disabled(); 226 schedule_preempt_disabled();
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index af2afb019672..09be0c3c9069 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -25,7 +25,6 @@
25#include <linux/timer.h> 25#include <linux/timer.h>
26#include <linux/irq.h> 26#include <linux/irq.h>
27 27
28#include <asm/leds.h>
29#include <asm/thread_info.h> 28#include <asm/thread_info.h>
30#include <asm/sched_clock.h> 29#include <asm/sched_clock.h>
31#include <asm/stacktrace.h> 30#include <asm/stacktrace.h>
@@ -80,21 +79,6 @@ u32 arch_gettimeoffset(void)
80} 79}
81#endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */ 80#endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */
82 81
83#ifdef CONFIG_LEDS_TIMER
84static inline void do_leds(void)
85{
86 static unsigned int count = HZ/2;
87
88 if (--count == 0) {
89 count = HZ/2;
90 leds_event(led_timer);
91 }
92}
93#else
94#define do_leds()
95#endif
96
97
98#ifndef CONFIG_GENERIC_CLOCKEVENTS 82#ifndef CONFIG_GENERIC_CLOCKEVENTS
99/* 83/*
100 * Kernel system timer support. 84 * Kernel system timer support.
@@ -102,7 +86,6 @@ static inline void do_leds(void)
102void timer_tick(void) 86void timer_tick(void)
103{ 87{
104 profile_tick(CPU_PROFILING); 88 profile_tick(CPU_PROFILING);
105 do_leds();
106 xtime_update(1); 89 xtime_update(1);
107#ifndef CONFIG_SMP 90#ifndef CONFIG_SMP
108 update_process_times(user_mode(get_irq_regs())); 91 update_process_times(user_mode(get_irq_regs()));
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index 462bc319cbc5..32396bb4a4c9 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -220,8 +220,6 @@ static struct gpio_led csb_leds[] = {
220 220
221static void __init csb337_board_init(void) 221static void __init csb337_board_init(void)
222{ 222{
223 /* Setup the LEDs */
224 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
225 /* Serial */ 223 /* Serial */
226 /* DBGU on ttyS0 */ 224 /* DBGU on ttyS0 */
227 at91_register_uart(0, 0, 0); 225 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index 9c24cb25707c..192ec76579c4 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -138,11 +138,20 @@ static struct spi_board_info __initdata ecb_at91spi_devices[] = {
138 }, 138 },
139}; 139};
140 140
141/*
142 * LEDs
143 */
144static struct gpio_led ecb_leds[] = {
145 { /* D1 */
146 .name = "led1",
147 .gpio = AT91_PIN_PC7,
148 .active_low = 1,
149 .default_trigger = "heartbeat",
150 }
151};
152
141static void __init ecb_at91board_init(void) 153static void __init ecb_at91board_init(void)
142{ 154{
143 /* Setup the LEDs */
144 at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7);
145
146 /* Serial */ 155 /* Serial */
147 /* DBGU on ttyS0. (Rx & Tx only) */ 156 /* DBGU on ttyS0. (Rx & Tx only) */
148 at91_register_uart(0, 0, 0); 157 at91_register_uart(0, 0, 0);
@@ -165,6 +174,9 @@ static void __init ecb_at91board_init(void)
165 174
166 /* SPI */ 175 /* SPI */
167 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices)); 176 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices));
177
178 /* LEDs */
179 at91_gpio_leds(ecb_leds, ARRAY_SIZE(ecb_leds));
168} 180}
169 181
170MACHINE_START(ECBAT91, "emQbit's ECB_AT91") 182MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index 82bdfde3405f..d2d4580df48f 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -93,10 +93,26 @@ static struct spi_board_info eco920_spi_devices[] = {
93 }, 93 },
94}; 94};
95 95
96/*
97 * LEDs
98 */
99static struct gpio_led eco920_leds[] = {
100 { /* D1 */
101 .name = "led1",
102 .gpio = AT91_PIN_PB0,
103 .active_low = 1,
104 .default_trigger = "heartbeat",
105 },
106 { /* D2 */
107 .name = "led2",
108 .gpio = AT91_PIN_PB1,
109 .active_low = 1,
110 .default_trigger = "timer",
111 }
112};
113
96static void __init eco920_board_init(void) 114static void __init eco920_board_init(void)
97{ 115{
98 /* Setup the LEDs */
99 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
100 /* DBGU on ttyS0. (Rx & Tx only */ 116 /* DBGU on ttyS0. (Rx & Tx only */
101 at91_register_uart(0, 0, 0); 117 at91_register_uart(0, 0, 0);
102 at91_add_device_serial(); 118 at91_add_device_serial();
@@ -127,6 +143,8 @@ static void __init eco920_board_init(void)
127 ); 143 );
128 144
129 at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices)); 145 at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices));
146 /* LEDs */
147 at91_gpio_leds(eco920_leds, ARRAY_SIZE(eco920_leds));
130} 148}
131 149
132MACHINE_START(ECO920, "eco920") 150MACHINE_START(ECO920, "eco920")
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index 64c1dbf88a07..86050da3ba53 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -66,11 +66,20 @@ static struct at91_udc_data __initdata kafa_udc_data = {
66 .pullup_pin = AT91_PIN_PB7, 66 .pullup_pin = AT91_PIN_PB7,
67}; 67};
68 68
69/*
70 * LEDs
71 */
72static struct gpio_led kafa_leds[] = {
73 { /* D1 */
74 .name = "led1",
75 .gpio = AT91_PIN_PB4,
76 .active_low = 1,
77 .default_trigger = "heartbeat",
78 },
79};
80
69static void __init kafa_board_init(void) 81static void __init kafa_board_init(void)
70{ 82{
71 /* Set up the LEDs */
72 at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4);
73
74 /* Serial */ 83 /* Serial */
75 /* DBGU on ttyS0. (Rx & Tx only) */ 84 /* DBGU on ttyS0. (Rx & Tx only) */
76 at91_register_uart(0, 0, 0); 85 at91_register_uart(0, 0, 0);
@@ -88,6 +97,8 @@ static void __init kafa_board_init(void)
88 at91_add_device_i2c(NULL, 0); 97 at91_add_device_i2c(NULL, 0);
89 /* SPI */ 98 /* SPI */
90 at91_add_device_spi(NULL, 0); 99 at91_add_device_spi(NULL, 0);
100 /* LEDs */
101 at91_gpio_leds(kafa_leds, ARRAY_SIZE(kafa_leds));
91} 102}
92 103
93MACHINE_START(KAFA, "Sperry-Sun KAFA") 104MACHINE_START(KAFA, "Sperry-Sun KAFA")
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index 5d96cb85175f..00d60071770c 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -96,11 +96,26 @@ static struct atmel_nand_data __initdata kb9202_nand_data = {
96 .num_parts = ARRAY_SIZE(kb9202_nand_partition), 96 .num_parts = ARRAY_SIZE(kb9202_nand_partition),
97}; 97};
98 98
99/*
100 * LEDs
101 */
102static struct gpio_led kb9202_leds[] = {
103 { /* D1 */
104 .name = "led1",
105 .gpio = AT91_PIN_PC19,
106 .active_low = 1,
107 .default_trigger = "heartbeat",
108 },
109 { /* D2 */
110 .name = "led2",
111 .gpio = AT91_PIN_PC18,
112 .active_low = 1,
113 .default_trigger = "timer",
114 }
115};
116
99static void __init kb9202_board_init(void) 117static void __init kb9202_board_init(void)
100{ 118{
101 /* Set up the LEDs */
102 at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18);
103
104 /* Serial */ 119 /* Serial */
105 /* DBGU on ttyS0. (Rx & Tx only) */ 120 /* DBGU on ttyS0. (Rx & Tx only) */
106 at91_register_uart(0, 0, 0); 121 at91_register_uart(0, 0, 0);
@@ -128,6 +143,8 @@ static void __init kb9202_board_init(void)
128 at91_add_device_spi(NULL, 0); 143 at91_add_device_spi(NULL, 0);
129 /* NAND */ 144 /* NAND */
130 at91_add_device_nand(&kb9202_nand_data); 145 at91_add_device_nand(&kb9202_nand_data);
146 /* LEDs */
147 at91_gpio_leds(kb9202_leds, ARRAY_SIZE(kb9202_leds));
131} 148}
132 149
133MACHINE_START(KB9200, "KB920x") 150MACHINE_START(KB9200, "KB920x")
diff --git a/arch/arm/mach-at91/board-rm9200dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index cc2bf9796073..2526ad759b5b 100644
--- a/arch/arm/mach-at91/board-rm9200dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -177,9 +177,6 @@ static struct gpio_led dk_leds[] = {
177 177
178static void __init dk_board_init(void) 178static void __init dk_board_init(void)
179{ 179{
180 /* Setup the LEDs */
181 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
182
183 /* Serial */ 180 /* Serial */
184 /* DBGU on ttyS0. (Rx & Tx only) */ 181 /* DBGU on ttyS0. (Rx & Tx only) */
185 at91_register_uart(0, 0, 0); 182 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-rm9200ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index 62e19e64c9d3..06f2ce543e2a 100644
--- a/arch/arm/mach-at91/board-rm9200ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -148,9 +148,6 @@ static struct gpio_led ek_leds[] = {
148 148
149static void __init ek_board_init(void) 149static void __init ek_board_init(void)
150{ 150{
151 /* Setup the LEDs */
152 at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
153
154 /* Serial */ 151 /* Serial */
155 /* DBGU on ttyS0. (Rx & Tx only) */ 152 /* DBGU on ttyS0. (Rx & Tx only) */
156 at91_register_uart(0, 0, 0); 153 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-rsi-ews.c b/arch/arm/mach-at91/board-rsi-ews.c
index c3b43aefdb75..93b8e3a45e23 100644
--- a/arch/arm/mach-at91/board-rsi-ews.c
+++ b/arch/arm/mach-at91/board-rsi-ews.c
@@ -185,9 +185,6 @@ static struct platform_device rsiews_nor_flash = {
185 */ 185 */
186static void __init rsi_ews_board_init(void) 186static void __init rsi_ews_board_init(void)
187{ 187{
188 /* Setup the LEDs */
189 at91_init_leds(AT91_PIN_PB6, AT91_PIN_PB9);
190
191 /* Serial */ 188 /* Serial */
192 /* DBGU on ttyS0. (Rx & Tx only) */ 189 /* DBGU on ttyS0. (Rx & Tx only) */
193 /* This one is for debugging */ 190 /* This one is for debugging */
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index 7bf6da70d7d5..46e1eb550537 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -166,11 +166,26 @@ static struct at91_mmc_data __initdata ek_mmc_data = {
166 .vcc_pin = -EINVAL, 166 .vcc_pin = -EINVAL,
167}; 167};
168 168
169/*
170 * LEDs
171 */
172static struct gpio_led ek_leds[] = {
173 { /* D1 */
174 .name = "led1",
175 .gpio = AT91_PIN_PA9,
176 .active_low = 1,
177 .default_trigger = "heartbeat",
178 },
179 { /* D2 */
180 .name = "led2",
181 .gpio = AT91_PIN_PA6,
182 .active_low = 1,
183 .default_trigger = "timer",
184 }
185};
186
169static void __init ek_board_init(void) 187static void __init ek_board_init(void)
170{ 188{
171 /* Setup the LEDs */
172 at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6);
173
174 /* Serial */ 189 /* Serial */
175 /* DBGU on ttyS0. (Rx & Tx only) */ 190 /* DBGU on ttyS0. (Rx & Tx only) */
176 at91_register_uart(0, 0, 0); 191 at91_register_uart(0, 0, 0);
@@ -197,6 +212,8 @@ static void __init ek_board_init(void)
197 at91_add_device_mmc(0, &ek_mmc_data); 212 at91_add_device_mmc(0, &ek_mmc_data);
198 /* I2C */ 213 /* I2C */
199 at91_add_device_i2c(NULL, 0); 214 at91_add_device_i2c(NULL, 0);
215 /* LEDs */
216 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
200} 217}
201 218
202MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260") 219MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 2269be5fa384..802d4946bb32 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -569,9 +569,6 @@ static struct gpio_led ek_leds[] = {
569 569
570static void __init ek_board_init(void) 570static void __init ek_board_init(void)
571{ 571{
572 /* Setup the LEDs */
573 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
574
575 /* Serial */ 572 /* Serial */
576 /* DBGU on ttyS0. (Rx & Tx only) */ 573 /* DBGU on ttyS0. (Rx & Tx only) */
577 at91_register_uart(0, 0, 0); 574 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index 516d340549d8..9fd57bcac693 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -541,9 +541,6 @@ void __init yl9200_add_device_video(void) {}
541 541
542static void __init yl9200_board_init(void) 542static void __init yl9200_board_init(void)
543{ 543{
544 /* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */
545 at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17);
546
547 /* Serial */ 544 /* Serial */
548 /* DBGU on ttyS0. (Rx & Tx only) */ 545 /* DBGU on ttyS0. (Rx & Tx only) */
549 at91_register_uart(0, 0, 0); 546 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 369afc2ffc5b..c55a4364ffb4 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -187,7 +187,6 @@ struct at91_can_data {
187extern void __init at91_add_device_can(struct at91_can_data *data); 187extern void __init at91_add_device_can(struct at91_can_data *data);
188 188
189 /* LEDs */ 189 /* LEDs */
190extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
191extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); 190extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
192extern void __init at91_pwm_leds(struct gpio_led *leds, int nr); 191extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);
193 192
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c
index 8dfafe76ffe6..1b1e62b5f41b 100644
--- a/arch/arm/mach-at91/leds.c
+++ b/arch/arm/mach-at91/leds.c
@@ -90,108 +90,3 @@ void __init at91_pwm_leds(struct gpio_led *leds, int nr)
90#else 90#else
91void __init at91_pwm_leds(struct gpio_led *leds, int nr){} 91void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
92#endif 92#endif
93
94
95/* ------------------------------------------------------------------------- */
96
97#if defined(CONFIG_LEDS)
98
99#include <asm/leds.h>
100
101/*
102 * Old ARM-specific LED framework; not fully functional when generic time is
103 * in use.
104 */
105
106static u8 at91_leds_cpu;
107static u8 at91_leds_timer;
108
109static inline void at91_led_on(unsigned int led)
110{
111 at91_set_gpio_value(led, 0);
112}
113
114static inline void at91_led_off(unsigned int led)
115{
116 at91_set_gpio_value(led, 1);
117}
118
119static inline void at91_led_toggle(unsigned int led)
120{
121 unsigned long is_off = at91_get_gpio_value(led);
122 if (is_off)
123 at91_led_on(led);
124 else
125 at91_led_off(led);
126}
127
128
129/*
130 * Handle LED events.
131 */
132static void at91_leds_event(led_event_t evt)
133{
134 unsigned long flags;
135
136 local_irq_save(flags);
137
138 switch(evt) {
139 case led_start: /* System startup */
140 at91_led_on(at91_leds_cpu);
141 break;
142
143 case led_stop: /* System stop / suspend */
144 at91_led_off(at91_leds_cpu);
145 break;
146
147#ifdef CONFIG_LEDS_TIMER
148 case led_timer: /* Every 50 timer ticks */
149 at91_led_toggle(at91_leds_timer);
150 break;
151#endif
152
153#ifdef CONFIG_LEDS_CPU
154 case led_idle_start: /* Entering idle state */
155 at91_led_off(at91_leds_cpu);
156 break;
157
158 case led_idle_end: /* Exit idle state */
159 at91_led_on(at91_leds_cpu);
160 break;
161#endif
162
163 default:
164 break;
165 }
166
167 local_irq_restore(flags);
168}
169
170
171static int __init leds_init(void)
172{
173 if (!at91_leds_timer || !at91_leds_cpu)
174 return -ENODEV;
175
176 leds_event = at91_leds_event;
177
178 leds_event(led_start);
179 return 0;
180}
181
182__initcall(leds_init);
183
184
185void __init at91_init_leds(u8 cpu_led, u8 timer_led)
186{
187 /* Enable GPIO to access the LEDs */
188 at91_set_gpio_output(cpu_led, 1);
189 at91_set_gpio_output(timer_led, 1);
190
191 at91_leds_cpu = cpu_led;
192 at91_leds_timer = timer_led;
193}
194
195#else
196void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
197#endif
diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
index f2f0256232e3..5872b49bfaed 100644
--- a/arch/arm/mach-clps711x/Makefile
+++ b/arch/arm/mach-clps711x/Makefile
@@ -16,5 +16,3 @@ obj-$(CONFIG_ARCH_CLEP7312) += clep7312.o
16obj-$(CONFIG_ARCH_EDB7211) += edb7211-arch.o edb7211-mm.o 16obj-$(CONFIG_ARCH_EDB7211) += edb7211-arch.o edb7211-mm.o
17obj-$(CONFIG_ARCH_FORTUNET) += fortunet.o 17obj-$(CONFIG_ARCH_FORTUNET) += fortunet.o
18obj-$(CONFIG_ARCH_P720T) += p720t.o 18obj-$(CONFIG_ARCH_P720T) += p720t.o
19leds-$(CONFIG_ARCH_P720T) += p720t-leds.o
20obj-$(CONFIG_LEDS) += $(leds-y)
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c
index f15293bd7974..3a4af00db9e3 100644
--- a/arch/arm/mach-clps711x/common.c
+++ b/arch/arm/mach-clps711x/common.c
@@ -30,7 +30,6 @@
30#include <asm/sizes.h> 30#include <asm/sizes.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/leds.h>
34#include <asm/pgtable.h> 33#include <asm/pgtable.h>
35#include <asm/page.h> 34#include <asm/page.h>
36#include <asm/mach/map.h> 35#include <asm/mach/map.h>
diff --git a/arch/arm/mach-clps711x/p720t-leds.c b/arch/arm/mach-clps711x/p720t-leds.c
deleted file mode 100644
index bbc449fbe14a..000000000000
--- a/arch/arm/mach-clps711x/p720t-leds.c
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * linux/arch/arm/mach-clps711x/leds.c
3 *
4 * Integrator LED control routines
5 *
6 * Copyright (C) 2000 Deep Blue Solutions Ltd
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/io.h>
25
26#include <mach/hardware.h>
27#include <asm/leds.h>
28#include <asm/mach-types.h>
29
30static void p720t_leds_event(led_event_t ledevt)
31{
32 unsigned long flags;
33 u32 pddr;
34
35 local_irq_save(flags);
36 switch(ledevt) {
37 case led_idle_start:
38 break;
39
40 case led_idle_end:
41 break;
42
43 case led_timer:
44 pddr = clps_readb(PDDR);
45 clps_writeb(pddr ^ 1, PDDR);
46 break;
47
48 default:
49 break;
50 }
51
52 local_irq_restore(flags);
53}
54
55static int __init leds_init(void)
56{
57 if (machine_is_p720t())
58 leds_event = p720t_leds_event;
59
60 return 0;
61}
62
63arch_initcall(leds_init);
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index f266d90b9efc..b752b586fc2f 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -23,6 +23,8 @@
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/slab.h>
27#include <linux/leds.h>
26 28
27#include <mach/hardware.h> 29#include <mach/hardware.h>
28#include <asm/pgtable.h> 30#include <asm/pgtable.h>
@@ -34,6 +36,8 @@
34#include <asm/mach/map.h> 36#include <asm/mach/map.h>
35#include <mach/syspld.h> 37#include <mach/syspld.h>
36 38
39#include <asm/hardware/clps7111.h>
40
37#include "common.h" 41#include "common.h"
38 42
39/* 43/*
@@ -107,6 +111,64 @@ static void __init p720t_init_early(void)
107 } 111 }
108} 112}
109 113
114/*
115 * LED controled by CPLD
116 */
117#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
118static void p720t_led_set(struct led_classdev *cdev,
119 enum led_brightness b)
120{
121 u8 reg = clps_readb(PDDR);
122
123 if (b != LED_OFF)
124 reg |= 0x1;
125 else
126 reg &= ~0x1;
127
128 clps_writeb(reg, PDDR);
129}
130
131static enum led_brightness p720t_led_get(struct led_classdev *cdev)
132{
133 u8 reg = clps_readb(PDDR);
134
135 return (reg & 0x1) ? LED_FULL : LED_OFF;
136}
137
138static int __init p720t_leds_init(void)
139{
140
141 struct led_classdev *cdev;
142 int ret;
143
144 if (!machine_is_p720t())
145 return -ENODEV;
146
147 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
148 if (!cdev)
149 return -ENOMEM;
150
151 cdev->name = "p720t:0";
152 cdev->brightness_set = p720t_led_set;
153 cdev->brightness_get = p720t_led_get;
154 cdev->default_trigger = "heartbeat";
155
156 ret = led_classdev_register(NULL, cdev);
157 if (ret < 0) {
158 kfree(cdev);
159 return ret;
160 }
161
162 return 0;
163}
164
165/*
166 * Since we may have triggers on any subsystem, defer registration
167 * until after subsystem_init.
168 */
169fs_initcall(p720t_leds_init);
170#endif
171
110MACHINE_START(P720T, "ARM-Prospector720T") 172MACHINE_START(P720T, "ARM-Prospector720T")
111 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 173 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
112 .atag_offset = 0x100, 174 .atag_offset = 0x100,
diff --git a/arch/arm/mach-ebsa110/Makefile b/arch/arm/mach-ebsa110/Makefile
index 6520ac835802..935e4af01a27 100644
--- a/arch/arm/mach-ebsa110/Makefile
+++ b/arch/arm/mach-ebsa110/Makefile
@@ -4,9 +4,7 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := core.o io.o 7obj-y := core.o io.o leds.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
11
12obj-$(CONFIG_LEDS) += leds.o
diff --git a/arch/arm/mach-ebsa110/leds.c b/arch/arm/mach-ebsa110/leds.c
index 99e14e362500..0398258c20cd 100644
--- a/arch/arm/mach-ebsa110/leds.c
+++ b/arch/arm/mach-ebsa110/leds.c
@@ -1,52 +1,71 @@
1/* 1/*
2 * linux/arch/arm/mach-ebsa110/leds.c 2 * Driver for the LED found on the EBSA110 machine
3 * Based on Versatile and RealView machine LED code
3 * 4 *
4 * Copyright (C) 1998 Russell King 5 * License terms: GNU General Public License (GPL) version 2
5 * 6 * Author: Bryan Wu <bryan.wu@canonical.com>
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 * EBSA-110 LED control routines. We use the led as follows:
11 *
12 * - Red - toggles state every 50 timer interrupts
13 */ 7 */
14#include <linux/module.h> 8#include <linux/kernel.h>
15#include <linux/spinlock.h>
16#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/io.h>
11#include <linux/slab.h>
12#include <linux/leds.h>
17 13
18#include <mach/hardware.h>
19#include <asm/leds.h>
20#include <asm/mach-types.h> 14#include <asm/mach-types.h>
21 15
22#include "core.h" 16#include "core.h"
23 17
24static spinlock_t leds_lock; 18#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
25 19static void ebsa110_led_set(struct led_classdev *cdev,
26static void ebsa110_leds_event(led_event_t ledevt) 20 enum led_brightness b)
27{ 21{
28 unsigned long flags; 22 u8 reg = __raw_readb(SOFT_BASE);
29 23
30 spin_lock_irqsave(&leds_lock, flags); 24 if (b != LED_OFF)
25 reg |= 0x80;
26 else
27 reg &= ~0x80;
31 28
32 switch(ledevt) { 29 __raw_writeb(reg, SOFT_BASE);
33 case led_timer: 30}
34 *(volatile unsigned char *)SOFT_BASE ^= 128;
35 break;
36 31
37 default: 32static enum led_brightness ebsa110_led_get(struct led_classdev *cdev)
38 break; 33{
39 } 34 u8 reg = __raw_readb(SOFT_BASE);
40 35
41 spin_unlock_irqrestore(&leds_lock, flags); 36 return (reg & 0x80) ? LED_FULL : LED_OFF;
42} 37}
43 38
44static int __init leds_init(void) 39static int __init ebsa110_leds_init(void)
45{ 40{
46 if (machine_is_ebsa110()) 41
47 leds_event = ebsa110_leds_event; 42 struct led_classdev *cdev;
43 int ret;
44
45 if (!machine_is_ebsa110())
46 return -ENODEV;
47
48 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
49 if (!cdev)
50 return -ENOMEM;
51
52 cdev->name = "ebsa110:0";
53 cdev->brightness_set = ebsa110_led_set;
54 cdev->brightness_get = ebsa110_led_get;
55 cdev->default_trigger = "heartbeat";
56
57 ret = led_classdev_register(NULL, cdev);
58 if (ret < 0) {
59 kfree(cdev);
60 return ret;
61 }
48 62
49 return 0; 63 return 0;
50} 64}
51 65
52__initcall(leds_init); 66/*
67 * Since we may have triggers on any subsystem, defer registration
68 * until after subsystem_init.
69 */
70fs_initcall(ebsa110_leds_init);
71#endif
diff --git a/arch/arm/mach-footbridge/Makefile b/arch/arm/mach-footbridge/Makefile
index 3afb1b25946f..0b64dd430d61 100644
--- a/arch/arm/mach-footbridge/Makefile
+++ b/arch/arm/mach-footbridge/Makefile
@@ -14,15 +14,11 @@ pci-$(CONFIG_ARCH_EBSA285_HOST) += ebsa285-pci.o
14pci-$(CONFIG_ARCH_NETWINDER) += netwinder-pci.o 14pci-$(CONFIG_ARCH_NETWINDER) += netwinder-pci.o
15pci-$(CONFIG_ARCH_PERSONAL_SERVER) += personal-pci.o 15pci-$(CONFIG_ARCH_PERSONAL_SERVER) += personal-pci.o
16 16
17leds-$(CONFIG_ARCH_EBSA285) += ebsa285-leds.o
18leds-$(CONFIG_ARCH_NETWINDER) += netwinder-leds.o
19
20obj-$(CONFIG_ARCH_CATS) += cats-hw.o isa-timer.o 17obj-$(CONFIG_ARCH_CATS) += cats-hw.o isa-timer.o
21obj-$(CONFIG_ARCH_EBSA285) += ebsa285.o dc21285-timer.o 18obj-$(CONFIG_ARCH_EBSA285) += ebsa285.o dc21285-timer.o
22obj-$(CONFIG_ARCH_NETWINDER) += netwinder-hw.o isa-timer.o 19obj-$(CONFIG_ARCH_NETWINDER) += netwinder-hw.o isa-timer.o
23obj-$(CONFIG_ARCH_PERSONAL_SERVER) += personal.o dc21285-timer.o 20obj-$(CONFIG_ARCH_PERSONAL_SERVER) += personal.o dc21285-timer.o
24 21
25obj-$(CONFIG_PCI) +=$(pci-y) 22obj-$(CONFIG_PCI) +=$(pci-y)
26obj-$(CONFIG_LEDS) +=$(leds-y)
27 23
28obj-$(CONFIG_ISA) += isa.o isa-rtc.o 24obj-$(CONFIG_ISA) += isa.o isa-rtc.o
diff --git a/arch/arm/mach-footbridge/ebsa285-leds.c b/arch/arm/mach-footbridge/ebsa285-leds.c
deleted file mode 100644
index 5bd266754b95..000000000000
--- a/arch/arm/mach-footbridge/ebsa285-leds.c
+++ /dev/null
@@ -1,138 +0,0 @@
1/*
2 * linux/arch/arm/mach-footbridge/ebsa285-leds.c
3 *
4 * Copyright (C) 1998-1999 Russell King
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 * EBSA-285 control routines.
10 *
11 * The EBSA-285 uses the leds as follows:
12 * - Green - toggles state every 50 timer interrupts
13 * - Amber - On if system is not idle
14 * - Red - currently unused
15 *
16 * Changelog:
17 * 02-05-1999 RMK Various cleanups
18 */
19#include <linux/module.h>
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/spinlock.h>
23
24#include <mach/hardware.h>
25#include <asm/leds.h>
26#include <asm/mach-types.h>
27
28#define LED_STATE_ENABLED 1
29#define LED_STATE_CLAIMED 2
30static char led_state;
31static char hw_led_state;
32
33static DEFINE_SPINLOCK(leds_lock);
34
35static void ebsa285_leds_event(led_event_t evt)
36{
37 unsigned long flags;
38
39 spin_lock_irqsave(&leds_lock, flags);
40
41 switch (evt) {
42 case led_start:
43 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN;
44#ifndef CONFIG_LEDS_CPU
45 hw_led_state |= XBUS_LED_AMBER;
46#endif
47 led_state |= LED_STATE_ENABLED;
48 break;
49
50 case led_stop:
51 led_state &= ~LED_STATE_ENABLED;
52 break;
53
54 case led_claim:
55 led_state |= LED_STATE_CLAIMED;
56 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
57 break;
58
59 case led_release:
60 led_state &= ~LED_STATE_CLAIMED;
61 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
62 break;
63
64#ifdef CONFIG_LEDS_TIMER
65 case led_timer:
66 if (!(led_state & LED_STATE_CLAIMED))
67 hw_led_state ^= XBUS_LED_GREEN;
68 break;
69#endif
70
71#ifdef CONFIG_LEDS_CPU
72 case led_idle_start:
73 if (!(led_state & LED_STATE_CLAIMED))
74 hw_led_state |= XBUS_LED_AMBER;
75 break;
76
77 case led_idle_end:
78 if (!(led_state & LED_STATE_CLAIMED))
79 hw_led_state &= ~XBUS_LED_AMBER;
80 break;
81#endif
82
83 case led_halted:
84 if (!(led_state & LED_STATE_CLAIMED))
85 hw_led_state &= ~XBUS_LED_RED;
86 break;
87
88 case led_green_on:
89 if (led_state & LED_STATE_CLAIMED)
90 hw_led_state &= ~XBUS_LED_GREEN;
91 break;
92
93 case led_green_off:
94 if (led_state & LED_STATE_CLAIMED)
95 hw_led_state |= XBUS_LED_GREEN;
96 break;
97
98 case led_amber_on:
99 if (led_state & LED_STATE_CLAIMED)
100 hw_led_state &= ~XBUS_LED_AMBER;
101 break;
102
103 case led_amber_off:
104 if (led_state & LED_STATE_CLAIMED)
105 hw_led_state |= XBUS_LED_AMBER;
106 break;
107
108 case led_red_on:
109 if (led_state & LED_STATE_CLAIMED)
110 hw_led_state &= ~XBUS_LED_RED;
111 break;
112
113 case led_red_off:
114 if (led_state & LED_STATE_CLAIMED)
115 hw_led_state |= XBUS_LED_RED;
116 break;
117
118 default:
119 break;
120 }
121
122 if (led_state & LED_STATE_ENABLED)
123 *XBUS_LEDS = hw_led_state;
124
125 spin_unlock_irqrestore(&leds_lock, flags);
126}
127
128static int __init leds_init(void)
129{
130 if (machine_is_ebsa285())
131 leds_event = ebsa285_leds_event;
132
133 leds_event(led_start);
134
135 return 0;
136}
137
138__initcall(leds_init);
diff --git a/arch/arm/mach-footbridge/ebsa285.c b/arch/arm/mach-footbridge/ebsa285.c
index 27716a7e5fc1..b09551ef89ca 100644
--- a/arch/arm/mach-footbridge/ebsa285.c
+++ b/arch/arm/mach-footbridge/ebsa285.c
@@ -5,6 +5,8 @@
5 */ 5 */
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/spinlock.h> 7#include <linux/spinlock.h>
8#include <linux/slab.h>
9#include <linux/leds.h>
8 10
9#include <asm/hardware/dec21285.h> 11#include <asm/hardware/dec21285.h>
10#include <asm/mach-types.h> 12#include <asm/mach-types.h>
@@ -13,6 +15,85 @@
13 15
14#include "common.h" 16#include "common.h"
15 17
18/* LEDs */
19#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
20struct ebsa285_led {
21 struct led_classdev cdev;
22 u8 mask;
23};
24
25/*
26 * The triggers lines up below will only be used if the
27 * LED triggers are compiled in.
28 */
29static const struct {
30 const char *name;
31 const char *trigger;
32} ebsa285_leds[] = {
33 { "ebsa285:amber", "heartbeat", },
34 { "ebsa285:green", "cpu0", },
35 { "ebsa285:red",},
36};
37
38static void ebsa285_led_set(struct led_classdev *cdev,
39 enum led_brightness b)
40{
41 struct ebsa285_led *led = container_of(cdev,
42 struct ebsa285_led, cdev);
43
44 if (b != LED_OFF)
45 *XBUS_LEDS |= led->mask;
46 else
47 *XBUS_LEDS &= ~led->mask;
48}
49
50static enum led_brightness ebsa285_led_get(struct led_classdev *cdev)
51{
52 struct ebsa285_led *led = container_of(cdev,
53 struct ebsa285_led, cdev);
54
55 return (*XBUS_LEDS & led->mask) ? LED_FULL : LED_OFF;
56}
57
58static int __init ebsa285_leds_init(void)
59{
60 int i;
61
62 if (machine_is_ebsa285())
63 return -ENODEV;
64
65 /* 3 LEDS All ON */
66 *XBUS_LEDS |= XBUS_LED_AMBER | XBUS_LED_GREEN | XBUS_LED_RED;
67
68 for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
69 struct ebsa285_led *led;
70
71 led = kzalloc(sizeof(*led), GFP_KERNEL);
72 if (!led)
73 break;
74
75 led->cdev.name = ebsa285_leds[i].name;
76 led->cdev.brightness_set = ebsa285_led_set;
77 led->cdev.brightness_get = ebsa285_led_get;
78 led->cdev.default_trigger = ebsa285_leds[i].trigger;
79 led->mask = BIT(i);
80
81 if (led_classdev_register(NULL, &led->cdev) < 0) {
82 kfree(led);
83 break;
84 }
85 }
86
87 return 0;
88}
89
90/*
91 * Since we may have triggers on any subsystem, defer registration
92 * until after subsystem_init.
93 */
94fs_initcall(ebsa285_leds_init);
95#endif
96
16MACHINE_START(EBSA285, "EBSA285") 97MACHINE_START(EBSA285, "EBSA285")
17 /* Maintainer: Russell King */ 98 /* Maintainer: Russell King */
18 .atag_offset = 0x100, 99 .atag_offset = 0x100,
diff --git a/arch/arm/mach-footbridge/netwinder-hw.c b/arch/arm/mach-footbridge/netwinder-hw.c
index cac9f67e7da7..d2d14339c6c4 100644
--- a/arch/arm/mach-footbridge/netwinder-hw.c
+++ b/arch/arm/mach-footbridge/netwinder-hw.c
@@ -12,9 +12,10 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/slab.h>
16#include <linux/leds.h>
15 17
16#include <asm/hardware/dec21285.h> 18#include <asm/hardware/dec21285.h>
17#include <asm/leds.h>
18#include <asm/mach-types.h> 19#include <asm/mach-types.h>
19#include <asm/setup.h> 20#include <asm/setup.h>
20#include <asm/system_misc.h> 21#include <asm/system_misc.h>
@@ -27,13 +28,6 @@
27#define GP1_IO_BASE 0x338 28#define GP1_IO_BASE 0x338
28#define GP2_IO_BASE 0x33a 29#define GP2_IO_BASE 0x33a
29 30
30
31#ifdef CONFIG_LEDS
32#define DEFAULT_LEDS 0
33#else
34#define DEFAULT_LEDS GPIO_GREEN_LED
35#endif
36
37/* 31/*
38 * Winbond WB83977F accessibility stuff 32 * Winbond WB83977F accessibility stuff
39 */ 33 */
@@ -611,15 +605,9 @@ static void __init rwa010_init(void)
611static int __init nw_hw_init(void) 605static int __init nw_hw_init(void)
612{ 606{
613 if (machine_is_netwinder()) { 607 if (machine_is_netwinder()) {
614 unsigned long flags;
615
616 wb977_init(); 608 wb977_init();
617 cpld_init(); 609 cpld_init();
618 rwa010_init(); 610 rwa010_init();
619
620 raw_spin_lock_irqsave(&nw_gpio_lock, flags);
621 nw_gpio_modify_op(GPIO_RED_LED|GPIO_GREEN_LED, DEFAULT_LEDS);
622 raw_spin_unlock_irqrestore(&nw_gpio_lock, flags);
623 } 611 }
624 return 0; 612 return 0;
625} 613}
@@ -672,6 +660,102 @@ static void netwinder_restart(char mode, const char *cmd)
672 } 660 }
673} 661}
674 662
663/* LEDs */
664#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
665struct netwinder_led {
666 struct led_classdev cdev;
667 u8 mask;
668};
669
670/*
671 * The triggers lines up below will only be used if the
672 * LED triggers are compiled in.
673 */
674static const struct {
675 const char *name;
676 const char *trigger;
677} netwinder_leds[] = {
678 { "netwinder:green", "heartbeat", },
679 { "netwinder:red", "cpu0", },
680};
681
682/*
683 * The LED control in Netwinder is reversed:
684 * - setting bit means turn off LED
685 * - clearing bit means turn on LED
686 */
687static void netwinder_led_set(struct led_classdev *cdev,
688 enum led_brightness b)
689{
690 struct netwinder_led *led = container_of(cdev,
691 struct netwinder_led, cdev);
692 unsigned long flags;
693 u32 reg;
694
695 spin_lock_irqsave(&nw_gpio_lock, flags);
696 reg = nw_gpio_read();
697 if (b != LED_OFF)
698 reg &= ~led->mask;
699 else
700 reg |= led->mask;
701 nw_gpio_modify_op(led->mask, reg);
702 spin_unlock_irqrestore(&nw_gpio_lock, flags);
703}
704
705static enum led_brightness netwinder_led_get(struct led_classdev *cdev)
706{
707 struct netwinder_led *led = container_of(cdev,
708 struct netwinder_led, cdev);
709 unsigned long flags;
710 u32 reg;
711
712 spin_lock_irqsave(&nw_gpio_lock, flags);
713 reg = nw_gpio_read();
714 spin_unlock_irqrestore(&nw_gpio_lock, flags);
715
716 return (reg & led->mask) ? LED_OFF : LED_FULL;
717}
718
719static int __init netwinder_leds_init(void)
720{
721 int i;
722
723 if (!machine_is_netwinder())
724 return -ENODEV;
725
726 for (i = 0; i < ARRAY_SIZE(netwinder_leds); i++) {
727 struct netwinder_led *led;
728
729 led = kzalloc(sizeof(*led), GFP_KERNEL);
730 if (!led)
731 break;
732
733 led->cdev.name = netwinder_leds[i].name;
734 led->cdev.brightness_set = netwinder_led_set;
735 led->cdev.brightness_get = netwinder_led_get;
736 led->cdev.default_trigger = netwinder_leds[i].trigger;
737
738 if (i == 0)
739 led->mask = GPIO_GREEN_LED;
740 else
741 led->mask = GPIO_RED_LED;
742
743 if (led_classdev_register(NULL, &led->cdev) < 0) {
744 kfree(led);
745 break;
746 }
747 }
748
749 return 0;
750}
751
752/*
753 * Since we may have triggers on any subsystem, defer registration
754 * until after subsystem_init.
755 */
756fs_initcall(netwinder_leds_init);
757#endif
758
675MACHINE_START(NETWINDER, "Rebel-NetWinder") 759MACHINE_START(NETWINDER, "Rebel-NetWinder")
676 /* Maintainer: Russell King/Rebel.com */ 760 /* Maintainer: Russell King/Rebel.com */
677 .atag_offset = 0x100, 761 .atag_offset = 0x100,
diff --git a/arch/arm/mach-footbridge/netwinder-leds.c b/arch/arm/mach-footbridge/netwinder-leds.c
deleted file mode 100644
index 5a2bd89cbdca..000000000000
--- a/arch/arm/mach-footbridge/netwinder-leds.c
+++ /dev/null
@@ -1,138 +0,0 @@
1/*
2 * linux/arch/arm/mach-footbridge/netwinder-leds.c
3 *
4 * Copyright (C) 1998-1999 Russell King
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 * NetWinder LED control routines.
11 *
12 * The Netwinder uses the leds as follows:
13 * - Green - toggles state every 50 timer interrupts
14 * - Red - On if the system is not idle
15 *
16 * Changelog:
17 * 02-05-1999 RMK Various cleanups
18 */
19#include <linux/module.h>
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/spinlock.h>
23
24#include <mach/hardware.h>
25#include <asm/leds.h>
26#include <asm/mach-types.h>
27
28#define LED_STATE_ENABLED 1
29#define LED_STATE_CLAIMED 2
30static char led_state;
31static char hw_led_state;
32
33static DEFINE_RAW_SPINLOCK(leds_lock);
34
35static void netwinder_leds_event(led_event_t evt)
36{
37 unsigned long flags;
38
39 raw_spin_lock_irqsave(&leds_lock, flags);
40
41 switch (evt) {
42 case led_start:
43 led_state |= LED_STATE_ENABLED;
44 hw_led_state = GPIO_GREEN_LED;
45 break;
46
47 case led_stop:
48 led_state &= ~LED_STATE_ENABLED;
49 break;
50
51 case led_claim:
52 led_state |= LED_STATE_CLAIMED;
53 hw_led_state = 0;
54 break;
55
56 case led_release:
57 led_state &= ~LED_STATE_CLAIMED;
58 hw_led_state = 0;
59 break;
60
61#ifdef CONFIG_LEDS_TIMER
62 case led_timer:
63 if (!(led_state & LED_STATE_CLAIMED))
64 hw_led_state ^= GPIO_GREEN_LED;
65 break;
66#endif
67
68#ifdef CONFIG_LEDS_CPU
69 case led_idle_start:
70 if (!(led_state & LED_STATE_CLAIMED))
71 hw_led_state &= ~GPIO_RED_LED;
72 break;
73
74 case led_idle_end:
75 if (!(led_state & LED_STATE_CLAIMED))
76 hw_led_state |= GPIO_RED_LED;
77 break;
78#endif
79
80 case led_halted:
81 if (!(led_state & LED_STATE_CLAIMED))
82 hw_led_state |= GPIO_RED_LED;
83 break;
84
85 case led_green_on:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state |= GPIO_GREEN_LED;
88 break;
89
90 case led_green_off:
91 if (led_state & LED_STATE_CLAIMED)
92 hw_led_state &= ~GPIO_GREEN_LED;
93 break;
94
95 case led_amber_on:
96 if (led_state & LED_STATE_CLAIMED)
97 hw_led_state |= GPIO_GREEN_LED | GPIO_RED_LED;
98 break;
99
100 case led_amber_off:
101 if (led_state & LED_STATE_CLAIMED)
102 hw_led_state &= ~(GPIO_GREEN_LED | GPIO_RED_LED);
103 break;
104
105 case led_red_on:
106 if (led_state & LED_STATE_CLAIMED)
107 hw_led_state |= GPIO_RED_LED;
108 break;
109
110 case led_red_off:
111 if (led_state & LED_STATE_CLAIMED)
112 hw_led_state &= ~GPIO_RED_LED;
113 break;
114
115 default:
116 break;
117 }
118
119 raw_spin_unlock_irqrestore(&leds_lock, flags);
120
121 if (led_state & LED_STATE_ENABLED) {
122 raw_spin_lock_irqsave(&nw_gpio_lock, flags);
123 nw_gpio_modify_op(GPIO_RED_LED | GPIO_GREEN_LED, hw_led_state);
124 raw_spin_unlock_irqrestore(&nw_gpio_lock, flags);
125 }
126}
127
128static int __init leds_init(void)
129{
130 if (machine_is_netwinder())
131 leds_event = netwinder_leds_event;
132
133 leds_event(led_start);
134
135 return 0;
136}
137
138__initcall(leds_init);
diff --git a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile
index ebeef966e1f5..5521d18bf19a 100644
--- a/arch/arm/mach-integrator/Makefile
+++ b/arch/arm/mach-integrator/Makefile
@@ -4,11 +4,10 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := core.o lm.o 7obj-y := core.o lm.o leds.o
8obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o 8obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o
9obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o 9obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o
10 10
11obj-$(CONFIG_LEDS) += leds.o
12obj-$(CONFIG_PCI) += pci_v3.o pci.o 11obj-$(CONFIG_PCI) += pci_v3.o pci.o
13obj-$(CONFIG_CPU_FREQ_INTEGRATOR) += cpu.o 12obj-$(CONFIG_CPU_FREQ_INTEGRATOR) += cpu.o
14obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o 13obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index ebf680bebdf2..208c05d9e685 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -27,7 +27,6 @@
27#include <mach/cm.h> 27#include <mach/cm.h>
28#include <mach/irqs.h> 28#include <mach/irqs.h>
29 29
30#include <asm/leds.h>
31#include <asm/mach-types.h> 30#include <asm/mach-types.h>
32#include <asm/mach/time.h> 31#include <asm/mach/time.h>
33#include <asm/pgtable.h> 32#include <asm/pgtable.h>
@@ -127,8 +126,6 @@ static struct amba_pl010_data integrator_uart_data = {
127 .set_mctrl = integrator_uart_set_mctrl, 126 .set_mctrl = integrator_uart_set_mctrl,
128}; 127};
129 128
130#define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
131
132static DEFINE_RAW_SPINLOCK(cm_lock); 129static DEFINE_RAW_SPINLOCK(cm_lock);
133 130
134/** 131/**
diff --git a/arch/arm/mach-integrator/include/mach/cm.h b/arch/arm/mach-integrator/include/mach/cm.h
index 445d57adb043..1a78692e32a4 100644
--- a/arch/arm/mach-integrator/include/mach/cm.h
+++ b/arch/arm/mach-integrator/include/mach/cm.h
@@ -3,6 +3,8 @@
3 */ 3 */
4void cm_control(u32, u32); 4void cm_control(u32, u32);
5 5
6#define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
7
6#define CM_CTRL_LED (1 << 0) 8#define CM_CTRL_LED (1 << 0)
7#define CM_CTRL_nMBDET (1 << 1) 9#define CM_CTRL_nMBDET (1 << 1)
8#define CM_CTRL_REMAP (1 << 2) 10#define CM_CTRL_REMAP (1 << 2)
diff --git a/arch/arm/mach-integrator/leds.c b/arch/arm/mach-integrator/leds.c
index 466defa97842..7a7f6d3273bf 100644
--- a/arch/arm/mach-integrator/leds.c
+++ b/arch/arm/mach-integrator/leds.c
@@ -1,90 +1,125 @@
1/* 1/*
2 * linux/arch/arm/mach-integrator/leds.c 2 * Driver for the 4 user LEDs found on the Integrator AP/CP baseboard
3 * Based on Versatile and RealView machine LED code
3 * 4 *
4 * Integrator/AP and Integrator/CP LED control routines 5 * License terms: GNU General Public License (GPL) version 2
5 * 6 * Author: Bryan Wu <bryan.wu@canonical.com>
6 * Copyright (C) 1999 ARM Limited
7 * Copyright (C) 2000 Deep Blue Solutions Ltd
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 7 */
23#include <linux/kernel.h> 8#include <linux/kernel.h>
24#include <linux/init.h> 9#include <linux/init.h>
25#include <linux/smp.h>
26#include <linux/spinlock.h>
27#include <linux/io.h> 10#include <linux/io.h>
11#include <linux/slab.h>
12#include <linux/leds.h>
28 13
14#include <mach/cm.h>
29#include <mach/hardware.h> 15#include <mach/hardware.h>
30#include <mach/platform.h> 16#include <mach/platform.h>
31#include <asm/leds.h>
32#include <asm/mach-types.h>
33#include <mach/cm.h>
34 17
35static int saved_leds; 18#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
19
20#define ALPHA_REG __io_address(INTEGRATOR_DBG_BASE)
21#define LEDREG (__io_address(INTEGRATOR_DBG_BASE) + INTEGRATOR_DBG_LEDS_OFFSET)
36 22
37static void integrator_leds_event(led_event_t ledevt) 23struct integrator_led {
24 struct led_classdev cdev;
25 u8 mask;
26};
27
28/*
29 * The triggers lines up below will only be used if the
30 * LED triggers are compiled in.
31 */
32static const struct {
33 const char *name;
34 const char *trigger;
35} integrator_leds[] = {
36 { "integrator:green0", "heartbeat", },
37 { "integrator:yellow", },
38 { "integrator:red", },
39 { "integrator:green1", },
40 { "integrator:core_module", "cpu0", },
41};
42
43static void integrator_led_set(struct led_classdev *cdev,
44 enum led_brightness b)
38{ 45{
39 unsigned long flags; 46 struct integrator_led *led = container_of(cdev,
40 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE); 47 struct integrator_led, cdev);
41 unsigned int update_alpha_leds; 48 u32 reg = __raw_readl(LEDREG);
42 49
43 // yup, change the LEDs 50 if (b != LED_OFF)
44 local_irq_save(flags); 51 reg |= led->mask;
45 update_alpha_leds = 0; 52 else
53 reg &= ~led->mask;
46 54
47 switch(ledevt) { 55 while (__raw_readl(ALPHA_REG) & 1)
48 case led_idle_start: 56 cpu_relax();
49 cm_control(CM_CTRL_LED, 0);
50 break;
51 57
52 case led_idle_end: 58 __raw_writel(reg, LEDREG);
53 cm_control(CM_CTRL_LED, CM_CTRL_LED); 59}
54 break;
55 60
56 case led_timer: 61static enum led_brightness integrator_led_get(struct led_classdev *cdev)
57 saved_leds ^= GREEN_LED; 62{
58 update_alpha_leds = 1; 63 struct integrator_led *led = container_of(cdev,
59 break; 64 struct integrator_led, cdev);
65 u32 reg = __raw_readl(LEDREG);
60 66
61 case led_red_on: 67 return (reg & led->mask) ? LED_FULL : LED_OFF;
62 saved_leds |= RED_LED; 68}
63 update_alpha_leds = 1;
64 break;
65 69
66 case led_red_off: 70static void cm_led_set(struct led_classdev *cdev,
67 saved_leds &= ~RED_LED; 71 enum led_brightness b)
68 update_alpha_leds = 1; 72{
69 break; 73 if (b != LED_OFF)
74 cm_control(CM_CTRL_LED, CM_CTRL_LED);
75 else
76 cm_control(CM_CTRL_LED, 0);
77}
70 78
71 default: 79static enum led_brightness cm_led_get(struct led_classdev *cdev)
72 break; 80{
73 } 81 u32 reg = readl(CM_CTRL);
74 82
75 if (update_alpha_leds) { 83 return (reg & CM_CTRL_LED) ? LED_FULL : LED_OFF;
76 while (__raw_readl(dbg_base + INTEGRATOR_DBG_ALPHA_OFFSET) & 1);
77 __raw_writel(saved_leds, dbg_base + INTEGRATOR_DBG_LEDS_OFFSET);
78 }
79 local_irq_restore(flags);
80} 84}
81 85
82static int __init leds_init(void) 86static int __init integrator_leds_init(void)
83{ 87{
84 if (machine_is_integrator() || machine_is_cintegrator()) 88 int i;
85 leds_event = integrator_leds_event; 89
90 for (i = 0; i < ARRAY_SIZE(integrator_leds); i++) {
91 struct integrator_led *led;
92
93 led = kzalloc(sizeof(*led), GFP_KERNEL);
94 if (!led)
95 break;
96
97
98 led->cdev.name = integrator_leds[i].name;
99
100 if (i == 4) { /* Setting for LED in core module */
101 led->cdev.brightness_set = cm_led_set;
102 led->cdev.brightness_get = cm_led_get;
103 } else {
104 led->cdev.brightness_set = integrator_led_set;
105 led->cdev.brightness_get = integrator_led_get;
106 }
107
108 led->cdev.default_trigger = integrator_leds[i].trigger;
109 led->mask = BIT(i);
110
111 if (led_classdev_register(NULL, &led->cdev) < 0) {
112 kfree(led);
113 break;
114 }
115 }
86 116
87 return 0; 117 return 0;
88} 118}
89 119
90core_initcall(leds_init); 120/*
121 * Since we may have triggers on any subsystem, defer registration
122 * until after subsystem_init.
123 */
124fs_initcall(integrator_leds_init);
125#endif
diff --git a/arch/arm/mach-ks8695/Makefile b/arch/arm/mach-ks8695/Makefile
index 853efd9133c6..9324ef965c26 100644
--- a/arch/arm/mach-ks8695/Makefile
+++ b/arch/arm/mach-ks8695/Makefile
@@ -11,9 +11,6 @@ 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
17# Board-specific support 14# Board-specific support
18obj-$(CONFIG_MACH_KS8695) += board-micrel.o 15obj-$(CONFIG_MACH_KS8695) += board-micrel.o
19obj-$(CONFIG_MACH_DSM320) += board-dsm320.o 16obj-$(CONFIG_MACH_DSM320) += board-dsm320.o
diff --git a/arch/arm/mach-ks8695/devices.c b/arch/arm/mach-ks8695/devices.c
index 73bd63812878..47399bc3c024 100644
--- a/arch/arm/mach-ks8695/devices.c
+++ b/arch/arm/mach-ks8695/devices.c
@@ -182,27 +182,6 @@ static void __init ks8695_add_device_watchdog(void)
182} 182}
183 183
184 184
185/* --------------------------------------------------------------------
186 * LEDs
187 * -------------------------------------------------------------------- */
188
189#if defined(CONFIG_LEDS)
190short ks8695_leds_cpu = -1;
191short ks8695_leds_timer = -1;
192
193void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
194{
195 /* Enable GPIO to access the LEDs */
196 gpio_direction_output(cpu_led, 1);
197 gpio_direction_output(timer_led, 1);
198
199 ks8695_leds_cpu = cpu_led;
200 ks8695_leds_timer = timer_led;
201}
202#else
203void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
204#endif
205
206/* -------------------------------------------------------------------- */ 185/* -------------------------------------------------------------------- */
207 186
208/* 187/*
diff --git a/arch/arm/mach-ks8695/include/mach/devices.h b/arch/arm/mach-ks8695/include/mach/devices.h
index 85a3c9aa7d13..1e6594a0f297 100644
--- a/arch/arm/mach-ks8695/include/mach/devices.h
+++ b/arch/arm/mach-ks8695/include/mach/devices.h
@@ -18,11 +18,6 @@ extern void __init ks8695_add_device_wan(void);
18extern void __init ks8695_add_device_lan(void); 18extern void __init ks8695_add_device_lan(void);
19extern void __init ks8695_add_device_hpna(void); 19extern void __init ks8695_add_device_hpna(void);
20 20
21 /* LEDs */
22extern short ks8695_leds_cpu;
23extern short ks8695_leds_timer;
24extern void __init ks8695_init_leds(u8 cpu_led, u8 timer_led);
25
26 /* PCI */ 21 /* PCI */
27#define KS8695_MODE_PCI 0 22#define KS8695_MODE_PCI 0
28#define KS8695_MODE_MINIPCI 1 23#define KS8695_MODE_MINIPCI 1
diff --git a/arch/arm/mach-ks8695/leds.c b/arch/arm/mach-ks8695/leds.c
deleted file mode 100644
index 4bd707547293..000000000000
--- a/arch/arm/mach-ks8695/leds.c
+++ /dev/null
@@ -1,92 +0,0 @@
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#include <linux/gpio.h>
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/init.h>
14
15#include <asm/leds.h>
16#include <mach/devices.h>
17
18
19static inline void ks8695_led_on(unsigned int led)
20{
21 gpio_set_value(led, 0);
22}
23
24static inline void ks8695_led_off(unsigned int led)
25{
26 gpio_set_value(led, 1);
27}
28
29static inline void ks8695_led_toggle(unsigned int led)
30{
31 unsigned long is_off = gpio_get_value(led);
32 if (is_off)
33 ks8695_led_on(led);
34 else
35 ks8695_led_off(led);
36}
37
38
39/*
40 * Handle LED events.
41 */
42static void ks8695_leds_event(led_event_t evt)
43{
44 unsigned long flags;
45
46 local_irq_save(flags);
47
48 switch(evt) {
49 case led_start: /* System startup */
50 ks8695_led_on(ks8695_leds_cpu);
51 break;
52
53 case led_stop: /* System stop / suspend */
54 ks8695_led_off(ks8695_leds_cpu);
55 break;
56
57#ifdef CONFIG_LEDS_TIMER
58 case led_timer: /* Every 50 timer ticks */
59 ks8695_led_toggle(ks8695_leds_timer);
60 break;
61#endif
62
63#ifdef CONFIG_LEDS_CPU
64 case led_idle_start: /* Entering idle state */
65 ks8695_led_off(ks8695_leds_cpu);
66 break;
67
68 case led_idle_end: /* Exit idle state */
69 ks8695_led_on(ks8695_leds_cpu);
70 break;
71#endif
72
73 default:
74 break;
75 }
76
77 local_irq_restore(flags);
78}
79
80
81static int __init leds_init(void)
82{
83 if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
84 return -ENODEV;
85
86 leds_event = ks8695_leds_event;
87
88 leds_event(led_start);
89 return 0;
90}
91
92__initcall(leds_init);
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 398e9e53e189..cd169c386161 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -61,14 +61,6 @@ obj-$(CONFIG_ARCH_OMAP850) += gpio7xx.o
61obj-$(CONFIG_ARCH_OMAP15XX) += gpio15xx.o 61obj-$(CONFIG_ARCH_OMAP15XX) += gpio15xx.o
62obj-$(CONFIG_ARCH_OMAP16XX) += gpio16xx.o 62obj-$(CONFIG_ARCH_OMAP16XX) += gpio16xx.o
63 63
64# LEDs support
65led-$(CONFIG_MACH_OMAP_H2) += leds-h2p2-debug.o
66led-$(CONFIG_MACH_OMAP_H3) += leds-h2p2-debug.o
67led-$(CONFIG_MACH_OMAP_INNOVATOR) += leds-innovator.o
68led-$(CONFIG_MACH_OMAP_PERSEUS2) += leds-h2p2-debug.o
69led-$(CONFIG_MACH_OMAP_OSK) += leds-osk.o
70obj-$(CONFIG_LEDS) += $(led-y)
71
72ifneq ($(CONFIG_FB_OMAP),) 64ifneq ($(CONFIG_FB_OMAP),)
73obj-y += lcd_dma.o 65obj-y += lcd_dma.o
74endif 66endif
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 44a4ab195fbc..cd8836f43f01 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -31,6 +31,7 @@
31#include <linux/i2c/tps65010.h> 31#include <linux/i2c/tps65010.h>
32#include <linux/smc91x.h> 32#include <linux/smc91x.h>
33#include <linux/omapfb.h> 33#include <linux/omapfb.h>
34#include <linux/leds.h>
34 35
35#include <asm/mach-types.h> 36#include <asm/mach-types.h>
36#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
@@ -306,12 +307,39 @@ static struct platform_device h2_irda_device = {
306 .resource = h2_irda_resources, 307 .resource = h2_irda_resources,
307}; 308};
308 309
310static struct gpio_led h2_gpio_led_pins[] = {
311 {
312 .name = "h2:red",
313 .default_trigger = "heartbeat",
314 .gpio = 3,
315 },
316 {
317 .name = "h2:green",
318 .default_trigger = "cpu0",
319 .gpio = OMAP_MPUIO(4),
320 },
321};
322
323static struct gpio_led_platform_data h2_gpio_led_data = {
324 .leds = h2_gpio_led_pins,
325 .num_leds = ARRAY_SIZE(h2_gpio_led_pins),
326};
327
328static struct platform_device h2_gpio_leds = {
329 .name = "leds-gpio",
330 .id = -1,
331 .dev = {
332 .platform_data = &h2_gpio_led_data,
333 },
334};
335
309static struct platform_device *h2_devices[] __initdata = { 336static struct platform_device *h2_devices[] __initdata = {
310 &h2_nor_device, 337 &h2_nor_device,
311 &h2_nand_device, 338 &h2_nand_device,
312 &h2_smc91x_device, 339 &h2_smc91x_device,
313 &h2_irda_device, 340 &h2_irda_device,
314 &h2_kp_device, 341 &h2_kp_device,
342 &h2_gpio_leds,
315}; 343};
316 344
317static void __init h2_init_smc91x(void) 345static void __init h2_init_smc91x(void)
@@ -406,6 +434,10 @@ static void __init h2_init(void)
406 omap_cfg_reg(E19_1610_KBR4); 434 omap_cfg_reg(E19_1610_KBR4);
407 omap_cfg_reg(N19_1610_KBR5); 435 omap_cfg_reg(N19_1610_KBR5);
408 436
437 /* GPIO based LEDs */
438 omap_cfg_reg(P18_1610_GPIO3);
439 omap_cfg_reg(MPUIO4);
440
409 h2_smc91x_resources[1].start = gpio_to_irq(0); 441 h2_smc91x_resources[1].start = gpio_to_irq(0);
410 h2_smc91x_resources[1].end = gpio_to_irq(0); 442 h2_smc91x_resources[1].end = gpio_to_irq(0);
411 platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices)); 443 platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 86cb5a04a404..1fa9c45c1ae5 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -31,6 +31,7 @@
31#include <linux/i2c/tps65010.h> 31#include <linux/i2c/tps65010.h>
32#include <linux/smc91x.h> 32#include <linux/smc91x.h>
33#include <linux/omapfb.h> 33#include <linux/omapfb.h>
34#include <linux/leds.h>
34 35
35#include <asm/setup.h> 36#include <asm/setup.h>
36#include <asm/page.h> 37#include <asm/page.h>
@@ -324,6 +325,32 @@ static struct spi_board_info h3_spi_board_info[] __initdata = {
324 }, 325 },
325}; 326};
326 327
328static struct gpio_led h3_gpio_led_pins[] = {
329 {
330 .name = "h3:red",
331 .default_trigger = "heartbeat",
332 .gpio = 3,
333 },
334 {
335 .name = "h3:green",
336 .default_trigger = "cpu0",
337 .gpio = OMAP_MPUIO(4),
338 },
339};
340
341static struct gpio_led_platform_data h3_gpio_led_data = {
342 .leds = h3_gpio_led_pins,
343 .num_leds = ARRAY_SIZE(h3_gpio_led_pins),
344};
345
346static struct platform_device h3_gpio_leds = {
347 .name = "leds-gpio",
348 .id = -1,
349 .dev = {
350 .platform_data = &h3_gpio_led_data,
351 },
352};
353
327static struct platform_device *devices[] __initdata = { 354static struct platform_device *devices[] __initdata = {
328 &nor_device, 355 &nor_device,
329 &nand_device, 356 &nand_device,
@@ -331,6 +358,7 @@ static struct platform_device *devices[] __initdata = {
331 &intlat_device, 358 &intlat_device,
332 &h3_kp_device, 359 &h3_kp_device,
333 &h3_lcd_device, 360 &h3_lcd_device,
361 &h3_gpio_leds,
334}; 362};
335 363
336static struct omap_usb_config h3_usb_config __initdata = { 364static struct omap_usb_config h3_usb_config __initdata = {
@@ -398,6 +426,10 @@ static void __init h3_init(void)
398 omap_cfg_reg(E19_1610_KBR4); 426 omap_cfg_reg(E19_1610_KBR4);
399 omap_cfg_reg(N19_1610_KBR5); 427 omap_cfg_reg(N19_1610_KBR5);
400 428
429 /* GPIO based LEDs */
430 omap_cfg_reg(P18_1610_GPIO3);
431 omap_cfg_reg(MPUIO4);
432
401 smc91x_resources[1].start = gpio_to_irq(40); 433 smc91x_resources[1].start = gpio_to_irq(40);
402 smc91x_resources[1].end = gpio_to_irq(40); 434 smc91x_resources[1].end = gpio_to_irq(40);
403 platform_add_devices(devices, ARRAY_SIZE(devices)); 435 platform_add_devices(devices, ARRAY_SIZE(devices));
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 8784705edb60..7ee1c1eac356 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -380,10 +380,37 @@ static struct platform_device osk5912_lcd_device = {
380 .id = -1, 380 .id = -1,
381}; 381};
382 382
383static struct gpio_led mistral_gpio_led_pins[] = {
384 {
385 .name = "mistral:red",
386 .default_trigger = "heartbeat",
387 .gpio = 3,
388 },
389 {
390 .name = "mistral:green",
391 .default_trigger = "cpu0",
392 .gpio = OMAP_MPUIO(4),
393 },
394};
395
396static struct gpio_led_platform_data mistral_gpio_led_data = {
397 .leds = mistral_gpio_led_pins,
398 .num_leds = ARRAY_SIZE(mistral_gpio_led_pins),
399};
400
401static struct platform_device mistral_gpio_leds = {
402 .name = "leds-gpio",
403 .id = -1,
404 .dev = {
405 .platform_data = &mistral_gpio_led_data,
406 },
407};
408
383static struct platform_device *mistral_devices[] __initdata = { 409static struct platform_device *mistral_devices[] __initdata = {
384 &osk5912_kp_device, 410 &osk5912_kp_device,
385 &mistral_bl_device, 411 &mistral_bl_device,
386 &osk5912_lcd_device, 412 &osk5912_lcd_device,
413 &mistral_gpio_leds,
387}; 414};
388 415
389static int mistral_get_pendown_state(void) 416static int mistral_get_pendown_state(void)
@@ -508,6 +535,12 @@ static void __init osk_mistral_init(void)
508 if (gpio_request(2, "lcd_pwr") == 0) 535 if (gpio_request(2, "lcd_pwr") == 0)
509 gpio_direction_output(2, 1); 536 gpio_direction_output(2, 1);
510 537
538 /*
539 * GPIO based LEDs
540 */
541 omap_cfg_reg(P18_1610_GPIO3);
542 omap_cfg_reg(MPUIO4);
543
511 i2c_register_board_info(1, mistral_i2c_board_info, 544 i2c_register_board_info(1, mistral_i2c_board_info,
512 ARRAY_SIZE(mistral_i2c_board_info)); 545 ARRAY_SIZE(mistral_i2c_board_info));
513 546
diff --git a/arch/arm/mach-omap1/leds-h2p2-debug.c b/arch/arm/mach-omap1/leds-h2p2-debug.c
deleted file mode 100644
index f6b14a14a957..000000000000
--- a/arch/arm/mach-omap1/leds-h2p2-debug.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * linux/arch/arm/mach-omap1/leds-h2p2-debug.c
3 *
4 * Copyright 2003 by Texas Instruments Incorporated
5 *
6 * There are 16 LEDs on the debug board (all green); four may be used
7 * for logical 'green', 'amber', 'red', and 'blue' (after "claiming").
8 *
9 * The "surfer" expansion board and H2 sample board also have two-color
10 * green+red LEDs (in parallel), used here for timer and idle indicators.
11 */
12#include <linux/gpio.h>
13#include <linux/init.h>
14#include <linux/kernel_stat.h>
15#include <linux/sched.h>
16#include <linux/io.h>
17
18#include <mach/hardware.h>
19#include <asm/leds.h>
20#include <asm/mach-types.h>
21
22#include <plat/fpga.h>
23
24#include "leds.h"
25
26
27#define GPIO_LED_RED 3
28#define GPIO_LED_GREEN OMAP_MPUIO(4)
29
30
31#define LED_STATE_ENABLED 0x01
32#define LED_STATE_CLAIMED 0x02
33#define LED_TIMER_ON 0x04
34
35#define GPIO_IDLE GPIO_LED_GREEN
36#define GPIO_TIMER GPIO_LED_RED
37
38
39void h2p2_dbg_leds_event(led_event_t evt)
40{
41 unsigned long flags;
42
43 static struct h2p2_dbg_fpga __iomem *fpga;
44 static u16 led_state, hw_led_state;
45
46 local_irq_save(flags);
47
48 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
49 goto done;
50
51 switch (evt) {
52 case led_start:
53 if (!fpga)
54 fpga = ioremap(H2P2_DBG_FPGA_START,
55 H2P2_DBG_FPGA_SIZE);
56 if (fpga) {
57 led_state |= LED_STATE_ENABLED;
58 __raw_writew(~0, &fpga->leds);
59 }
60 break;
61
62 case led_stop:
63 case led_halted:
64 /* all leds off during suspend or shutdown */
65
66 if (! machine_is_omap_perseus2()) {
67 gpio_set_value(GPIO_TIMER, 0);
68 gpio_set_value(GPIO_IDLE, 0);
69 }
70
71 __raw_writew(~0, &fpga->leds);
72 led_state &= ~LED_STATE_ENABLED;
73 if (evt == led_halted) {
74 iounmap(fpga);
75 fpga = NULL;
76 }
77
78 goto done;
79
80 case led_claim:
81 led_state |= LED_STATE_CLAIMED;
82 hw_led_state = 0;
83 break;
84
85 case led_release:
86 led_state &= ~LED_STATE_CLAIMED;
87 break;
88
89#ifdef CONFIG_LEDS_TIMER
90 case led_timer:
91 led_state ^= LED_TIMER_ON;
92
93 if (machine_is_omap_perseus2())
94 hw_led_state ^= H2P2_DBG_FPGA_P2_LED_TIMER;
95 else {
96 gpio_set_value(GPIO_TIMER, led_state & LED_TIMER_ON);
97 goto done;
98 }
99
100 break;
101#endif
102
103#ifdef CONFIG_LEDS_CPU
104 case led_idle_start:
105 if (machine_is_omap_perseus2())
106 hw_led_state |= H2P2_DBG_FPGA_P2_LED_IDLE;
107 else {
108 gpio_set_value(GPIO_IDLE, 1);
109 goto done;
110 }
111
112 break;
113
114 case led_idle_end:
115 if (machine_is_omap_perseus2())
116 hw_led_state &= ~H2P2_DBG_FPGA_P2_LED_IDLE;
117 else {
118 gpio_set_value(GPIO_IDLE, 0);
119 goto done;
120 }
121
122 break;
123#endif
124
125 case led_green_on:
126 hw_led_state |= H2P2_DBG_FPGA_LED_GREEN;
127 break;
128 case led_green_off:
129 hw_led_state &= ~H2P2_DBG_FPGA_LED_GREEN;
130 break;
131
132 case led_amber_on:
133 hw_led_state |= H2P2_DBG_FPGA_LED_AMBER;
134 break;
135 case led_amber_off:
136 hw_led_state &= ~H2P2_DBG_FPGA_LED_AMBER;
137 break;
138
139 case led_red_on:
140 hw_led_state |= H2P2_DBG_FPGA_LED_RED;
141 break;
142 case led_red_off:
143 hw_led_state &= ~H2P2_DBG_FPGA_LED_RED;
144 break;
145
146 case led_blue_on:
147 hw_led_state |= H2P2_DBG_FPGA_LED_BLUE;
148 break;
149 case led_blue_off:
150 hw_led_state &= ~H2P2_DBG_FPGA_LED_BLUE;
151 break;
152
153 default:
154 break;
155 }
156
157
158 /*
159 * Actually burn the LEDs
160 */
161 if (led_state & LED_STATE_ENABLED)
162 __raw_writew(~hw_led_state, &fpga->leds);
163
164done:
165 local_irq_restore(flags);
166}
diff --git a/arch/arm/mach-omap1/leds-innovator.c b/arch/arm/mach-omap1/leds-innovator.c
deleted file mode 100644
index 3a066ee8d02c..000000000000
--- a/arch/arm/mach-omap1/leds-innovator.c
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * linux/arch/arm/mach-omap1/leds-innovator.c
3 */
4#include <linux/init.h>
5
6#include <mach/hardware.h>
7#include <asm/leds.h>
8
9#include "leds.h"
10
11
12#define LED_STATE_ENABLED 1
13#define LED_STATE_CLAIMED 2
14
15static unsigned int led_state;
16static unsigned int hw_led_state;
17
18void innovator_leds_event(led_event_t evt)
19{
20 unsigned long flags;
21
22 local_irq_save(flags);
23
24 switch (evt) {
25 case led_start:
26 hw_led_state = 0;
27 led_state = LED_STATE_ENABLED;
28 break;
29
30 case led_stop:
31 led_state &= ~LED_STATE_ENABLED;
32 hw_led_state = 0;
33 break;
34
35 case led_claim:
36 led_state |= LED_STATE_CLAIMED;
37 hw_led_state = 0;
38 break;
39
40 case led_release:
41 led_state &= ~LED_STATE_CLAIMED;
42 hw_led_state = 0;
43 break;
44
45#ifdef CONFIG_LEDS_TIMER
46 case led_timer:
47 if (!(led_state & LED_STATE_CLAIMED))
48 hw_led_state ^= 0;
49 break;
50#endif
51
52#ifdef CONFIG_LEDS_CPU
53 case led_idle_start:
54 if (!(led_state & LED_STATE_CLAIMED))
55 hw_led_state |= 0;
56 break;
57
58 case led_idle_end:
59 if (!(led_state & LED_STATE_CLAIMED))
60 hw_led_state &= ~0;
61 break;
62#endif
63
64 case led_halted:
65 break;
66
67 case led_green_on:
68 if (led_state & LED_STATE_CLAIMED)
69 hw_led_state &= ~0;
70 break;
71
72 case led_green_off:
73 if (led_state & LED_STATE_CLAIMED)
74 hw_led_state |= 0;
75 break;
76
77 case led_amber_on:
78 break;
79
80 case led_amber_off:
81 break;
82
83 case led_red_on:
84 if (led_state & LED_STATE_CLAIMED)
85 hw_led_state &= ~0;
86 break;
87
88 case led_red_off:
89 if (led_state & LED_STATE_CLAIMED)
90 hw_led_state |= 0;
91 break;
92
93 default:
94 break;
95 }
96
97 local_irq_restore(flags);
98}
diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c
deleted file mode 100644
index 936ed426b84f..000000000000
--- a/arch/arm/mach-omap1/leds-osk.c
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 * linux/arch/arm/mach-omap1/leds-osk.c
3 *
4 * LED driver for OSK with optional Mistral QVGA board
5 */
6#include <linux/gpio.h>
7#include <linux/init.h>
8
9#include <mach/hardware.h>
10#include <asm/leds.h>
11
12#include "leds.h"
13
14
15#define LED_STATE_ENABLED (1 << 0)
16#define LED_STATE_CLAIMED (1 << 1)
17static u8 led_state;
18
19#define TIMER_LED (1 << 3) /* Mistral board */
20#define IDLE_LED (1 << 4) /* Mistral board */
21static u8 hw_led_state;
22
23
24#ifdef CONFIG_OMAP_OSK_MISTRAL
25
26/* For now, all system indicators require the Mistral board, since that
27 * LED can be manipulated without a task context. This LED is either red,
28 * or green, but not both; it can't give the full "disco led" effect.
29 */
30
31#define GPIO_LED_RED 3
32#define GPIO_LED_GREEN OMAP_MPUIO(4)
33
34static void mistral_setled(void)
35{
36 int red = 0;
37 int green = 0;
38
39 if (hw_led_state & TIMER_LED)
40 red = 1;
41 else if (hw_led_state & IDLE_LED)
42 green = 1;
43 /* else both sides are disabled */
44
45 gpio_set_value(GPIO_LED_GREEN, green);
46 gpio_set_value(GPIO_LED_RED, red);
47}
48
49#endif
50
51void osk_leds_event(led_event_t evt)
52{
53 unsigned long flags;
54 u16 leds;
55
56 local_irq_save(flags);
57
58 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
59 goto done;
60
61 leds = hw_led_state;
62 switch (evt) {
63 case led_start:
64 led_state |= LED_STATE_ENABLED;
65 hw_led_state = 0;
66 leds = ~0;
67 break;
68
69 case led_halted:
70 case led_stop:
71 led_state &= ~LED_STATE_ENABLED;
72 hw_led_state = 0;
73 break;
74
75 case led_claim:
76 led_state |= LED_STATE_CLAIMED;
77 hw_led_state = 0;
78 leds = ~0;
79 break;
80
81 case led_release:
82 led_state &= ~LED_STATE_CLAIMED;
83 hw_led_state = 0;
84 break;
85
86#ifdef CONFIG_OMAP_OSK_MISTRAL
87
88 case led_timer:
89 hw_led_state ^= TIMER_LED;
90 mistral_setled();
91 break;
92
93 case led_idle_start: /* idle == off */
94 hw_led_state &= ~IDLE_LED;
95 mistral_setled();
96 break;
97
98 case led_idle_end:
99 hw_led_state |= IDLE_LED;
100 mistral_setled();
101 break;
102
103#endif /* CONFIG_OMAP_OSK_MISTRAL */
104
105 default:
106 break;
107 }
108
109 leds ^= hw_led_state;
110
111done:
112 local_irq_restore(flags);
113}
diff --git a/arch/arm/mach-omap1/leds.c b/arch/arm/mach-omap1/leds.c
deleted file mode 100644
index ae6dd93b8ddc..000000000000
--- a/arch/arm/mach-omap1/leds.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * linux/arch/arm/mach-omap1/leds.c
3 *
4 * OMAP LEDs dispatcher
5 */
6#include <linux/gpio.h>
7#include <linux/kernel.h>
8#include <linux/init.h>
9
10#include <asm/leds.h>
11#include <asm/mach-types.h>
12
13#include <plat/mux.h>
14
15#include "leds.h"
16
17static int __init
18omap_leds_init(void)
19{
20 if (!cpu_class_is_omap1())
21 return -ENODEV;
22
23 if (machine_is_omap_innovator())
24 leds_event = innovator_leds_event;
25
26 else if (machine_is_omap_h2()
27 || machine_is_omap_h3()
28 || machine_is_omap_perseus2())
29 leds_event = h2p2_dbg_leds_event;
30
31 else if (machine_is_omap_osk())
32 leds_event = osk_leds_event;
33
34 else
35 return -1;
36
37 if (machine_is_omap_h2()
38 || machine_is_omap_h3()
39#ifdef CONFIG_OMAP_OSK_MISTRAL
40 || machine_is_omap_osk()
41#endif
42 ) {
43
44 /* LED1/LED2 pins can be used as GPIO (as done here), or by
45 * the LPG (works even in deep sleep!), to drive a bicolor
46 * LED on the H2 sample board, and another on the H2/P2
47 * "surfer" expansion board.
48 *
49 * The same pins drive a LED on the OSK Mistral board, but
50 * that's a different kind of LED (just one color at a time).
51 */
52 omap_cfg_reg(P18_1610_GPIO3);
53 if (gpio_request(3, "LED red") == 0)
54 gpio_direction_output(3, 1);
55 else
56 printk(KERN_WARNING "LED: can't get GPIO3/red?\n");
57
58 omap_cfg_reg(MPUIO4);
59 if (gpio_request(OMAP_MPUIO(4), "LED green") == 0)
60 gpio_direction_output(OMAP_MPUIO(4), 1);
61 else
62 printk(KERN_WARNING "LED: can't get MPUIO4/green?\n");
63 }
64
65 leds_event(led_start);
66 return 0;
67}
68
69__initcall(omap_leds_init);
diff --git a/arch/arm/mach-omap1/leds.h b/arch/arm/mach-omap1/leds.h
deleted file mode 100644
index a1e9fedc376c..000000000000
--- a/arch/arm/mach-omap1/leds.h
+++ /dev/null
@@ -1,3 +0,0 @@
1extern void innovator_leds_event(led_event_t evt);
2extern void h2p2_dbg_leds_event(led_event_t evt);
3extern void osk_leds_event(led_event_t evt);
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 4062480bfec7..4d4816fd6fc9 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -44,7 +44,6 @@
44#include <linux/clockchips.h> 44#include <linux/clockchips.h>
45#include <linux/io.h> 45#include <linux/io.h>
46 46
47#include <asm/leds.h>
48#include <asm/irq.h> 47#include <asm/irq.h>
49#include <asm/sched_clock.h> 48#include <asm/sched_clock.h>
50 49
diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index eae49c3980c9..74529549130c 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -46,7 +46,6 @@
46#include <linux/clockchips.h> 46#include <linux/clockchips.h>
47#include <linux/io.h> 47#include <linux/io.h>
48 48
49#include <asm/leds.h>
50#include <asm/irq.h> 49#include <asm/irq.h>
51#include <asm/mach/irq.h> 50#include <asm/mach/irq.h>
52#include <asm/mach/time.h> 51#include <asm/mach/time.h>
diff --git a/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c b/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
index 78a6a11d8216..9b1c95310291 100644
--- a/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
@@ -18,7 +18,6 @@
18#include <linux/ethtool.h> 18#include <linux/ethtool.h>
19#include <net/dsa.h> 19#include <net/dsa.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/leds.h>
22#include <asm/mach/arch.h> 21#include <asm/mach/arch.h>
23#include <asm/mach/pci.h> 22#include <asm/mach/pci.h>
24#include <mach/orion5x.h> 23#include <mach/orion5x.h>
diff --git a/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c b/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
index 2f5dc54cd4cd..51ba2b81a10b 100644
--- a/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
@@ -19,7 +19,6 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <net/dsa.h> 20#include <net/dsa.h>
21#include <asm/mach-types.h> 21#include <asm/mach-types.h>
22#include <asm/leds.h>
23#include <asm/mach/arch.h> 22#include <asm/mach/arch.h>
24#include <asm/mach/pci.h> 23#include <asm/mach/pci.h>
25#include <mach/orion5x.h> 24#include <mach/orion5x.h>
diff --git a/arch/arm/mach-orion5x/rd88f5182-setup.c b/arch/arm/mach-orion5x/rd88f5182-setup.c
index 399130fac0b6..0a56b9444f1b 100644
--- a/arch/arm/mach-orion5x/rd88f5182-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5182-setup.c
@@ -19,8 +19,8 @@
19#include <linux/mv643xx_eth.h> 19#include <linux/mv643xx_eth.h>
20#include <linux/ata_platform.h> 20#include <linux/ata_platform.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/leds.h>
22#include <asm/mach-types.h> 23#include <asm/mach-types.h>
23#include <asm/leds.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
25#include <asm/mach/pci.h> 25#include <asm/mach/pci.h>
26#include <mach/orion5x.h> 26#include <mach/orion5x.h>
@@ -53,12 +53,6 @@
53#define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7 53#define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
54#define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6 54#define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
55 55
56/*
57 * GPIO Debug LED
58 */
59
60#define RD88F5182_GPIO_DBG_LED 0
61
62/***************************************************************************** 56/*****************************************************************************
63 * 16M NOR Flash on Device bus CS1 57 * 16M NOR Flash on Device bus CS1
64 ****************************************************************************/ 58 ****************************************************************************/
@@ -83,55 +77,32 @@ static struct platform_device rd88f5182_nor_flash = {
83 .resource = &rd88f5182_nor_flash_resource, 77 .resource = &rd88f5182_nor_flash_resource,
84}; 78};
85 79
86#ifdef CONFIG_LEDS
87
88/***************************************************************************** 80/*****************************************************************************
89 * Use GPIO debug led as CPU active indication 81 * Use GPIO LED as CPU active indication
90 ****************************************************************************/ 82 ****************************************************************************/
91 83
92static void rd88f5182_dbgled_event(led_event_t evt) 84#define RD88F5182_GPIO_LED 0
93{
94 int val;
95
96 if (evt == led_idle_end)
97 val = 1;
98 else if (evt == led_idle_start)
99 val = 0;
100 else
101 return;
102
103 gpio_set_value(RD88F5182_GPIO_DBG_LED, val);
104}
105
106static int __init rd88f5182_dbgled_init(void)
107{
108 int pin;
109
110 if (machine_is_rd88f5182()) {
111 pin = RD88F5182_GPIO_DBG_LED;
112 85
113 if (gpio_request(pin, "DBGLED") == 0) { 86static struct gpio_led rd88f5182_gpio_led_pins[] = {
114 if (gpio_direction_output(pin, 0) != 0) { 87 {
115 printk(KERN_ERR "rd88f5182_dbgled_init failed " 88 .name = "rd88f5182:cpu",
116 "to set output pin %d\n", pin); 89 .default_trigger = "cpu0",
117 gpio_free(pin); 90 .gpio = RD88F5182_GPIO_LED,
118 return 0; 91 },
119 } 92};
120 } else {
121 printk(KERN_ERR "rd88f5182_dbgled_init failed "
122 "to request gpio %d\n", pin);
123 return 0;
124 }
125
126 leds_event = rd88f5182_dbgled_event;
127 }
128
129 return 0;
130}
131 93
132__initcall(rd88f5182_dbgled_init); 94static struct gpio_led_platform_data rd88f5182_gpio_led_data = {
95 .leds = rd88f5182_gpio_led_pins,
96 .num_leds = ARRAY_SIZE(rd88f5182_gpio_led_pins),
97};
133 98
134#endif 99static struct platform_device rd88f5182_gpio_leds = {
100 .name = "leds-gpio",
101 .id = -1,
102 .dev = {
103 .platform_data = &rd88f5182_gpio_led_data,
104 },
105};
135 106
136/***************************************************************************** 107/*****************************************************************************
137 * PCI 108 * PCI
@@ -298,6 +269,7 @@ static void __init rd88f5182_init(void)
298 269
299 orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE); 270 orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);
300 platform_device_register(&rd88f5182_nor_flash); 271 platform_device_register(&rd88f5182_nor_flash);
272 platform_device_register(&rd88f5182_gpio_leds);
301 273
302 i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1); 274 i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
303} 275}
diff --git a/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c b/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
index 92df49c1b62a..ed50910b08a4 100644
--- a/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
+++ b/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
@@ -20,7 +20,6 @@
20#include <linux/ethtool.h> 20#include <linux/ethtool.h>
21#include <net/dsa.h> 21#include <net/dsa.h>
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <asm/leds.h>
24#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
25#include <asm/mach/pci.h> 24#include <asm/mach/pci.h>
26#include <mach/orion5x.h> 25#include <mach/orion5x.h>
diff --git a/arch/arm/mach-pnx4008/time.c b/arch/arm/mach-pnx4008/time.c
index 0cfe8af3d3be..47a7ae96156a 100644
--- a/arch/arm/mach-pnx4008/time.c
+++ b/arch/arm/mach-pnx4008/time.c
@@ -25,7 +25,6 @@
25#include <linux/io.h> 25#include <linux/io.h>
26 26
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <asm/leds.h>
29#include <asm/mach/time.h> 28#include <asm/mach/time.h>
30#include <asm/errno.h> 29#include <asm/errno.h>
31 30
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index be0f7df8685c..d4337e300ada 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -95,12 +95,4 @@ obj-$(CONFIG_MACH_RAUMFELD_CONNECTOR) += raumfeld.o
95obj-$(CONFIG_MACH_RAUMFELD_SPEAKER) += raumfeld.o 95obj-$(CONFIG_MACH_RAUMFELD_SPEAKER) += raumfeld.o
96obj-$(CONFIG_MACH_ZIPIT2) += z2.o 96obj-$(CONFIG_MACH_ZIPIT2) += z2.o
97 97
98# Support for blinky lights
99led-y := leds.o
100led-$(CONFIG_ARCH_LUBBOCK) += leds-lubbock.o
101led-$(CONFIG_MACH_MAINSTONE) += leds-mainstone.o
102led-$(CONFIG_ARCH_PXA_IDP) += leds-idp.o
103
104obj-$(CONFIG_LEDS) += $(led-y)
105
106obj-$(CONFIG_TOSA_BT) += tosa-bt.o 98obj-$(CONFIG_TOSA_BT) += tosa-bt.o
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index 6ff466bd43e8..ae1e9977603e 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -191,6 +191,87 @@ static void __init idp_map_io(void)
191 iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc)); 191 iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc));
192} 192}
193 193
194/* LEDs */
195#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
196struct idp_led {
197 struct led_classdev cdev;
198 u8 mask;
199};
200
201/*
202 * The triggers lines up below will only be used if the
203 * LED triggers are compiled in.
204 */
205static const struct {
206 const char *name;
207 const char *trigger;
208} idp_leds[] = {
209 { "idp:green", "heartbeat", },
210 { "idp:red", "cpu0", },
211};
212
213static void idp_led_set(struct led_classdev *cdev,
214 enum led_brightness b)
215{
216 struct idp_led *led = container_of(cdev,
217 struct idp_led, cdev);
218 u32 reg = IDP_CPLD_LED_CONTROL;
219
220 if (b != LED_OFF)
221 reg &= ~led->mask;
222 else
223 reg |= led->mask;
224
225 IDP_CPLD_LED_CONTROL = reg;
226}
227
228static enum led_brightness idp_led_get(struct led_classdev *cdev)
229{
230 struct idp_led *led = container_of(cdev,
231 struct idp_led, cdev);
232
233 return (IDP_CPLD_LED_CONTROL & led->mask) ? LED_OFF : LED_FULL;
234}
235
236static int __init idp_leds_init(void)
237{
238 int i;
239
240 if (!machine_is_pxa_idp())
241 return -ENODEV;
242
243 for (i = 0; i < ARRAY_SIZE(idp_leds); i++) {
244 struct idp_led *led;
245
246 led = kzalloc(sizeof(*led), GFP_KERNEL);
247 if (!led)
248 break;
249
250 led->cdev.name = idp_leds[i].name;
251 led->cdev.brightness_set = idp_led_set;
252 led->cdev.brightness_get = idp_led_get;
253 led->cdev.default_trigger = idp_leds[i].trigger;
254
255 if (i == 0)
256 led->mask = IDP_HB_LED;
257 else
258 led->mask = IDP_BUSY_LED;
259
260 if (led_classdev_register(NULL, &led->cdev) < 0) {
261 kfree(led);
262 break;
263 }
264 }
265
266 return 0;
267}
268
269/*
270 * Since we may have triggers on any subsystem, defer registration
271 * until after subsystem_init.
272 */
273fs_initcall(idp_leds_init);
274#endif
194 275
195MACHINE_START(PXA_IDP, "Vibren PXA255 IDP") 276MACHINE_START(PXA_IDP, "Vibren PXA255 IDP")
196 /* Maintainer: Vibren Technologies */ 277 /* Maintainer: Vibren Technologies */
diff --git a/arch/arm/mach-pxa/leds-idp.c b/arch/arm/mach-pxa/leds-idp.c
deleted file mode 100644
index 06b060025d11..000000000000
--- a/arch/arm/mach-pxa/leds-idp.c
+++ /dev/null
@@ -1,115 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/leds-idp.c
3 *
4 * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
5 *
6 * Copyright (c) 2001 Jeff Sutherland <jeffs@accelent.com>
7 *
8 * Original (leds-footbridge.c) by Russell King
9 *
10 * Macros for actual LED manipulation should be in machine specific
11 * files in this 'mach' directory.
12 */
13
14
15#include <linux/init.h>
16
17#include <mach/hardware.h>
18#include <asm/leds.h>
19
20#include <mach/pxa25x.h>
21#include <mach/idp.h>
22
23#include "leds.h"
24
25#define LED_STATE_ENABLED 1
26#define LED_STATE_CLAIMED 2
27
28static unsigned int led_state;
29static unsigned int hw_led_state;
30
31void idp_leds_event(led_event_t evt)
32{
33 unsigned long flags;
34
35 local_irq_save(flags);
36
37 switch (evt) {
38 case led_start:
39 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
40 led_state = LED_STATE_ENABLED;
41 break;
42
43 case led_stop:
44 led_state &= ~LED_STATE_ENABLED;
45 break;
46
47 case led_claim:
48 led_state |= LED_STATE_CLAIMED;
49 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
50 break;
51
52 case led_release:
53 led_state &= ~LED_STATE_CLAIMED;
54 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
55 break;
56
57#ifdef CONFIG_LEDS_TIMER
58 case led_timer:
59 if (!(led_state & LED_STATE_CLAIMED))
60 hw_led_state ^= IDP_HB_LED;
61 break;
62#endif
63
64#ifdef CONFIG_LEDS_CPU
65 case led_idle_start:
66 if (!(led_state & LED_STATE_CLAIMED))
67 hw_led_state &= ~IDP_BUSY_LED;
68 break;
69
70 case led_idle_end:
71 if (!(led_state & LED_STATE_CLAIMED))
72 hw_led_state |= IDP_BUSY_LED;
73 break;
74#endif
75
76 case led_halted:
77 break;
78
79 case led_green_on:
80 if (led_state & LED_STATE_CLAIMED)
81 hw_led_state |= IDP_HB_LED;
82 break;
83
84 case led_green_off:
85 if (led_state & LED_STATE_CLAIMED)
86 hw_led_state &= ~IDP_HB_LED;
87 break;
88
89 case led_amber_on:
90 break;
91
92 case led_amber_off:
93 break;
94
95 case led_red_on:
96 if (led_state & LED_STATE_CLAIMED)
97 hw_led_state |= IDP_BUSY_LED;
98 break;
99
100 case led_red_off:
101 if (led_state & LED_STATE_CLAIMED)
102 hw_led_state &= ~IDP_BUSY_LED;
103 break;
104
105 default:
106 break;
107 }
108
109 if (led_state & LED_STATE_ENABLED)
110 IDP_CPLD_LED_CONTROL = ( (IDP_CPLD_LED_CONTROL | IDP_LEDS_MASK) & ~hw_led_state);
111 else
112 IDP_CPLD_LED_CONTROL |= IDP_LEDS_MASK;
113
114 local_irq_restore(flags);
115}
diff --git a/arch/arm/mach-pxa/leds-lubbock.c b/arch/arm/mach-pxa/leds-lubbock.c
deleted file mode 100644
index 0bd85c884a7c..000000000000
--- a/arch/arm/mach-pxa/leds-lubbock.c
+++ /dev/null
@@ -1,124 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/leds-lubbock.c
3 *
4 * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
5 *
6 * Copyright (c) 2001 Jeff Sutherland <jeffs@accelent.com>
7 *
8 * Original (leds-footbridge.c) by Russell King
9 *
10 * Major surgery on April 2004 by Nicolas Pitre for less global
11 * namespace collision. Mostly adapted the Mainstone version.
12 */
13
14#include <linux/init.h>
15
16#include <mach/hardware.h>
17#include <asm/leds.h>
18#include <mach/pxa25x.h>
19#include <mach/lubbock.h>
20
21#include "leds.h"
22
23/*
24 * 8 discrete leds available for general use:
25 *
26 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
27 * so be sure to not monkey with them here.
28 */
29
30#define D28 (1 << 0)
31#define D27 (1 << 1)
32#define D26 (1 << 2)
33#define D25 (1 << 3)
34#define D24 (1 << 4)
35#define D23 (1 << 5)
36#define D22 (1 << 6)
37#define D21 (1 << 7)
38
39#define LED_STATE_ENABLED 1
40#define LED_STATE_CLAIMED 2
41
42static unsigned int led_state;
43static unsigned int hw_led_state;
44
45void lubbock_leds_event(led_event_t evt)
46{
47 unsigned long flags;
48
49 local_irq_save(flags);
50
51 switch (evt) {
52 case led_start:
53 hw_led_state = 0;
54 led_state = LED_STATE_ENABLED;
55 break;
56
57 case led_stop:
58 led_state &= ~LED_STATE_ENABLED;
59 break;
60
61 case led_claim:
62 led_state |= LED_STATE_CLAIMED;
63 hw_led_state = 0;
64 break;
65
66 case led_release:
67 led_state &= ~LED_STATE_CLAIMED;
68 hw_led_state = 0;
69 break;
70
71#ifdef CONFIG_LEDS_TIMER
72 case led_timer:
73 hw_led_state ^= D26;
74 break;
75#endif
76
77#ifdef CONFIG_LEDS_CPU
78 case led_idle_start:
79 hw_led_state &= ~D27;
80 break;
81
82 case led_idle_end:
83 hw_led_state |= D27;
84 break;
85#endif
86
87 case led_halted:
88 break;
89
90 case led_green_on:
91 hw_led_state |= D21;
92 break;
93
94 case led_green_off:
95 hw_led_state &= ~D21;
96 break;
97
98 case led_amber_on:
99 hw_led_state |= D22;
100 break;
101
102 case led_amber_off:
103 hw_led_state &= ~D22;
104 break;
105
106 case led_red_on:
107 hw_led_state |= D23;
108 break;
109
110 case led_red_off:
111 hw_led_state &= ~D23;
112 break;
113
114 default:
115 break;
116 }
117
118 if (led_state & LED_STATE_ENABLED)
119 LUB_DISC_BLNK_LED = (LUB_DISC_BLNK_LED | 0xff) & ~hw_led_state;
120 else
121 LUB_DISC_BLNK_LED |= 0xff;
122
123 local_irq_restore(flags);
124}
diff --git a/arch/arm/mach-pxa/leds-mainstone.c b/arch/arm/mach-pxa/leds-mainstone.c
deleted file mode 100644
index 4058ab340fe6..000000000000
--- a/arch/arm/mach-pxa/leds-mainstone.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/leds-mainstone.c
3 *
4 * Author: Nicolas Pitre
5 * Created: Nov 05, 2002
6 * Copyright: MontaVista Software Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14
15#include <mach/hardware.h>
16#include <asm/leds.h>
17
18#include <mach/pxa27x.h>
19#include <mach/mainstone.h>
20
21#include "leds.h"
22
23
24/* 8 discrete leds available for general use: */
25#define D28 (1 << 0)
26#define D27 (1 << 1)
27#define D26 (1 << 2)
28#define D25 (1 << 3)
29#define D24 (1 << 4)
30#define D23 (1 << 5)
31#define D22 (1 << 6)
32#define D21 (1 << 7)
33
34#define LED_STATE_ENABLED 1
35#define LED_STATE_CLAIMED 2
36
37static unsigned int led_state;
38static unsigned int hw_led_state;
39
40void mainstone_leds_event(led_event_t evt)
41{
42 unsigned long flags;
43
44 local_irq_save(flags);
45
46 switch (evt) {
47 case led_start:
48 hw_led_state = 0;
49 led_state = LED_STATE_ENABLED;
50 break;
51
52 case led_stop:
53 led_state &= ~LED_STATE_ENABLED;
54 break;
55
56 case led_claim:
57 led_state |= LED_STATE_CLAIMED;
58 hw_led_state = 0;
59 break;
60
61 case led_release:
62 led_state &= ~LED_STATE_CLAIMED;
63 hw_led_state = 0;
64 break;
65
66#ifdef CONFIG_LEDS_TIMER
67 case led_timer:
68 hw_led_state ^= D26;
69 break;
70#endif
71
72#ifdef CONFIG_LEDS_CPU
73 case led_idle_start:
74 hw_led_state &= ~D27;
75 break;
76
77 case led_idle_end:
78 hw_led_state |= D27;
79 break;
80#endif
81
82 case led_halted:
83 break;
84
85 case led_green_on:
86 hw_led_state |= D21;
87 break;
88
89 case led_green_off:
90 hw_led_state &= ~D21;
91 break;
92
93 case led_amber_on:
94 hw_led_state |= D22;
95 break;
96
97 case led_amber_off:
98 hw_led_state &= ~D22;
99 break;
100
101 case led_red_on:
102 hw_led_state |= D23;
103 break;
104
105 case led_red_off:
106 hw_led_state &= ~D23;
107 break;
108
109 default:
110 break;
111 }
112
113 if (led_state & LED_STATE_ENABLED)
114 MST_LEDCTRL = (MST_LEDCTRL | 0xff) & ~hw_led_state;
115 else
116 MST_LEDCTRL |= 0xff;
117
118 local_irq_restore(flags);
119}
diff --git a/arch/arm/mach-pxa/leds.c b/arch/arm/mach-pxa/leds.c
deleted file mode 100644
index bbe4d5f6afaa..000000000000
--- a/arch/arm/mach-pxa/leds.c
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/leds.c
3 *
4 * xscale LEDs dispatcher
5 *
6 * Copyright (C) 2001 Nicolas Pitre
7 *
8 * Copyright (c) 2001 Jeff Sutherland, Accelent Systems Inc.
9 */
10#include <linux/compiler.h>
11#include <linux/init.h>
12
13#include <asm/leds.h>
14#include <asm/mach-types.h>
15
16#include "leds.h"
17
18static int __init
19pxa_leds_init(void)
20{
21 if (machine_is_lubbock())
22 leds_event = lubbock_leds_event;
23 if (machine_is_mainstone())
24 leds_event = mainstone_leds_event;
25 if (machine_is_pxa_idp())
26 leds_event = idp_leds_event;
27
28 leds_event(led_start);
29 return 0;
30}
31
32core_initcall(pxa_leds_init);
diff --git a/arch/arm/mach-pxa/leds.h b/arch/arm/mach-pxa/leds.h
deleted file mode 100644
index 7f0dfe01345a..000000000000
--- a/arch/arm/mach-pxa/leds.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-pxa/leds.h
3 *
4 * Copyright (c) 2001 Jeff Sutherland, Accelent Systems Inc.
5 *
6 * blinky lights for various PXA-based systems:
7 *
8 */
9
10extern void idp_leds_event(led_event_t evt);
11extern void lubbock_leds_event(led_event_t evt);
12extern void mainstone_leds_event(led_event_t evt);
13extern void trizeps4_leds_event(led_event_t evt);
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 0ca0db787903..3c48035afd6b 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -15,6 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/io.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/syscore_ops.h> 20#include <linux/syscore_ops.h>
20#include <linux/major.h> 21#include <linux/major.h>
@@ -23,6 +24,8 @@
23#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h> 25#include <linux/mtd/partitions.h>
25#include <linux/smc91x.h> 26#include <linux/smc91x.h>
27#include <linux/slab.h>
28#include <linux/leds.h>
26 29
27#include <linux/spi/spi.h> 30#include <linux/spi/spi.h>
28#include <linux/spi/ads7846.h> 31#include <linux/spi/ads7846.h>
@@ -549,6 +552,98 @@ static void __init lubbock_map_io(void)
549 PCFR |= PCFR_OPDE; 552 PCFR |= PCFR_OPDE;
550} 553}
551 554
555/*
556 * Driver for the 8 discrete LEDs available for general use:
557 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
558 * so be sure to not monkey with them here.
559 */
560
561#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
562struct lubbock_led {
563 struct led_classdev cdev;
564 u8 mask;
565};
566
567/*
568 * The triggers lines up below will only be used if the
569 * LED triggers are compiled in.
570 */
571static const struct {
572 const char *name;
573 const char *trigger;
574} lubbock_leds[] = {
575 { "lubbock:D28", "default-on", },
576 { "lubbock:D27", "cpu0", },
577 { "lubbock:D26", "heartbeat" },
578 { "lubbock:D25", },
579 { "lubbock:D24", },
580 { "lubbock:D23", },
581 { "lubbock:D22", },
582 { "lubbock:D21", },
583};
584
585static void lubbock_led_set(struct led_classdev *cdev,
586 enum led_brightness b)
587{
588 struct lubbock_led *led = container_of(cdev,
589 struct lubbock_led, cdev);
590 u32 reg = LUB_DISC_BLNK_LED;
591
592 if (b != LED_OFF)
593 reg |= led->mask;
594 else
595 reg &= ~led->mask;
596
597 LUB_DISC_BLNK_LED = reg;
598}
599
600static enum led_brightness lubbock_led_get(struct led_classdev *cdev)
601{
602 struct lubbock_led *led = container_of(cdev,
603 struct lubbock_led, cdev);
604 u32 reg = LUB_DISC_BLNK_LED;
605
606 return (reg & led->mask) ? LED_FULL : LED_OFF;
607}
608
609static int __init lubbock_leds_init(void)
610{
611 int i;
612
613 if (!machine_is_lubbock())
614 return -ENODEV;
615
616 /* All ON */
617 LUB_DISC_BLNK_LED |= 0xff;
618 for (i = 0; i < ARRAY_SIZE(lubbock_leds); i++) {
619 struct lubbock_led *led;
620
621 led = kzalloc(sizeof(*led), GFP_KERNEL);
622 if (!led)
623 break;
624
625 led->cdev.name = lubbock_leds[i].name;
626 led->cdev.brightness_set = lubbock_led_set;
627 led->cdev.brightness_get = lubbock_led_get;
628 led->cdev.default_trigger = lubbock_leds[i].trigger;
629 led->mask = BIT(i);
630
631 if (led_classdev_register(NULL, &led->cdev) < 0) {
632 kfree(led);
633 break;
634 }
635 }
636
637 return 0;
638}
639
640/*
641 * Since we may have triggers on any subsystem, defer registration
642 * until after subsystem_init.
643 */
644fs_initcall(lubbock_leds_init);
645#endif
646
552MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)") 647MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
553 /* Maintainer: MontaVista Software Inc. */ 648 /* Maintainer: MontaVista Software Inc. */
554 .map_io = lubbock_map_io, 649 .map_io = lubbock_map_io,
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 1aebaf719462..bdc6c335830a 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -28,6 +28,8 @@
28#include <linux/pwm_backlight.h> 28#include <linux/pwm_backlight.h>
29#include <linux/smc91x.h> 29#include <linux/smc91x.h>
30#include <linux/i2c/pxa-i2c.h> 30#include <linux/i2c/pxa-i2c.h>
31#include <linux/slab.h>
32#include <linux/leds.h>
31 33
32#include <asm/types.h> 34#include <asm/types.h>
33#include <asm/setup.h> 35#include <asm/setup.h>
@@ -613,6 +615,98 @@ static void __init mainstone_map_io(void)
613 PCFR = 0x66; 615 PCFR = 0x66;
614} 616}
615 617
618/*
619 * Driver for the 8 discrete LEDs available for general use:
620 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
621 * so be sure to not monkey with them here.
622 */
623
624#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
625struct mainstone_led {
626 struct led_classdev cdev;
627 u8 mask;
628};
629
630/*
631 * The triggers lines up below will only be used if the
632 * LED triggers are compiled in.
633 */
634static const struct {
635 const char *name;
636 const char *trigger;
637} mainstone_leds[] = {
638 { "mainstone:D28", "default-on", },
639 { "mainstone:D27", "cpu0", },
640 { "mainstone:D26", "heartbeat" },
641 { "mainstone:D25", },
642 { "mainstone:D24", },
643 { "mainstone:D23", },
644 { "mainstone:D22", },
645 { "mainstone:D21", },
646};
647
648static void mainstone_led_set(struct led_classdev *cdev,
649 enum led_brightness b)
650{
651 struct mainstone_led *led = container_of(cdev,
652 struct mainstone_led, cdev);
653 u32 reg = MST_LEDCTRL;
654
655 if (b != LED_OFF)
656 reg |= led->mask;
657 else
658 reg &= ~led->mask;
659
660 MST_LEDCTRL = reg;
661}
662
663static enum led_brightness mainstone_led_get(struct led_classdev *cdev)
664{
665 struct mainstone_led *led = container_of(cdev,
666 struct mainstone_led, cdev);
667 u32 reg = MST_LEDCTRL;
668
669 return (reg & led->mask) ? LED_FULL : LED_OFF;
670}
671
672static int __init mainstone_leds_init(void)
673{
674 int i;
675
676 if (!machine_is_mainstone())
677 return -ENODEV;
678
679 /* All ON */
680 MST_LEDCTRL |= 0xff;
681 for (i = 0; i < ARRAY_SIZE(mainstone_leds); i++) {
682 struct mainstone_led *led;
683
684 led = kzalloc(sizeof(*led), GFP_KERNEL);
685 if (!led)
686 break;
687
688 led->cdev.name = mainstone_leds[i].name;
689 led->cdev.brightness_set = mainstone_led_set;
690 led->cdev.brightness_get = mainstone_led_get;
691 led->cdev.default_trigger = mainstone_leds[i].trigger;
692 led->mask = BIT(i);
693
694 if (led_classdev_register(NULL, &led->cdev) < 0) {
695 kfree(led);
696 break;
697 }
698 }
699
700 return 0;
701}
702
703/*
704 * Since we may have triggers on any subsystem, defer registration
705 * until after subsystem_init.
706 */
707fs_initcall(mainstone_leds_init);
708#endif
709
616MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)") 710MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
617 /* Maintainer: MontaVista Software Inc. */ 711 /* Maintainer: MontaVista Software Inc. */
618 .atag_offset = 0x100, /* BLOB boot parameter setting */ 712 .atag_offset = 0x100, /* BLOB boot parameter setting */
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 45868bb43cbd..d22dee96484d 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -35,7 +35,6 @@
35 35
36#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/leds.h>
39#include <asm/mach-types.h> 38#include <asm/mach-types.h>
40#include <asm/hardware/arm_timer.h> 39#include <asm/hardware/arm_timer.h>
41#include <asm/hardware/icst.h> 40#include <asm/hardware/icst.h>
@@ -436,44 +435,6 @@ struct clcd_board clcd_plat_data = {
436 .remove = versatile_clcd_remove_dma, 435 .remove = versatile_clcd_remove_dma,
437}; 436};
438 437
439#ifdef CONFIG_LEDS
440#define VA_LEDS_BASE (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
441
442void realview_leds_event(led_event_t ledevt)
443{
444 unsigned long flags;
445 u32 val;
446 u32 led = 1 << smp_processor_id();
447
448 local_irq_save(flags);
449 val = readl(VA_LEDS_BASE);
450
451 switch (ledevt) {
452 case led_idle_start:
453 val = val & ~led;
454 break;
455
456 case led_idle_end:
457 val = val | led;
458 break;
459
460 case led_timer:
461 val = val ^ REALVIEW_SYS_LED7;
462 break;
463
464 case led_halted:
465 val = 0;
466 break;
467
468 default:
469 break;
470 }
471
472 writel(val, VA_LEDS_BASE);
473 local_irq_restore(flags);
474}
475#endif /* CONFIG_LEDS */
476
477/* 438/*
478 * Where is the timer (VA)? 439 * Where is the timer (VA)?
479 */ 440 */
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index f8f2c0ac4c01..f2141ae5a7de 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -26,7 +26,6 @@
26#include <linux/io.h> 26#include <linux/io.h>
27 27
28#include <asm/setup.h> 28#include <asm/setup.h>
29#include <asm/leds.h>
30 29
31#define APB_DEVICE(name, busid, base, plat) \ 30#define APB_DEVICE(name, busid, base, plat) \
32static AMBA_APB_DEVICE(name, busid, 0, REALVIEW_##base##_BASE, base##_IRQ, plat) 31static AMBA_APB_DEVICE(name, busid, 0, REALVIEW_##base##_BASE, base##_IRQ, plat)
@@ -47,7 +46,6 @@ extern void __iomem *timer1_va_base;
47extern void __iomem *timer2_va_base; 46extern void __iomem *timer2_va_base;
48extern void __iomem *timer3_va_base; 47extern void __iomem *timer3_va_base;
49 48
50extern void realview_leds_event(led_event_t ledevt);
51extern void realview_timer_init(unsigned int timer_irq); 49extern void realview_timer_init(unsigned int timer_irq);
52extern int realview_flash_register(struct resource *res, u32 num); 50extern int realview_flash_register(struct resource *res, u32 num);
53extern int realview_eth_register(const char *name, struct resource *res); 51extern int realview_eth_register(const char *name, struct resource *res);
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index baf382c5e776..21661ade885f 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -30,7 +30,6 @@
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/leds.h>
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
35#include <asm/pmu.h> 34#include <asm/pmu.h>
36#include <asm/pgtable.h> 35#include <asm/pgtable.h>
@@ -462,10 +461,6 @@ static void __init realview_eb_init(void)
462 struct amba_device *d = amba_devs[i]; 461 struct amba_device *d = amba_devs[i];
463 amba_device_register(d, &iomem_resource); 462 amba_device_register(d, &iomem_resource);
464 } 463 }
465
466#ifdef CONFIG_LEDS
467 leds_event = realview_leds_event;
468#endif
469} 464}
470 465
471MACHINE_START(REALVIEW_EB, "ARM-RealView EB") 466MACHINE_START(REALVIEW_EB, "ARM-RealView EB")
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c
index b1d7cafa1a6d..c0ff882c5cb8 100644
--- a/arch/arm/mach-realview/realview_pb1176.c
+++ b/arch/arm/mach-realview/realview_pb1176.c
@@ -32,7 +32,6 @@
32 32
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/leds.h>
36#include <asm/mach-types.h> 35#include <asm/mach-types.h>
37#include <asm/pmu.h> 36#include <asm/pmu.h>
38#include <asm/pgtable.h> 37#include <asm/pgtable.h>
@@ -375,10 +374,6 @@ static void __init realview_pb1176_init(void)
375 struct amba_device *d = amba_devs[i]; 374 struct amba_device *d = amba_devs[i];
376 amba_device_register(d, &iomem_resource); 375 amba_device_register(d, &iomem_resource);
377 } 376 }
378
379#ifdef CONFIG_LEDS
380 leds_event = realview_leds_event;
381#endif
382} 377}
383 378
384MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176") 379MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index a98c536e3327..30779ae40c04 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -30,7 +30,6 @@
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/leds.h>
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
35#include <asm/pmu.h> 34#include <asm/pmu.h>
36#include <asm/pgtable.h> 35#include <asm/pgtable.h>
@@ -357,10 +356,6 @@ static void __init realview_pb11mp_init(void)
357 struct amba_device *d = amba_devs[i]; 356 struct amba_device *d = amba_devs[i];
358 amba_device_register(d, &iomem_resource); 357 amba_device_register(d, &iomem_resource);
359 } 358 }
360
361#ifdef CONFIG_LEDS
362 leds_event = realview_leds_event;
363#endif
364} 359}
365 360
366MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore") 361MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore")
diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c
index 59650174e6ed..081cd72c090e 100644
--- a/arch/arm/mach-realview/realview_pba8.c
+++ b/arch/arm/mach-realview/realview_pba8.c
@@ -29,7 +29,6 @@
29#include <linux/io.h> 29#include <linux/io.h>
30 30
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/leds.h>
33#include <asm/mach-types.h> 32#include <asm/mach-types.h>
34#include <asm/pmu.h> 33#include <asm/pmu.h>
35#include <asm/pgtable.h> 34#include <asm/pgtable.h>
@@ -299,10 +298,6 @@ static void __init realview_pba8_init(void)
299 struct amba_device *d = amba_devs[i]; 298 struct amba_device *d = amba_devs[i];
300 amba_device_register(d, &iomem_resource); 299 amba_device_register(d, &iomem_resource);
301 } 300 }
302
303#ifdef CONFIG_LEDS
304 leds_event = realview_leds_event;
305#endif
306} 301}
307 302
308MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8") 303MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8")
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 3f2f605624e9..1ce62b9f846c 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -28,7 +28,6 @@
28#include <linux/io.h> 28#include <linux/io.h>
29 29
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/leds.h>
32#include <asm/mach-types.h> 31#include <asm/mach-types.h>
33#include <asm/pmu.h> 32#include <asm/pmu.h>
34#include <asm/smp_twd.h> 33#include <asm/smp_twd.h>
@@ -394,10 +393,6 @@ static void __init realview_pbx_init(void)
394 struct amba_device *d = amba_devs[i]; 393 struct amba_device *d = amba_devs[i];
395 amba_device_register(d, &iomem_resource); 394 amba_device_register(d, &iomem_resource);
396 } 395 }
397
398#ifdef CONFIG_LEDS
399 leds_event = realview_leds_event;
400#endif
401} 396}
402 397
403MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX") 398MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
index 60b97ec01676..1aed9e70465d 100644
--- a/arch/arm/mach-sa1100/Makefile
+++ b/arch/arm/mach-sa1100/Makefile
@@ -7,21 +7,17 @@ obj-y := clock.o generic.o irq.o time.o #nmi-oopser.o
7obj-m := 7obj-m :=
8obj-n := 8obj-n :=
9obj- := 9obj- :=
10led-y := leds.o
11 10
12obj-$(CONFIG_CPU_FREQ_SA1100) += cpu-sa1100.o 11obj-$(CONFIG_CPU_FREQ_SA1100) += cpu-sa1100.o
13obj-$(CONFIG_CPU_FREQ_SA1110) += cpu-sa1110.o 12obj-$(CONFIG_CPU_FREQ_SA1110) += cpu-sa1110.o
14 13
15# Specific board support 14# Specific board support
16obj-$(CONFIG_SA1100_ASSABET) += assabet.o 15obj-$(CONFIG_SA1100_ASSABET) += assabet.o
17led-$(CONFIG_SA1100_ASSABET) += leds-assabet.o
18obj-$(CONFIG_ASSABET_NEPONSET) += neponset.o 16obj-$(CONFIG_ASSABET_NEPONSET) += neponset.o
19 17
20obj-$(CONFIG_SA1100_BADGE4) += badge4.o 18obj-$(CONFIG_SA1100_BADGE4) += badge4.o
21led-$(CONFIG_SA1100_BADGE4) += leds-badge4.o
22 19
23obj-$(CONFIG_SA1100_CERF) += cerf.o 20obj-$(CONFIG_SA1100_CERF) += cerf.o
24led-$(CONFIG_SA1100_CERF) += leds-cerf.o
25 21
26obj-$(CONFIG_SA1100_COLLIE) += collie.o 22obj-$(CONFIG_SA1100_COLLIE) += collie.o
27 23
@@ -29,13 +25,11 @@ obj-$(CONFIG_SA1100_H3100) += h3100.o h3xxx.o
29obj-$(CONFIG_SA1100_H3600) += h3600.o h3xxx.o 25obj-$(CONFIG_SA1100_H3600) += h3600.o h3xxx.o
30 26
31obj-$(CONFIG_SA1100_HACKKIT) += hackkit.o 27obj-$(CONFIG_SA1100_HACKKIT) += hackkit.o
32led-$(CONFIG_SA1100_HACKKIT) += leds-hackkit.o
33 28
34obj-$(CONFIG_SA1100_JORNADA720) += jornada720.o 29obj-$(CONFIG_SA1100_JORNADA720) += jornada720.o
35obj-$(CONFIG_SA1100_JORNADA720_SSP) += jornada720_ssp.o 30obj-$(CONFIG_SA1100_JORNADA720_SSP) += jornada720_ssp.o
36 31
37obj-$(CONFIG_SA1100_LART) += lart.o 32obj-$(CONFIG_SA1100_LART) += lart.o
38led-$(CONFIG_SA1100_LART) += leds-lart.o
39 33
40obj-$(CONFIG_SA1100_NANOENGINE) += nanoengine.o 34obj-$(CONFIG_SA1100_NANOENGINE) += nanoengine.o
41obj-$(CONFIG_PCI_NANOENGINE) += pci-nanoengine.o 35obj-$(CONFIG_PCI_NANOENGINE) += pci-nanoengine.o
@@ -46,9 +40,6 @@ obj-$(CONFIG_SA1100_SHANNON) += shannon.o
46 40
47obj-$(CONFIG_SA1100_SIMPAD) += simpad.o 41obj-$(CONFIG_SA1100_SIMPAD) += simpad.o
48 42
49# LEDs support
50obj-$(CONFIG_LEDS) += $(led-y)
51
52# Miscellaneous functions 43# Miscellaneous functions
53obj-$(CONFIG_PM) += pm.o sleep.o 44obj-$(CONFIG_PM) += pm.o sleep.o
54obj-$(CONFIG_SA1100_SSP) += ssp.o 45obj-$(CONFIG_SA1100_SSP) += ssp.o
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index d673211f121c..1710ed1a0ac0 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -20,6 +20,8 @@
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/leds.h>
24#include <linux/slab.h>
23 25
24#include <video/sa1100fb.h> 26#include <video/sa1100fb.h>
25 27
@@ -529,6 +531,89 @@ static void __init assabet_map_io(void)
529 sa1100_register_uart(2, 3); 531 sa1100_register_uart(2, 3);
530} 532}
531 533
534/* LEDs */
535#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
536struct assabet_led {
537 struct led_classdev cdev;
538 u32 mask;
539};
540
541/*
542 * The triggers lines up below will only be used if the
543 * LED triggers are compiled in.
544 */
545static const struct {
546 const char *name;
547 const char *trigger;
548} assabet_leds[] = {
549 { "assabet:red", "cpu0",},
550 { "assabet:green", "heartbeat", },
551};
552
553/*
554 * The LED control in Assabet is reversed:
555 * - setting bit means turn off LED
556 * - clearing bit means turn on LED
557 */
558static void assabet_led_set(struct led_classdev *cdev,
559 enum led_brightness b)
560{
561 struct assabet_led *led = container_of(cdev,
562 struct assabet_led, cdev);
563
564 if (b != LED_OFF)
565 ASSABET_BCR_clear(led->mask);
566 else
567 ASSABET_BCR_set(led->mask);
568}
569
570static enum led_brightness assabet_led_get(struct led_classdev *cdev)
571{
572 struct assabet_led *led = container_of(cdev,
573 struct assabet_led, cdev);
574
575 return (ASSABET_BCR & led->mask) ? LED_OFF : LED_FULL;
576}
577
578static int __init assabet_leds_init(void)
579{
580 int i;
581
582 if (!machine_is_assabet())
583 return -ENODEV;
584
585 for (i = 0; i < ARRAY_SIZE(assabet_leds); i++) {
586 struct assabet_led *led;
587
588 led = kzalloc(sizeof(*led), GFP_KERNEL);
589 if (!led)
590 break;
591
592 led->cdev.name = assabet_leds[i].name;
593 led->cdev.brightness_set = assabet_led_set;
594 led->cdev.brightness_get = assabet_led_get;
595 led->cdev.default_trigger = assabet_leds[i].trigger;
596
597 if (!i)
598 led->mask = ASSABET_BCR_LED_RED;
599 else
600 led->mask = ASSABET_BCR_LED_GREEN;
601
602 if (led_classdev_register(NULL, &led->cdev) < 0) {
603 kfree(led);
604 break;
605 }
606 }
607
608 return 0;
609}
610
611/*
612 * Since we may have triggers on any subsystem, defer registration
613 * until after subsystem_init.
614 */
615fs_initcall(assabet_leds_init);
616#endif
532 617
533MACHINE_START(ASSABET, "Intel-Assabet") 618MACHINE_START(ASSABET, "Intel-Assabet")
534 .atag_offset = 0x100, 619 .atag_offset = 0x100,
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
index b30fb99b587c..038df4894b0f 100644
--- a/arch/arm/mach-sa1100/badge4.c
+++ b/arch/arm/mach-sa1100/badge4.c
@@ -22,6 +22,8 @@
22#include <linux/mtd/mtd.h> 22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/gpio.h>
26#include <linux/leds.h>
25 27
26#include <mach/hardware.h> 28#include <mach/hardware.h>
27#include <asm/mach-types.h> 29#include <asm/mach-types.h>
@@ -76,8 +78,36 @@ static struct platform_device sa1111_device = {
76 .resource = sa1111_resources, 78 .resource = sa1111_resources,
77}; 79};
78 80
81/* LEDs */
82struct gpio_led badge4_gpio_leds[] = {
83 {
84 .name = "badge4:red",
85 .default_trigger = "heartbeat",
86 .gpio = 7,
87 },
88 {
89 .name = "badge4:green",
90 .default_trigger = "cpu0",
91 .gpio = 9,
92 },
93};
94
95static struct gpio_led_platform_data badge4_gpio_led_info = {
96 .leds = badge4_gpio_leds,
97 .num_leds = ARRAY_SIZE(badge4_gpio_leds),
98};
99
100static struct platform_device badge4_leds = {
101 .name = "leds-gpio",
102 .id = -1,
103 .dev = {
104 .platform_data = &badge4_gpio_led_info,
105 }
106};
107
79static struct platform_device *devices[] __initdata = { 108static struct platform_device *devices[] __initdata = {
80 &sa1111_device, 109 &sa1111_device,
110 &badge4_leds,
81}; 111};
82 112
83static int __init badge4_sa1111_init(void) 113static int __init badge4_sa1111_init(void)
diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c
index 09d7f4b4b354..5240f104a3cd 100644
--- a/arch/arm/mach-sa1100/cerf.c
+++ b/arch/arm/mach-sa1100/cerf.c
@@ -17,6 +17,8 @@
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
19#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
20#include <linux/gpio.h>
21#include <linux/leds.h>
20 22
21#include <mach/hardware.h> 23#include <mach/hardware.h>
22#include <asm/setup.h> 24#include <asm/setup.h>
@@ -43,8 +45,48 @@ static struct platform_device cerfuart2_device = {
43 .resource = cerfuart2_resources, 45 .resource = cerfuart2_resources,
44}; 46};
45 47
48/* LEDs */
49struct gpio_led cerf_gpio_leds[] = {
50 {
51 .name = "cerf:d0",
52 .default_trigger = "heartbeat",
53 .gpio = 0,
54 },
55 {
56 .name = "cerf:d1",
57 .default_trigger = "cpu0",
58 .gpio = 1,
59 },
60 {
61 .name = "cerf:d2",
62 .default_trigger = "default-on",
63 .gpio = 2,
64 },
65 {
66 .name = "cerf:d3",
67 .default_trigger = "default-on",
68 .gpio = 3,
69 },
70
71};
72
73static struct gpio_led_platform_data cerf_gpio_led_info = {
74 .leds = cerf_gpio_leds,
75 .num_leds = ARRAY_SIZE(cerf_gpio_leds),
76};
77
78static struct platform_device cerf_leds = {
79 .name = "leds-gpio",
80 .id = -1,
81 .dev = {
82 .platform_data = &cerf_gpio_led_info,
83 }
84};
85
86
46static struct platform_device *cerf_devices[] __initdata = { 87static struct platform_device *cerf_devices[] __initdata = {
47 &cerfuart2_device, 88 &cerfuart2_device,
89 &cerf_leds,
48}; 90};
49 91
50#ifdef CONFIG_SA1100_CERF_FLASH_32MB 92#ifdef CONFIG_SA1100_CERF_FLASH_32MB
diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c
index 7f86bd911826..fc106aab7c7e 100644
--- a/arch/arm/mach-sa1100/hackkit.c
+++ b/arch/arm/mach-sa1100/hackkit.c
@@ -21,6 +21,10 @@
21#include <linux/serial_core.h> 21#include <linux/serial_core.h>
22#include <linux/mtd/mtd.h> 22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24#include <linux/tty.h>
25#include <linux/gpio.h>
26#include <linux/leds.h>
27#include <linux/platform_device.h>
24 28
25#include <asm/mach-types.h> 29#include <asm/mach-types.h>
26#include <asm/setup.h> 30#include <asm/setup.h>
@@ -183,9 +187,37 @@ static struct flash_platform_data hackkit_flash_data = {
183static struct resource hackkit_flash_resource = 187static struct resource hackkit_flash_resource =
184 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M); 188 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
185 189
190/* LEDs */
191struct gpio_led hackkit_gpio_leds[] = {
192 {
193 .name = "hackkit:red",
194 .default_trigger = "cpu0",
195 .gpio = 22,
196 },
197 {
198 .name = "hackkit:green",
199 .default_trigger = "heartbeat",
200 .gpio = 23,
201 },
202};
203
204static struct gpio_led_platform_data hackkit_gpio_led_info = {
205 .leds = hackkit_gpio_leds,
206 .num_leds = ARRAY_SIZE(hackkit_gpio_leds),
207};
208
209static struct platform_device hackkit_leds = {
210 .name = "leds-gpio",
211 .id = -1,
212 .dev = {
213 .platform_data = &hackkit_gpio_led_info,
214 }
215};
216
186static void __init hackkit_init(void) 217static void __init hackkit_init(void)
187{ 218{
188 sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1); 219 sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
220 platform_device_register(&hackkit_leds);
189} 221}
190 222
191/********************************************************************** 223/**********************************************************************
diff --git a/arch/arm/mach-sa1100/lart.c b/arch/arm/mach-sa1100/lart.c
index b775a0abec0a..b2ce04bf4c9b 100644
--- a/arch/arm/mach-sa1100/lart.c
+++ b/arch/arm/mach-sa1100/lart.c
@@ -5,6 +5,9 @@
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/tty.h> 7#include <linux/tty.h>
8#include <linux/gpio.h>
9#include <linux/leds.h>
10#include <linux/platform_device.h>
8 11
9#include <video/sa1100fb.h> 12#include <video/sa1100fb.h>
10 13
@@ -126,6 +129,27 @@ static struct map_desc lart_io_desc[] __initdata = {
126 } 129 }
127}; 130};
128 131
132/* LEDs */
133struct gpio_led lart_gpio_leds[] = {
134 {
135 .name = "lart:red",
136 .default_trigger = "cpu0",
137 .gpio = 23,
138 },
139};
140
141static struct gpio_led_platform_data lart_gpio_led_info = {
142 .leds = lart_gpio_leds,
143 .num_leds = ARRAY_SIZE(lart_gpio_leds),
144};
145
146static struct platform_device lart_leds = {
147 .name = "leds-gpio",
148 .id = -1,
149 .dev = {
150 .platform_data = &lart_gpio_led_info,
151 }
152};
129static void __init lart_map_io(void) 153static void __init lart_map_io(void)
130{ 154{
131 sa1100_map_io(); 155 sa1100_map_io();
@@ -139,6 +163,8 @@ static void __init lart_map_io(void)
139 GPDR |= GPIO_UART_TXD; 163 GPDR |= GPIO_UART_TXD;
140 GPDR &= ~GPIO_UART_RXD; 164 GPDR &= ~GPIO_UART_RXD;
141 PPAR |= PPAR_UPR; 165 PPAR |= PPAR_UPR;
166
167 platform_device_register(&lart_leds);
142} 168}
143 169
144MACHINE_START(LART, "LART") 170MACHINE_START(LART, "LART")
diff --git a/arch/arm/mach-sa1100/leds-assabet.c b/arch/arm/mach-sa1100/leds-assabet.c
deleted file mode 100644
index 3699176bca94..000000000000
--- a/arch/arm/mach-sa1100/leds-assabet.c
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds-assabet.c
3 *
4 * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
5 *
6 * Original (leds-footbridge.c) by Russell King
7 *
8 * Assabet uses the LEDs as follows:
9 * - Green - toggles state every 50 timer interrupts
10 * - Red - on if system is not idle
11 */
12#include <linux/init.h>
13
14#include <mach/hardware.h>
15#include <asm/leds.h>
16#include <mach/assabet.h>
17
18#include "leds.h"
19
20
21#define LED_STATE_ENABLED 1
22#define LED_STATE_CLAIMED 2
23
24static unsigned int led_state;
25static unsigned int hw_led_state;
26
27#define ASSABET_BCR_LED_MASK (ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED)
28
29void assabet_leds_event(led_event_t evt)
30{
31 unsigned long flags;
32
33 local_irq_save(flags);
34
35 switch (evt) {
36 case led_start:
37 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
38 led_state = LED_STATE_ENABLED;
39 break;
40
41 case led_stop:
42 led_state &= ~LED_STATE_ENABLED;
43 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
44 ASSABET_BCR_frob(ASSABET_BCR_LED_MASK, hw_led_state);
45 break;
46
47 case led_claim:
48 led_state |= LED_STATE_CLAIMED;
49 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
50 break;
51
52 case led_release:
53 led_state &= ~LED_STATE_CLAIMED;
54 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
55 break;
56
57#ifdef CONFIG_LEDS_TIMER
58 case led_timer:
59 if (!(led_state & LED_STATE_CLAIMED))
60 hw_led_state ^= ASSABET_BCR_LED_GREEN;
61 break;
62#endif
63
64#ifdef CONFIG_LEDS_CPU
65 case led_idle_start:
66 if (!(led_state & LED_STATE_CLAIMED))
67 hw_led_state |= ASSABET_BCR_LED_RED;
68 break;
69
70 case led_idle_end:
71 if (!(led_state & LED_STATE_CLAIMED))
72 hw_led_state &= ~ASSABET_BCR_LED_RED;
73 break;
74#endif
75
76 case led_halted:
77 break;
78
79 case led_green_on:
80 if (led_state & LED_STATE_CLAIMED)
81 hw_led_state &= ~ASSABET_BCR_LED_GREEN;
82 break;
83
84 case led_green_off:
85 if (led_state & LED_STATE_CLAIMED)
86 hw_led_state |= ASSABET_BCR_LED_GREEN;
87 break;
88
89 case led_amber_on:
90 break;
91
92 case led_amber_off:
93 break;
94
95 case led_red_on:
96 if (led_state & LED_STATE_CLAIMED)
97 hw_led_state &= ~ASSABET_BCR_LED_RED;
98 break;
99
100 case led_red_off:
101 if (led_state & LED_STATE_CLAIMED)
102 hw_led_state |= ASSABET_BCR_LED_RED;
103 break;
104
105 default:
106 break;
107 }
108
109 if (led_state & LED_STATE_ENABLED)
110 ASSABET_BCR_frob(ASSABET_BCR_LED_MASK, hw_led_state);
111
112 local_irq_restore(flags);
113}
diff --git a/arch/arm/mach-sa1100/leds-badge4.c b/arch/arm/mach-sa1100/leds-badge4.c
deleted file mode 100644
index f99fac3eedb6..000000000000
--- a/arch/arm/mach-sa1100/leds-badge4.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds-badge4.c
3 *
4 * Author: Christopher Hoover <ch@hpl.hp.com>
5 * Copyright (C) 2002 Hewlett-Packard Company
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
13#include <linux/init.h>
14
15#include <mach/hardware.h>
16#include <asm/leds.h>
17
18#include "leds.h"
19
20#define LED_STATE_ENABLED 1
21#define LED_STATE_CLAIMED 2
22
23static unsigned int led_state;
24static unsigned int hw_led_state;
25
26#define LED_RED GPIO_GPIO(7)
27#define LED_GREEN GPIO_GPIO(9)
28#define LED_MASK (LED_RED|LED_GREEN)
29
30#define LED_IDLE LED_GREEN
31#define LED_TIMER LED_RED
32
33void badge4_leds_event(led_event_t evt)
34{
35 unsigned long flags;
36
37 local_irq_save(flags);
38
39 switch (evt) {
40 case led_start:
41 GPDR |= LED_MASK;
42 hw_led_state = LED_MASK;
43 led_state = LED_STATE_ENABLED;
44 break;
45
46 case led_stop:
47 led_state &= ~LED_STATE_ENABLED;
48 break;
49
50 case led_claim:
51 led_state |= LED_STATE_CLAIMED;
52 hw_led_state = LED_MASK;
53 break;
54
55 case led_release:
56 led_state &= ~LED_STATE_CLAIMED;
57 hw_led_state = LED_MASK;
58 break;
59
60#ifdef CONFIG_LEDS_TIMER
61 case led_timer:
62 if (!(led_state & LED_STATE_CLAIMED))
63 hw_led_state ^= LED_TIMER;
64 break;
65#endif
66
67#ifdef CONFIG_LEDS_CPU
68 case led_idle_start:
69 /* LED off when system is idle */
70 if (!(led_state & LED_STATE_CLAIMED))
71 hw_led_state &= ~LED_IDLE;
72 break;
73
74 case led_idle_end:
75 if (!(led_state & LED_STATE_CLAIMED))
76 hw_led_state |= LED_IDLE;
77 break;
78#endif
79
80 case led_red_on:
81 if (!(led_state & LED_STATE_CLAIMED))
82 hw_led_state &= ~LED_RED;
83 break;
84
85 case led_red_off:
86 if (!(led_state & LED_STATE_CLAIMED))
87 hw_led_state |= LED_RED;
88 break;
89
90 case led_green_on:
91 if (!(led_state & LED_STATE_CLAIMED))
92 hw_led_state &= ~LED_GREEN;
93 break;
94
95 case led_green_off:
96 if (!(led_state & LED_STATE_CLAIMED))
97 hw_led_state |= LED_GREEN;
98 break;
99
100 default:
101 break;
102 }
103
104 if (led_state & LED_STATE_ENABLED) {
105 GPSR = hw_led_state;
106 GPCR = hw_led_state ^ LED_MASK;
107 }
108
109 local_irq_restore(flags);
110}
diff --git a/arch/arm/mach-sa1100/leds-cerf.c b/arch/arm/mach-sa1100/leds-cerf.c
deleted file mode 100644
index 30fc3b2bf555..000000000000
--- a/arch/arm/mach-sa1100/leds-cerf.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds-cerf.c
3 *
4 * Author: ???
5 */
6#include <linux/init.h>
7#include <linux/io.h>
8
9#include <mach/hardware.h>
10#include <asm/leds.h>
11
12#include "leds.h"
13
14
15#define LED_STATE_ENABLED 1
16#define LED_STATE_CLAIMED 2
17
18static unsigned int led_state;
19static unsigned int hw_led_state;
20
21#define LED_D0 GPIO_GPIO(0)
22#define LED_D1 GPIO_GPIO(1)
23#define LED_D2 GPIO_GPIO(2)
24#define LED_D3 GPIO_GPIO(3)
25#define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3)
26
27void cerf_leds_event(led_event_t evt)
28{
29 unsigned long flags;
30
31 local_irq_save(flags);
32
33 switch (evt) {
34 case led_start:
35 hw_led_state = LED_MASK;
36 led_state = LED_STATE_ENABLED;
37 break;
38
39 case led_stop:
40 led_state &= ~LED_STATE_ENABLED;
41 break;
42
43 case led_claim:
44 led_state |= LED_STATE_CLAIMED;
45 hw_led_state = LED_MASK;
46 break;
47 case led_release:
48 led_state &= ~LED_STATE_CLAIMED;
49 hw_led_state = LED_MASK;
50 break;
51
52#ifdef CONFIG_LEDS_TIMER
53 case led_timer:
54 if (!(led_state & LED_STATE_CLAIMED))
55 hw_led_state ^= LED_D0;
56 break;
57#endif
58
59#ifdef CONFIG_LEDS_CPU
60 case led_idle_start:
61 if (!(led_state & LED_STATE_CLAIMED))
62 hw_led_state &= ~LED_D1;
63 break;
64
65 case led_idle_end:
66 if (!(led_state & LED_STATE_CLAIMED))
67 hw_led_state |= LED_D1;
68 break;
69#endif
70 case led_green_on:
71 if (!(led_state & LED_STATE_CLAIMED))
72 hw_led_state &= ~LED_D2;
73 break;
74
75 case led_green_off:
76 if (!(led_state & LED_STATE_CLAIMED))
77 hw_led_state |= LED_D2;
78 break;
79
80 case led_amber_on:
81 if (!(led_state & LED_STATE_CLAIMED))
82 hw_led_state &= ~LED_D3;
83 break;
84
85 case led_amber_off:
86 if (!(led_state & LED_STATE_CLAIMED))
87 hw_led_state |= LED_D3;
88 break;
89
90 case led_red_on:
91 if (!(led_state & LED_STATE_CLAIMED))
92 hw_led_state &= ~LED_D1;
93 break;
94
95 case led_red_off:
96 if (!(led_state & LED_STATE_CLAIMED))
97 hw_led_state |= LED_D1;
98 break;
99
100 default:
101 break;
102 }
103
104 if (led_state & LED_STATE_ENABLED) {
105 GPSR = hw_led_state;
106 GPCR = hw_led_state ^ LED_MASK;
107 }
108
109 local_irq_restore(flags);
110}
diff --git a/arch/arm/mach-sa1100/leds-hackkit.c b/arch/arm/mach-sa1100/leds-hackkit.c
deleted file mode 100644
index 6a2352436e62..000000000000
--- a/arch/arm/mach-sa1100/leds-hackkit.c
+++ /dev/null
@@ -1,111 +0,0 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds-hackkit.c
3 *
4 * based on leds-lart.c
5 *
6 * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000
7 * (C) Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>, 2002
8 *
9 * The HackKit has two leds (GPIO 22/23). The red led (gpio 22) is used
10 * as cpu led, the green one is used as timer led.
11 */
12#include <linux/init.h>
13
14#include <mach/hardware.h>
15#include <asm/leds.h>
16
17#include "leds.h"
18
19
20#define LED_STATE_ENABLED 1
21#define LED_STATE_CLAIMED 2
22
23static unsigned int led_state;
24static unsigned int hw_led_state;
25
26#define LED_GREEN GPIO_GPIO23
27#define LED_RED GPIO_GPIO22
28#define LED_MASK (LED_RED | LED_GREEN)
29
30void hackkit_leds_event(led_event_t evt)
31{
32 unsigned long flags;
33
34 local_irq_save(flags);
35
36 switch(evt) {
37 case led_start:
38 /* pin 22/23 are outputs */
39 GPDR |= LED_MASK;
40 hw_led_state = LED_MASK;
41 led_state = LED_STATE_ENABLED;
42 break;
43
44 case led_stop:
45 led_state &= ~LED_STATE_ENABLED;
46 break;
47
48 case led_claim:
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = LED_MASK;
51 break;
52
53 case led_release:
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = LED_MASK;
56 break;
57
58#ifdef CONFIG_LEDS_TIMER
59 case led_timer:
60 if (!(led_state & LED_STATE_CLAIMED))
61 hw_led_state ^= LED_GREEN;
62 break;
63#endif
64
65#ifdef CONFIG_LEDS_CPU
66 case led_idle_start:
67 /* The LART people like the LED to be off when the
68 system is idle... */
69 if (!(led_state & LED_STATE_CLAIMED))
70 hw_led_state &= ~LED_RED;
71 break;
72
73 case led_idle_end:
74 /* ... and on if the system is not idle */
75 if (!(led_state & LED_STATE_CLAIMED))
76 hw_led_state |= LED_RED;
77 break;
78#endif
79
80 case led_red_on:
81 if (led_state & LED_STATE_CLAIMED)
82 hw_led_state &= ~LED_RED;
83 break;
84
85 case led_red_off:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state |= LED_RED;
88 break;
89
90 case led_green_on:
91 if (led_state & LED_STATE_CLAIMED)
92 hw_led_state &= ~LED_GREEN;
93 break;
94
95 case led_green_off:
96 if (led_state & LED_STATE_CLAIMED)
97 hw_led_state |= LED_GREEN;
98 break;
99
100 default:
101 break;
102 }
103
104 /* Now set the GPIO state, or nothing will happen at all */
105 if (led_state & LED_STATE_ENABLED) {
106 GPSR = hw_led_state;
107 GPCR = hw_led_state ^ LED_MASK;
108 }
109
110 local_irq_restore(flags);
111}
diff --git a/arch/arm/mach-sa1100/leds-lart.c b/arch/arm/mach-sa1100/leds-lart.c
deleted file mode 100644
index 50a5b143b460..000000000000
--- a/arch/arm/mach-sa1100/leds-lart.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds-lart.c
3 *
4 * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000
5 *
6 * LART uses the LED as follows:
7 * - GPIO23 is the LED, on if system is not idle
8 * You can use both CONFIG_LEDS_CPU and CONFIG_LEDS_TIMER at the same
9 * time, but in that case the timer events will still dictate the
10 * pace of the LED.
11 */
12#include <linux/init.h>
13#include <linux/io.h>
14
15#include <mach/hardware.h>
16#include <asm/leds.h>
17
18#include "leds.h"
19
20
21#define LED_STATE_ENABLED 1
22#define LED_STATE_CLAIMED 2
23
24static unsigned int led_state;
25static unsigned int hw_led_state;
26
27#define LED_23 GPIO_GPIO23
28#define LED_MASK (LED_23)
29
30void lart_leds_event(led_event_t evt)
31{
32 unsigned long flags;
33
34 local_irq_save(flags);
35
36 switch(evt) {
37 case led_start:
38 /* pin 23 is output pin */
39 GPDR |= LED_23;
40 hw_led_state = LED_MASK;
41 led_state = LED_STATE_ENABLED;
42 break;
43
44 case led_stop:
45 led_state &= ~LED_STATE_ENABLED;
46 break;
47
48 case led_claim:
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = LED_MASK;
51 break;
52
53 case led_release:
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = LED_MASK;
56 break;
57
58#ifdef CONFIG_LEDS_TIMER
59 case led_timer:
60 if (!(led_state & LED_STATE_CLAIMED))
61 hw_led_state ^= LED_23;
62 break;
63#endif
64
65#ifdef CONFIG_LEDS_CPU
66 case led_idle_start:
67 /* The LART people like the LED to be off when the
68 system is idle... */
69 if (!(led_state & LED_STATE_CLAIMED))
70 hw_led_state &= ~LED_23;
71 break;
72
73 case led_idle_end:
74 /* ... and on if the system is not idle */
75 if (!(led_state & LED_STATE_CLAIMED))
76 hw_led_state |= LED_23;
77 break;
78#endif
79
80 case led_red_on:
81 if (led_state & LED_STATE_CLAIMED)
82 hw_led_state &= ~LED_23;
83 break;
84
85 case led_red_off:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state |= LED_23;
88 break;
89
90 default:
91 break;
92 }
93
94 /* Now set the GPIO state, or nothing will happen at all */
95 if (led_state & LED_STATE_ENABLED) {
96 GPSR = hw_led_state;
97 GPCR = hw_led_state ^ LED_MASK;
98 }
99
100 local_irq_restore(flags);
101}
diff --git a/arch/arm/mach-sa1100/leds.c b/arch/arm/mach-sa1100/leds.c
deleted file mode 100644
index 5fe71a0f1053..000000000000
--- a/arch/arm/mach-sa1100/leds.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds.c
3 *
4 * SA1100 LEDs dispatcher
5 *
6 * Copyright (C) 2001 Nicolas Pitre
7 */
8#include <linux/compiler.h>
9#include <linux/init.h>
10
11#include <asm/leds.h>
12#include <asm/mach-types.h>
13
14#include "leds.h"
15
16static int __init
17sa1100_leds_init(void)
18{
19 if (machine_is_assabet())
20 leds_event = assabet_leds_event;
21 if (machine_is_consus())
22 leds_event = consus_leds_event;
23 if (machine_is_badge4())
24 leds_event = badge4_leds_event;
25 if (machine_is_brutus())
26 leds_event = brutus_leds_event;
27 if (machine_is_cerf())
28 leds_event = cerf_leds_event;
29 if (machine_is_flexanet())
30 leds_event = flexanet_leds_event;
31 if (machine_is_graphicsclient())
32 leds_event = graphicsclient_leds_event;
33 if (machine_is_hackkit())
34 leds_event = hackkit_leds_event;
35 if (machine_is_lart())
36 leds_event = lart_leds_event;
37 if (machine_is_pfs168())
38 leds_event = pfs168_leds_event;
39 if (machine_is_graphicsmaster())
40 leds_event = graphicsmaster_leds_event;
41 if (machine_is_adsbitsy())
42 leds_event = adsbitsy_leds_event;
43 if (machine_is_pt_system3())
44 leds_event = system3_leds_event;
45
46 leds_event(led_start);
47 return 0;
48}
49
50core_initcall(sa1100_leds_init);
diff --git a/arch/arm/mach-sa1100/leds.h b/arch/arm/mach-sa1100/leds.h
deleted file mode 100644
index 776b6020f550..000000000000
--- a/arch/arm/mach-sa1100/leds.h
+++ /dev/null
@@ -1,13 +0,0 @@
1extern void assabet_leds_event(led_event_t evt);
2extern void badge4_leds_event(led_event_t evt);
3extern void consus_leds_event(led_event_t evt);
4extern void brutus_leds_event(led_event_t evt);
5extern void cerf_leds_event(led_event_t evt);
6extern void flexanet_leds_event(led_event_t evt);
7extern void graphicsclient_leds_event(led_event_t evt);
8extern void hackkit_leds_event(led_event_t evt);
9extern void lart_leds_event(led_event_t evt);
10extern void pfs168_leds_event(led_event_t evt);
11extern void graphicsmaster_leds_event(led_event_t evt);
12extern void adsbitsy_leds_event(led_event_t evt);
13extern void system3_leds_event(led_event_t evt);
diff --git a/arch/arm/mach-shark/Makefile b/arch/arm/mach-shark/Makefile
index 45be9b04e7ba..29657183c452 100644
--- a/arch/arm/mach-shark/Makefile
+++ b/arch/arm/mach-shark/Makefile
@@ -4,9 +4,7 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := core.o dma.o irq.o pci.o 7obj-y := core.o dma.o irq.o pci.o leds.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
11
12obj-$(CONFIG_LEDS) += leds.o
diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
index 2704bcd869cd..c709979ee751 100644
--- a/arch/arm/mach-shark/core.c
+++ b/arch/arm/mach-shark/core.c
@@ -13,7 +13,6 @@
13 13
14#include <asm/setup.h> 14#include <asm/setup.h>
15#include <asm/mach-types.h> 15#include <asm/mach-types.h>
16#include <asm/leds.h>
17#include <asm/param.h> 16#include <asm/param.h>
18#include <asm/system_misc.h> 17#include <asm/system_misc.h>
19 18
diff --git a/arch/arm/mach-shark/leds.c b/arch/arm/mach-shark/leds.c
index 25609076921f..081c778a10ac 100644
--- a/arch/arm/mach-shark/leds.c
+++ b/arch/arm/mach-shark/leds.c
@@ -1,165 +1,117 @@
1/* 1/*
2 * arch/arm/mach-shark/leds.c
3 * by Alexander Schulz
4 *
5 * derived from:
6 * arch/arm/kernel/leds-footbridge.c
7 * Copyright (C) 1998-1999 Russell King
8 *
9 * DIGITAL Shark LED control routines. 2 * DIGITAL Shark LED control routines.
10 * 3 *
11 * The leds use is as follows: 4 * Driver for the 3 user LEDs found on the Shark
12 * - Green front - toggles state every 50 timer interrupts 5 * Based on Versatile and RealView machine LED code
13 * - Amber front - Unused, this is a dual color led (Amber/Green)
14 * - Amber back - On if system is not idle
15 * 6 *
16 * Changelog: 7 * License terms: GNU General Public License (GPL) version 2
8 * Author: Bryan Wu <bryan.wu@canonical.com>
17 */ 9 */
18#include <linux/kernel.h> 10#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/init.h> 11#include <linux/init.h>
21#include <linux/spinlock.h>
22#include <linux/ioport.h>
23#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/ioport.h>
14#include <linux/slab.h>
15#include <linux/leds.h>
24 16
25#include <asm/leds.h> 17#include <asm/mach-types.h>
26 18
27#define LED_STATE_ENABLED 1 19#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
28#define LED_STATE_CLAIMED 2 20struct shark_led {
21 struct led_classdev cdev;
22 u8 mask;
23};
29 24
30#define SEQUOIA_LED_GREEN (1<<6) 25/*
31#define SEQUOIA_LED_AMBER (1<<5) 26 * The triggers lines up below will only be used if the
32#define SEQUOIA_LED_BACK (1<<7) 27 * LED triggers are compiled in.
28 */
29static const struct {
30 const char *name;
31 const char *trigger;
32} shark_leds[] = {
33 { "shark:amber0", "default-on", }, /* Bit 5 */
34 { "shark:green", "heartbeat", }, /* Bit 6 */
35 { "shark:amber1", "cpu0" }, /* Bit 7 */
36};
37
38static u16 led_reg_read(void)
39{
40 outw(0x09, 0x24);
41 return inw(0x26);
42}
33 43
34static char led_state; 44static void led_reg_write(u16 value)
35static short hw_led_state; 45{
36static short saved_state; 46 outw(0x09, 0x24);
47 outw(value, 0x26);
48}
37 49
38static DEFINE_RAW_SPINLOCK(leds_lock); 50static void shark_led_set(struct led_classdev *cdev,
51 enum led_brightness b)
52{
53 struct shark_led *led = container_of(cdev,
54 struct shark_led, cdev);
55 u16 reg = led_reg_read();
39 56
40short sequoia_read(int addr) { 57 if (b != LED_OFF)
41 outw(addr,0x24); 58 reg |= led->mask;
42 return inw(0x26); 59 else
43} 60 reg &= ~led->mask;
44 61
45void sequoia_write(short value,short addr) { 62 led_reg_write(reg);
46 outw(addr,0x24);
47 outw(value,0x26);
48} 63}
49 64
50static void sequoia_leds_event(led_event_t evt) 65static enum led_brightness shark_led_get(struct led_classdev *cdev)
51{ 66{
52 unsigned long flags; 67 struct shark_led *led = container_of(cdev,
53 68 struct shark_led, cdev);
54 raw_spin_lock_irqsave(&leds_lock, flags); 69 u16 reg = led_reg_read();
55 70
56 hw_led_state = sequoia_read(0x09); 71 return (reg & led->mask) ? LED_FULL : LED_OFF;
72}
57 73
58 switch (evt) { 74static int __init shark_leds_init(void)
59 case led_start: 75{
60 hw_led_state |= SEQUOIA_LED_GREEN; 76 int i;
61 hw_led_state |= SEQUOIA_LED_AMBER; 77 u16 reg;
62#ifdef CONFIG_LEDS_CPU
63 hw_led_state |= SEQUOIA_LED_BACK;
64#else
65 hw_led_state &= ~SEQUOIA_LED_BACK;
66#endif
67 led_state |= LED_STATE_ENABLED;
68 break;
69
70 case led_stop:
71 hw_led_state &= ~SEQUOIA_LED_BACK;
72 hw_led_state |= SEQUOIA_LED_GREEN;
73 hw_led_state |= SEQUOIA_LED_AMBER;
74 led_state &= ~LED_STATE_ENABLED;
75 break;
76
77 case led_claim:
78 led_state |= LED_STATE_CLAIMED;
79 saved_state = hw_led_state;
80 hw_led_state &= ~SEQUOIA_LED_BACK;
81 hw_led_state |= SEQUOIA_LED_GREEN;
82 hw_led_state |= SEQUOIA_LED_AMBER;
83 break;
84
85 case led_release:
86 led_state &= ~LED_STATE_CLAIMED;
87 hw_led_state = saved_state;
88 break;
89
90#ifdef CONFIG_LEDS_TIMER
91 case led_timer:
92 if (!(led_state & LED_STATE_CLAIMED))
93 hw_led_state ^= SEQUOIA_LED_GREEN;
94 break;
95#endif
96 78
97#ifdef CONFIG_LEDS_CPU 79 if (!machine_is_shark())
98 case led_idle_start: 80 return -ENODEV;
99 if (!(led_state & LED_STATE_CLAIMED))
100 hw_led_state &= ~SEQUOIA_LED_BACK;
101 break;
102 81
103 case led_idle_end: 82 for (i = 0; i < ARRAY_SIZE(shark_leds); i++) {
104 if (!(led_state & LED_STATE_CLAIMED)) 83 struct shark_led *led;
105 hw_led_state |= SEQUOIA_LED_BACK;
106 break;
107#endif
108 84
109 case led_green_on: 85 led = kzalloc(sizeof(*led), GFP_KERNEL);
110 if (led_state & LED_STATE_CLAIMED) 86 if (!led)
111 hw_led_state &= ~SEQUOIA_LED_GREEN; 87 break;
112 break;
113
114 case led_green_off:
115 if (led_state & LED_STATE_CLAIMED)
116 hw_led_state |= SEQUOIA_LED_GREEN;
117 break;
118
119 case led_amber_on:
120 if (led_state & LED_STATE_CLAIMED)
121 hw_led_state &= ~SEQUOIA_LED_AMBER;
122 break;
123
124 case led_amber_off:
125 if (led_state & LED_STATE_CLAIMED)
126 hw_led_state |= SEQUOIA_LED_AMBER;
127 break;
128
129 case led_red_on:
130 if (led_state & LED_STATE_CLAIMED)
131 hw_led_state |= SEQUOIA_LED_BACK;
132 break;
133
134 case led_red_off:
135 if (led_state & LED_STATE_CLAIMED)
136 hw_led_state &= ~SEQUOIA_LED_BACK;
137 break;
138
139 default:
140 break;
141 }
142 88
143 if (led_state & LED_STATE_ENABLED) 89 led->cdev.name = shark_leds[i].name;
144 sequoia_write(hw_led_state,0x09); 90 led->cdev.brightness_set = shark_led_set;
91 led->cdev.brightness_get = shark_led_get;
92 led->cdev.default_trigger = shark_leds[i].trigger;
145 93
146 raw_spin_unlock_irqrestore(&leds_lock, flags); 94 /* Count in 5 bits offset */
147} 95 led->mask = BIT(i + 5);
148 96
149static int __init leds_init(void) 97 if (led_classdev_register(NULL, &led->cdev) < 0) {
150{ 98 kfree(led);
151 extern void (*leds_event)(led_event_t); 99 break;
152 short temp; 100 }
153 101 }
154 leds_event = sequoia_leds_event;
155 102
156 /* Make LEDs independent of power-state */ 103 /* Make LEDs independent of power-state */
157 request_region(0x24,4,"sequoia"); 104 request_region(0x24, 4, "led_reg");
158 temp = sequoia_read(0x09); 105 reg = led_reg_read();
159 temp |= 1<<10; 106 reg |= 1 << 10;
160 sequoia_write(temp,0x09); 107 led_reg_write(reg);
161 leds_event(led_start); 108
162 return 0; 109 return 0;
163} 110}
164 111
165__initcall(leds_init); 112/*
113 * Since we may have triggers on any subsystem, defer registration
114 * until after subsystem_init.
115 */
116fs_initcall(shark_leds_init);
117#endif
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index cd8ea3588f93..855ca02581e8 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -37,7 +37,6 @@
37#include <linux/mtd/physmap.h> 37#include <linux/mtd/physmap.h>
38 38
39#include <asm/irq.h> 39#include <asm/irq.h>
40#include <asm/leds.h>
41#include <asm/hardware/arm_timer.h> 40#include <asm/hardware/arm_timer.h>
42#include <asm/hardware/icst.h> 41#include <asm/hardware/icst.h>
43#include <asm/hardware/vic.h> 42#include <asm/hardware/vic.h>
@@ -763,10 +762,6 @@ void __init versatile_init(void)
763 struct amba_device *d = amba_devs[i]; 762 struct amba_device *d = amba_devs[i];
764 amba_device_register(d, &iomem_resource); 763 amba_device_register(d, &iomem_resource);
765 } 764 }
766
767#ifdef CONFIG_LEDS
768 leds_event = versatile_leds_event;
769#endif
770} 765}
771 766
772/* 767/*
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index dd36eba9506c..13910baae228 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -41,9 +41,8 @@ config OMAP_DEBUG_DEVICES
41 For debug cards on TI reference boards. 41 For debug cards on TI reference boards.
42 42
43config OMAP_DEBUG_LEDS 43config OMAP_DEBUG_LEDS
44 bool 44 def_bool y if NEW_LEDS
45 depends on OMAP_DEBUG_DEVICES 45 depends on OMAP_DEBUG_DEVICES
46 default y if LEDS_CLASS
47 46
48config POWER_AVS_OMAP 47config POWER_AVS_OMAP
49 bool "AVS(Adaptive Voltage Scaling) support for OMAP IP versions 1&2" 48 bool "AVS(Adaptive Voltage Scaling) support for OMAP IP versions 1&2"
diff --git a/arch/arm/plat-omap/debug-leds.c b/arch/arm/plat-omap/debug-leds.c
index 39407cbe34c6..24e23f3dd6a8 100644
--- a/arch/arm/plat-omap/debug-leds.c
+++ b/arch/arm/plat-omap/debug-leds.c
@@ -1,279 +1,118 @@
1/* 1/*
2 * linux/arch/arm/plat-omap/debug-leds.c 2 * linux/arch/arm/plat-omap/debug-leds.c
3 * 3 *
4 * Copyright 2011 by Bryan Wu <bryan.wu@canonical.com>
4 * Copyright 2003 by Texas Instruments Incorporated 5 * Copyright 2003 by Texas Instruments Incorporated
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
9 */ 10 */
10#include <linux/gpio.h> 11
12#include <linux/kernel.h>
11#include <linux/init.h> 13#include <linux/init.h>
12#include <linux/platform_device.h> 14#include <linux/platform_device.h>
13#include <linux/leds.h> 15#include <linux/leds.h>
14#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/slab.h>
15 18
16#include <mach/hardware.h> 19#include <mach/hardware.h>
17#include <asm/leds.h>
18#include <asm/mach-types.h> 20#include <asm/mach-types.h>
19 21
20#include <plat/fpga.h> 22#include <plat/fpga.h>
21 23
22
23/* Many OMAP development platforms reuse the same "debug board"; these 24/* Many OMAP development platforms reuse the same "debug board"; these
24 * platforms include H2, H3, H4, and Perseus2. There are 16 LEDs on the 25 * platforms include H2, H3, H4, and Perseus2. There are 16 LEDs on the
25 * debug board (all green), accessed through FPGA registers. 26 * debug board (all green), accessed through FPGA registers.
26 *
27 * The "surfer" expansion board and H2 sample board also have two-color
28 * green+red LEDs (in parallel), used here for timer and idle indicators
29 * in preference to the ones on the debug board, for a "Disco LED" effect.
30 *
31 * This driver exports either the original ARM LED API, the new generic
32 * one, or both.
33 */
34
35static spinlock_t lock;
36static struct h2p2_dbg_fpga __iomem *fpga;
37static u16 led_state, hw_led_state;
38
39
40#ifdef CONFIG_OMAP_DEBUG_LEDS
41#define new_led_api() 1
42#else
43#define new_led_api() 0
44#endif
45
46
47/*-------------------------------------------------------------------------*/
48
49/* original ARM debug LED API:
50 * - timer and idle leds (some boards use non-FPGA leds here);
51 * - up to 4 generic leds, easily accessed in-kernel (any context)
52 */ 27 */
53 28
54#define GPIO_LED_RED 3 29static struct h2p2_dbg_fpga __iomem *fpga;
55#define GPIO_LED_GREEN OMAP_MPUIO(4)
56
57#define LED_STATE_ENABLED 0x01
58#define LED_STATE_CLAIMED 0x02
59#define LED_TIMER_ON 0x04
60
61#define GPIO_IDLE GPIO_LED_GREEN
62#define GPIO_TIMER GPIO_LED_RED
63
64static void h2p2_dbg_leds_event(led_event_t evt)
65{
66 unsigned long flags;
67
68 spin_lock_irqsave(&lock, flags);
69
70 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
71 goto done;
72
73 switch (evt) {
74 case led_start:
75 if (fpga)
76 led_state |= LED_STATE_ENABLED;
77 break;
78
79 case led_stop:
80 case led_halted:
81 /* all leds off during suspend or shutdown */
82
83 if (!(machine_is_omap_perseus2() || machine_is_omap_h4())) {
84 gpio_set_value(GPIO_TIMER, 0);
85 gpio_set_value(GPIO_IDLE, 0);
86 }
87
88 __raw_writew(~0, &fpga->leds);
89 led_state &= ~LED_STATE_ENABLED;
90 goto done;
91
92 case led_claim:
93 led_state |= LED_STATE_CLAIMED;
94 hw_led_state = 0;
95 break;
96
97 case led_release:
98 led_state &= ~LED_STATE_CLAIMED;
99 break;
100
101#ifdef CONFIG_LEDS_TIMER
102 case led_timer:
103 led_state ^= LED_TIMER_ON;
104
105 if (machine_is_omap_perseus2() || machine_is_omap_h4())
106 hw_led_state ^= H2P2_DBG_FPGA_P2_LED_TIMER;
107 else {
108 gpio_set_value(GPIO_TIMER,
109 led_state & LED_TIMER_ON);
110 goto done;
111 }
112
113 break;
114#endif
115
116#ifdef CONFIG_LEDS_CPU
117 /* LED lit iff busy */
118 case led_idle_start:
119 if (machine_is_omap_perseus2() || machine_is_omap_h4())
120 hw_led_state &= ~H2P2_DBG_FPGA_P2_LED_IDLE;
121 else {
122 gpio_set_value(GPIO_IDLE, 1);
123 goto done;
124 }
125
126 break;
127 30
128 case led_idle_end: 31static u16 fpga_led_state;
129 if (machine_is_omap_perseus2() || machine_is_omap_h4())
130 hw_led_state |= H2P2_DBG_FPGA_P2_LED_IDLE;
131 else {
132 gpio_set_value(GPIO_IDLE, 0);
133 goto done;
134 }
135
136 break;
137#endif
138
139 case led_green_on:
140 hw_led_state |= H2P2_DBG_FPGA_LED_GREEN;
141 break;
142 case led_green_off:
143 hw_led_state &= ~H2P2_DBG_FPGA_LED_GREEN;
144 break;
145
146 case led_amber_on:
147 hw_led_state |= H2P2_DBG_FPGA_LED_AMBER;
148 break;
149 case led_amber_off:
150 hw_led_state &= ~H2P2_DBG_FPGA_LED_AMBER;
151 break;
152
153 case led_red_on:
154 hw_led_state |= H2P2_DBG_FPGA_LED_RED;
155 break;
156 case led_red_off:
157 hw_led_state &= ~H2P2_DBG_FPGA_LED_RED;
158 break;
159
160 case led_blue_on:
161 hw_led_state |= H2P2_DBG_FPGA_LED_BLUE;
162 break;
163 case led_blue_off:
164 hw_led_state &= ~H2P2_DBG_FPGA_LED_BLUE;
165 break;
166
167 default:
168 break;
169 }
170
171
172 /*
173 * Actually burn the LEDs
174 */
175 if (led_state & LED_STATE_ENABLED)
176 __raw_writew(~hw_led_state, &fpga->leds);
177
178done:
179 spin_unlock_irqrestore(&lock, flags);
180}
181
182/*-------------------------------------------------------------------------*/
183
184/* "new" LED API
185 * - with syfs access and generic triggering
186 * - not readily accessible to in-kernel drivers
187 */
188 32
189struct dbg_led { 33struct dbg_led {
190 struct led_classdev cdev; 34 struct led_classdev cdev;
191 u16 mask; 35 u16 mask;
192}; 36};
193 37
194static struct dbg_led dbg_leds[] = { 38static const struct {
195 /* REVISIT at least H2 uses different timer & cpu leds... */ 39 const char *name;
196#ifndef CONFIG_LEDS_TIMER 40 const char *trigger;
197 { .mask = 1 << 0, .cdev.name = "d4:green", 41} dbg_leds[] = {
198 .cdev.default_trigger = "heartbeat", }, 42 { "dbg:d4", "heartbeat", },
199#endif 43 { "dbg:d5", "cpu0", },
200#ifndef CONFIG_LEDS_CPU 44 { "dbg:d6", "default-on", },
201 { .mask = 1 << 1, .cdev.name = "d5:green", }, /* !idle */ 45 { "dbg:d7", },
202#endif 46 { "dbg:d8", },
203 { .mask = 1 << 2, .cdev.name = "d6:green", }, 47 { "dbg:d9", },
204 { .mask = 1 << 3, .cdev.name = "d7:green", }, 48 { "dbg:d10", },
205 49 { "dbg:d11", },
206 { .mask = 1 << 4, .cdev.name = "d8:green", }, 50 { "dbg:d12", },
207 { .mask = 1 << 5, .cdev.name = "d9:green", }, 51 { "dbg:d13", },
208 { .mask = 1 << 6, .cdev.name = "d10:green", }, 52 { "dbg:d14", },
209 { .mask = 1 << 7, .cdev.name = "d11:green", }, 53 { "dbg:d15", },
210 54 { "dbg:d16", },
211 { .mask = 1 << 8, .cdev.name = "d12:green", }, 55 { "dbg:d17", },
212 { .mask = 1 << 9, .cdev.name = "d13:green", }, 56 { "dbg:d18", },
213 { .mask = 1 << 10, .cdev.name = "d14:green", }, 57 { "dbg:d19", },
214 { .mask = 1 << 11, .cdev.name = "d15:green", },
215
216#ifndef CONFIG_LEDS
217 { .mask = 1 << 12, .cdev.name = "d16:green", },
218 { .mask = 1 << 13, .cdev.name = "d17:green", },
219 { .mask = 1 << 14, .cdev.name = "d18:green", },
220 { .mask = 1 << 15, .cdev.name = "d19:green", },
221#endif
222}; 58};
223 59
224static void 60/*
225fpga_led_set(struct led_classdev *cdev, enum led_brightness value) 61 * The triggers lines up below will only be used if the
62 * LED triggers are compiled in.
63 */
64static void dbg_led_set(struct led_classdev *cdev,
65 enum led_brightness b)
226{ 66{
227 struct dbg_led *led = container_of(cdev, struct dbg_led, cdev); 67 struct dbg_led *led = container_of(cdev, struct dbg_led, cdev);
228 unsigned long flags; 68 u16 reg;
229 69
230 spin_lock_irqsave(&lock, flags); 70 reg = __raw_readw(&fpga->leds);
231 if (value == LED_OFF) 71 if (b != LED_OFF)
232 hw_led_state &= ~led->mask; 72 reg |= led->mask;
233 else 73 else
234 hw_led_state |= led->mask; 74 reg &= ~led->mask;
235 __raw_writew(~hw_led_state, &fpga->leds); 75 __raw_writew(reg, &fpga->leds);
236 spin_unlock_irqrestore(&lock, flags);
237} 76}
238 77
239static void __init newled_init(struct device *dev) 78static enum led_brightness dbg_led_get(struct led_classdev *cdev)
240{ 79{
241 unsigned i; 80 struct dbg_led *led = container_of(cdev, struct dbg_led, cdev);
242 struct dbg_led *led; 81 u16 reg;
243 int status;
244 82
245 for (i = 0, led = dbg_leds; i < ARRAY_SIZE(dbg_leds); i++, led++) { 83 reg = __raw_readw(&fpga->leds);
246 led->cdev.brightness_set = fpga_led_set; 84 return (reg & led->mask) ? LED_FULL : LED_OFF;
247 status = led_classdev_register(dev, &led->cdev);
248 if (status < 0)
249 break;
250 }
251 return;
252} 85}
253 86
254 87static int fpga_probe(struct platform_device *pdev)
255/*-------------------------------------------------------------------------*/
256
257static int /* __init */ fpga_probe(struct platform_device *pdev)
258{ 88{
259 struct resource *iomem; 89 struct resource *iomem;
260 90 int i;
261 spin_lock_init(&lock);
262 91
263 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 92 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
264 if (!iomem) 93 if (!iomem)
265 return -ENODEV; 94 return -ENODEV;
266 95
267 fpga = ioremap(iomem->start, H2P2_DBG_FPGA_SIZE); 96 fpga = ioremap(iomem->start, H2P2_DBG_FPGA_SIZE);
268 __raw_writew(~0, &fpga->leds); 97 __raw_writew(0xff, &fpga->leds);
98
99 for (i = 0; i < ARRAY_SIZE(dbg_leds); i++) {
100 struct dbg_led *led;
101
102 led = kzalloc(sizeof(*led), GFP_KERNEL);
103 if (!led)
104 break;
269 105
270#ifdef CONFIG_LEDS 106 led->cdev.name = dbg_leds[i].name;
271 leds_event = h2p2_dbg_leds_event; 107 led->cdev.brightness_set = dbg_led_set;
272 leds_event(led_start); 108 led->cdev.brightness_get = dbg_led_get;
273#endif 109 led->cdev.default_trigger = dbg_leds[i].trigger;
110 led->mask = BIT(i);
274 111
275 if (new_led_api()) { 112 if (led_classdev_register(NULL, &led->cdev) < 0) {
276 newled_init(&pdev->dev); 113 kfree(led);
114 break;
115 }
277 } 116 }
278 117
279 return 0; 118 return 0;
@@ -281,13 +120,15 @@ static int /* __init */ fpga_probe(struct platform_device *pdev)
281 120
282static int fpga_suspend_noirq(struct device *dev) 121static int fpga_suspend_noirq(struct device *dev)
283{ 122{
284 __raw_writew(~0, &fpga->leds); 123 fpga_led_state = __raw_readw(&fpga->leds);
124 __raw_writew(0xff, &fpga->leds);
125
285 return 0; 126 return 0;
286} 127}
287 128
288static int fpga_resume_noirq(struct device *dev) 129static int fpga_resume_noirq(struct device *dev)
289{ 130{
290 __raw_writew(~hw_led_state, &fpga->leds); 131 __raw_writew(~fpga_led_state, &fpga->leds);
291 return 0; 132 return 0;
292} 133}
293 134
diff --git a/arch/arm/plat-samsung/time.c b/arch/arm/plat-samsung/time.c
index 4dcb11c3d894..60552e22f22e 100644
--- a/arch/arm/plat-samsung/time.c
+++ b/arch/arm/plat-samsung/time.c
@@ -28,7 +28,6 @@
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30 30
31#include <asm/leds.h>
32#include <asm/mach-types.h> 31#include <asm/mach-types.h>
33 32
34#include <asm/irq.h> 33#include <asm/irq.h>
diff --git a/arch/arm/plat-versatile/Kconfig b/arch/arm/plat-versatile/Kconfig
index 8d5c10a5084d..2a4ae8a6a081 100644
--- a/arch/arm/plat-versatile/Kconfig
+++ b/arch/arm/plat-versatile/Kconfig
@@ -16,8 +16,10 @@ config PLAT_VERSATILE_FPGA_IRQ_NR
16 depends on PLAT_VERSATILE_FPGA_IRQ 16 depends on PLAT_VERSATILE_FPGA_IRQ
17 17
18config PLAT_VERSATILE_LEDS 18config PLAT_VERSATILE_LEDS
19 def_bool y if LEDS_CLASS 19 def_bool y if NEW_LEDS
20 depends on ARCH_REALVIEW || ARCH_VERSATILE 20 depends on ARCH_REALVIEW || ARCH_VERSATILE
21 select LEDS_CLASS
22 select LEDS_TRIGGER
21 23
22config PLAT_VERSATILE_SCHED_CLOCK 24config PLAT_VERSATILE_SCHED_CLOCK
23 def_bool y 25 def_bool y
diff --git a/arch/arm/plat-versatile/leds.c b/arch/arm/plat-versatile/leds.c
index 3169fa555ea6..d2490d00b46c 100644
--- a/arch/arm/plat-versatile/leds.c
+++ b/arch/arm/plat-versatile/leds.c
@@ -37,10 +37,10 @@ static const struct {
37} versatile_leds[] = { 37} versatile_leds[] = {
38 { "versatile:0", "heartbeat", }, 38 { "versatile:0", "heartbeat", },
39 { "versatile:1", "mmc0", }, 39 { "versatile:1", "mmc0", },
40 { "versatile:2", }, 40 { "versatile:2", "cpu0" },
41 { "versatile:3", }, 41 { "versatile:3", "cpu1" },
42 { "versatile:4", }, 42 { "versatile:4", "cpu2" },
43 { "versatile:5", }, 43 { "versatile:5", "cpu3" },
44 { "versatile:6", }, 44 { "versatile:6", },
45 { "versatile:7", }, 45 { "versatile:7", },
46}; 46};