2 * linux/arch/arm/mach-sa1100/leds-cerf.c
6 #include <linux/config.h>
7 #include <linux/init.h>
9 #include <asm/hardware.h>
11 #include <asm/system.h>
16 #define LED_STATE_ENABLED 1
17 #define LED_STATE_CLAIMED 2
19 static unsigned int led_state
;
20 static unsigned int hw_led_state
;
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)
28 void cerf_leds_event(led_event_t evt
)
32 local_irq_save(flags
);
36 hw_led_state
= LED_MASK
;
37 led_state
= LED_STATE_ENABLED
;
41 led_state
&= ~LED_STATE_ENABLED
;
45 led_state
|= LED_STATE_CLAIMED
;
46 hw_led_state
= LED_MASK
;
49 led_state
&= ~LED_STATE_CLAIMED
;
50 hw_led_state
= LED_MASK
;
53 #ifdef CONFIG_LEDS_TIMER
55 if (!(led_state
& LED_STATE_CLAIMED
))
56 hw_led_state
^= LED_D0
;
60 #ifdef CONFIG_LEDS_CPU
62 if (!(led_state
& LED_STATE_CLAIMED
))
63 hw_led_state
&= ~LED_D1
;
67 if (!(led_state
& LED_STATE_CLAIMED
))
68 hw_led_state
|= LED_D1
;
72 if (!(led_state
& LED_STATE_CLAIMED
))
73 hw_led_state
&= ~LED_D2
;
77 if (!(led_state
& LED_STATE_CLAIMED
))
78 hw_led_state
|= LED_D2
;
82 if (!(led_state
& LED_STATE_CLAIMED
))
83 hw_led_state
&= ~LED_D3
;
87 if (!(led_state
& LED_STATE_CLAIMED
))
88 hw_led_state
|= LED_D3
;
92 if (!(led_state
& LED_STATE_CLAIMED
))
93 hw_led_state
&= ~LED_D1
;
97 if (!(led_state
& LED_STATE_CLAIMED
))
98 hw_led_state
|= LED_D1
;
105 if (led_state
& LED_STATE_ENABLED
) {
107 GPCR
= hw_led_state
^ LED_MASK
;
110 local_irq_restore(flags
);