2 * linux/arch/arm/mach-sa1100/leds-cerf.c
6 #include <linux/init.h>
8 #include <mach/hardware.h>
10 #include <asm/system.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
)
31 local_irq_save(flags
);
35 hw_led_state
= LED_MASK
;
36 led_state
= LED_STATE_ENABLED
;
40 led_state
&= ~LED_STATE_ENABLED
;
44 led_state
|= LED_STATE_CLAIMED
;
45 hw_led_state
= LED_MASK
;
48 led_state
&= ~LED_STATE_CLAIMED
;
49 hw_led_state
= LED_MASK
;
52 #ifdef CONFIG_LEDS_TIMER
54 if (!(led_state
& LED_STATE_CLAIMED
))
55 hw_led_state
^= LED_D0
;
59 #ifdef CONFIG_LEDS_CPU
61 if (!(led_state
& LED_STATE_CLAIMED
))
62 hw_led_state
&= ~LED_D1
;
66 if (!(led_state
& LED_STATE_CLAIMED
))
67 hw_led_state
|= LED_D1
;
71 if (!(led_state
& LED_STATE_CLAIMED
))
72 hw_led_state
&= ~LED_D2
;
76 if (!(led_state
& LED_STATE_CLAIMED
))
77 hw_led_state
|= LED_D2
;
81 if (!(led_state
& LED_STATE_CLAIMED
))
82 hw_led_state
&= ~LED_D3
;
86 if (!(led_state
& LED_STATE_CLAIMED
))
87 hw_led_state
|= LED_D3
;
91 if (!(led_state
& LED_STATE_CLAIMED
))
92 hw_led_state
&= ~LED_D1
;
96 if (!(led_state
& LED_STATE_CLAIMED
))
97 hw_led_state
|= LED_D1
;
104 if (led_state
& LED_STATE_ENABLED
) {
106 GPCR
= hw_led_state
^ LED_MASK
;
109 local_irq_restore(flags
);