2 * linux/arch/arm/mach-sa1100/leds-hackkit.c
6 * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000
7 * (C) Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>, 2002
9 * The HackKit has two leds (GPIO 22/23). The red led (gpio 22) is used
10 * as cpu led, the green one is used as timer led.
12 #include <linux/config.h>
13 #include <linux/init.h>
15 #include <asm/hardware.h>
17 #include <asm/system.h>
22 #define LED_STATE_ENABLED 1
23 #define LED_STATE_CLAIMED 2
25 static unsigned int led_state
;
26 static unsigned int hw_led_state
;
28 #define LED_GREEN GPIO_GPIO23
29 #define LED_RED GPIO_GPIO22
30 #define LED_MASK (LED_RED | LED_GREEN)
32 void hackkit_leds_event(led_event_t evt
)
36 local_irq_save(flags
);
40 /* pin 22/23 are outputs */
42 hw_led_state
= LED_MASK
;
43 led_state
= LED_STATE_ENABLED
;
47 led_state
&= ~LED_STATE_ENABLED
;
51 led_state
|= LED_STATE_CLAIMED
;
52 hw_led_state
= LED_MASK
;
56 led_state
&= ~LED_STATE_CLAIMED
;
57 hw_led_state
= LED_MASK
;
60 #ifdef CONFIG_LEDS_TIMER
62 if (!(led_state
& LED_STATE_CLAIMED
))
63 hw_led_state
^= LED_GREEN
;
67 #ifdef CONFIG_LEDS_CPU
69 /* The LART people like the LED to be off when the
71 if (!(led_state
& LED_STATE_CLAIMED
))
72 hw_led_state
&= ~LED_RED
;
76 /* ... and on if the system is not idle */
77 if (!(led_state
& LED_STATE_CLAIMED
))
78 hw_led_state
|= LED_RED
;
83 if (led_state
& LED_STATE_CLAIMED
)
84 hw_led_state
&= ~LED_RED
;
88 if (led_state
& LED_STATE_CLAIMED
)
89 hw_led_state
|= LED_RED
;
93 if (led_state
& LED_STATE_CLAIMED
)
94 hw_led_state
&= ~LED_GREEN
;
98 if (led_state
& LED_STATE_CLAIMED
)
99 hw_led_state
|= LED_GREEN
;
106 /* Now set the GPIO state, or nothing will happen at all */
107 if (led_state
& LED_STATE_ENABLED
) {
109 GPCR
= hw_led_state
^ LED_MASK
;
112 local_irq_restore(flags
);