diff options
author | Andrew Victor <andrew@sanpeople.com> | 2007-02-05 05:42:07 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-02-08 09:50:56 -0500 |
commit | 9d0412680e6c7b685ee466842047bcfb924d6dc5 (patch) | |
tree | c79300964ef1aca5d24571696f95e76b37c14679 /arch/arm/mach-at91/leds.c | |
parent | a93d48cc6019f84394b31d10c0d830a3b71696be (diff) |
[ARM] 4124/1: Rename mach-at91rm9200 and arch-at91rm9200 directories
Now that Linux includes support for the Atmel AT91SAM9260 and
AT91SAM9261 processors in addition to the original Atmel AT91RM9200
(with support for more AT91 processors pending), the "mach-at91rm9200"
and "arch-at91rm9200" directories should be renamed to indicate their
more generic nature.
The following git commands should be run BEFORE applying this patch:
git-mv arch/arm/mach-at91rm9200 arch/arm/mach-at91
git-mv include/asm-arm/arch-at91rm9200 include/asm-arm/arch-at91
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-at91/leds.c')
-rw-r--r-- | arch/arm/mach-at91/leds.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c new file mode 100644 index 000000000000..1a333730466e --- /dev/null +++ b/arch/arm/mach-at91/leds.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * LED driver for Atmel AT91-based boards. | ||
3 | * | ||
4 | * Copyright (C) SAN People (Pty) Ltd | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | |||
16 | #include <asm/mach-types.h> | ||
17 | #include <asm/leds.h> | ||
18 | #include <asm/arch/board.h> | ||
19 | #include <asm/arch/gpio.h> | ||
20 | |||
21 | |||
22 | static inline void at91_led_on(unsigned int led) | ||
23 | { | ||
24 | at91_set_gpio_value(led, 0); | ||
25 | } | ||
26 | |||
27 | static inline void at91_led_off(unsigned int led) | ||
28 | { | ||
29 | at91_set_gpio_value(led, 1); | ||
30 | } | ||
31 | |||
32 | static inline void at91_led_toggle(unsigned int led) | ||
33 | { | ||
34 | unsigned long is_off = at91_get_gpio_value(led); | ||
35 | if (is_off) | ||
36 | at91_led_on(led); | ||
37 | else | ||
38 | at91_led_off(led); | ||
39 | } | ||
40 | |||
41 | |||
42 | /* | ||
43 | * Handle LED events. | ||
44 | */ | ||
45 | static void at91_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: /* System startup */ | ||
53 | at91_led_on(at91_leds_cpu); | ||
54 | break; | ||
55 | |||
56 | case led_stop: /* System stop / suspend */ | ||
57 | at91_led_off(at91_leds_cpu); | ||
58 | break; | ||
59 | |||
60 | #ifdef CONFIG_LEDS_TIMER | ||
61 | case led_timer: /* Every 50 timer ticks */ | ||
62 | at91_led_toggle(at91_leds_timer); | ||
63 | break; | ||
64 | #endif | ||
65 | |||
66 | #ifdef CONFIG_LEDS_CPU | ||
67 | case led_idle_start: /* Entering idle state */ | ||
68 | at91_led_off(at91_leds_cpu); | ||
69 | break; | ||
70 | |||
71 | case led_idle_end: /* Exit idle state */ | ||
72 | at91_led_on(at91_leds_cpu); | ||
73 | break; | ||
74 | #endif | ||
75 | |||
76 | default: | ||
77 | break; | ||
78 | } | ||
79 | |||
80 | local_irq_restore(flags); | ||
81 | } | ||
82 | |||
83 | |||
84 | static int __init leds_init(void) | ||
85 | { | ||
86 | if (!at91_leds_timer || !at91_leds_cpu) | ||
87 | return -ENODEV; | ||
88 | |||
89 | /* Enable PIO to access the LEDs */ | ||
90 | at91_set_gpio_output(at91_leds_timer, 1); | ||
91 | at91_set_gpio_output(at91_leds_cpu, 1); | ||
92 | |||
93 | leds_event = at91_leds_event; | ||
94 | |||
95 | leds_event(led_start); | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | __initcall(leds_init); | ||