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 #ifdef CONFIG_SA1100_CERF_CPLD
24 #define LED_D0 GPIO_GPIO(0)
25 #define LED_D1 GPIO_GPIO(0)
26 #define LED_D2 GPIO_GPIO(0)
27 #define LED_D3 GPIO_GPIO(0)
28 #define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3)
32 #define LED_D0 GPIO_GPIO(0)
33 #define LED_D1 GPIO_GPIO(1)
34 #define LED_D2 GPIO_GPIO(2)
35 #define LED_D3 GPIO_GPIO(3)
36 #define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3)
40 void cerf_leds_event(led_event_t evt)
44 local_irq_save(flags);
48 hw_led_state = LED_MASK;
49 led_state = LED_STATE_ENABLED;
53 led_state &= ~LED_STATE_ENABLED;
57 led_state |= LED_STATE_CLAIMED;
58 hw_led_state = LED_MASK;
61 led_state &= ~LED_STATE_CLAIMED;
62 hw_led_state = LED_MASK;
65 #ifdef CONFIG_LEDS_TIMER
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state ^= LED_D0;
72 #ifdef CONFIG_LEDS_CPU
74 if (!(led_state & LED_STATE_CLAIMED))
75 hw_led_state &= ~LED_D1;
79 if (!(led_state & LED_STATE_CLAIMED))
80 hw_led_state |= LED_D1;
84 if (!(led_state & LED_STATE_CLAIMED))
85 hw_led_state &= ~LED_D2;
89 if (!(led_state & LED_STATE_CLAIMED))
90 hw_led_state |= LED_D2;
94 if (!(led_state & LED_STATE_CLAIMED))
95 hw_led_state &= ~LED_D3;
99 if (!(led_state & LED_STATE_CLAIMED))
100 hw_led_state |= LED_D3;
104 if (!(led_state & LED_STATE_CLAIMED))
105 hw_led_state &= ~LED_D1;
109 if (!(led_state & LED_STATE_CLAIMED))
110 hw_led_state |= LED_D1;
117 if (led_state & LED_STATE_ENABLED) {
119 GPCR = hw_led_state ^ LED_MASK;
122 local_irq_restore(flags);