aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/leds-cerf.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/leds-cerf.c')
-rw-r--r--arch/arm/mach-sa1100/leds-cerf.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/arch/arm/mach-sa1100/leds-cerf.c b/arch/arm/mach-sa1100/leds-cerf.c
new file mode 100644
index 000000000000..f6635a2d0e83
--- /dev/null
+++ b/arch/arm/mach-sa1100/leds-cerf.c
@@ -0,0 +1,111 @@
1/*
2 * linux/arch/arm/mach-sa1100/leds-cerf.c
3 *
4 * Author: ???
5 */
6#include <linux/config.h>
7#include <linux/init.h>
8
9#include <asm/hardware.h>
10#include <asm/leds.h>
11#include <asm/system.h>
12
13#include "leds.h"
14
15
16#define LED_STATE_ENABLED 1
17#define LED_STATE_CLAIMED 2
18
19static unsigned int led_state;
20static unsigned int hw_led_state;
21
22#define LED_D0 GPIO_GPIO(0)
23#define LED_D1 GPIO_GPIO(1)
24#define LED_D2 GPIO_GPIO(2)
25#define LED_D3 GPIO_GPIO(3)
26#define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3)
27
28void cerf_leds_event(led_event_t evt)
29{
30 unsigned long flags;
31
32 local_irq_save(flags);
33
34 switch (evt) {
35 case led_start:
36 hw_led_state = LED_MASK;
37 led_state = LED_STATE_ENABLED;
38 break;
39
40 case led_stop:
41 led_state &= ~LED_STATE_ENABLED;
42 break;
43
44 case led_claim:
45 led_state |= LED_STATE_CLAIMED;
46 hw_led_state = LED_MASK;
47 break;
48 case led_release:
49 led_state &= ~LED_STATE_CLAIMED;
50 hw_led_state = LED_MASK;
51 break;
52
53#ifdef CONFIG_LEDS_TIMER
54 case led_timer:
55 if (!(led_state & LED_STATE_CLAIMED))
56 hw_led_state ^= LED_D0;
57 break;
58#endif
59
60#ifdef CONFIG_LEDS_CPU
61 case led_idle_start:
62 if (!(led_state & LED_STATE_CLAIMED))
63 hw_led_state &= ~LED_D1;
64 break;
65
66 case led_idle_end:
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state |= LED_D1;
69 break;
70#endif
71 case led_green_on:
72 if (!(led_state & LED_STATE_CLAIMED))
73 hw_led_state &= ~LED_D2;
74 break;
75
76 case led_green_off:
77 if (!(led_state & LED_STATE_CLAIMED))
78 hw_led_state |= LED_D2;
79 break;
80
81 case led_amber_on:
82 if (!(led_state & LED_STATE_CLAIMED))
83 hw_led_state &= ~LED_D3;
84 break;
85
86 case led_amber_off:
87 if (!(led_state & LED_STATE_CLAIMED))
88 hw_led_state |= LED_D3;
89 break;
90
91 case led_red_on:
92 if (!(led_state & LED_STATE_CLAIMED))
93 hw_led_state &= ~LED_D1;
94 break;
95
96 case led_red_off:
97 if (!(led_state & LED_STATE_CLAIMED))
98 hw_led_state |= LED_D1;
99 break;
100
101 default:
102 break;
103 }
104
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}