Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-2.6/mini2440.git] / arch / arm / mach-sa1100 / leds-cerf.c
blob259b48e0be895b5b3c6ffcf50178b56c02a0b57f
1 /*
2 * linux/arch/arm/mach-sa1100/leds-cerf.c
4 * Author: ???
5 */
6 #include <linux/init.h>
8 #include <mach/hardware.h>
9 #include <asm/leds.h>
10 #include <asm/system.h>
12 #include "leds.h"
15 #define LED_STATE_ENABLED 1
16 #define LED_STATE_CLAIMED 2
18 static unsigned int led_state;
19 static unsigned int hw_led_state;
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)
27 void cerf_leds_event(led_event_t evt)
29 unsigned long flags;
31 local_irq_save(flags);
33 switch (evt) {
34 case led_start:
35 hw_led_state = LED_MASK;
36 led_state = LED_STATE_ENABLED;
37 break;
39 case led_stop:
40 led_state &= ~LED_STATE_ENABLED;
41 break;
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;
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
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;
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;
75 case led_green_off:
76 if (!(led_state & LED_STATE_CLAIMED))
77 hw_led_state |= LED_D2;
78 break;
80 case led_amber_on:
81 if (!(led_state & LED_STATE_CLAIMED))
82 hw_led_state &= ~LED_D3;
83 break;
85 case led_amber_off:
86 if (!(led_state & LED_STATE_CLAIMED))
87 hw_led_state |= LED_D3;
88 break;
90 case led_red_on:
91 if (!(led_state & LED_STATE_CLAIMED))
92 hw_led_state &= ~LED_D1;
93 break;
95 case led_red_off:
96 if (!(led_state & LED_STATE_CLAIMED))
97 hw_led_state |= LED_D1;
98 break;
100 default:
101 break;
104 if (led_state & LED_STATE_ENABLED) {
105 GPSR = hw_led_state;
106 GPCR = hw_led_state ^ LED_MASK;
109 local_irq_restore(flags);