2 * linux/arch/arm/mach-sa1100/leds-lart.c
4 * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000
6 * LART uses the LED as follows:
7 * - GPIO23 is the LED, on if system is not idle
8 * You can use both CONFIG_LEDS_CPU and CONFIG_LEDS_TIMER at the same
9 * time, but in that case the timer events will still dictate the
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_23 GPIO_GPIO23
29 #define LED_MASK (LED_23)
31 void lart_leds_event(led_event_t evt)
35 local_irq_save(flags);
39 /* pin 23 is output pin */
41 hw_led_state = LED_MASK;
42 led_state = LED_STATE_ENABLED;
46 led_state &= ~LED_STATE_ENABLED;
50 led_state |= LED_STATE_CLAIMED;
51 hw_led_state = LED_MASK;
55 led_state &= ~LED_STATE_CLAIMED;
56 hw_led_state = LED_MASK;
59 #ifdef CONFIG_LEDS_TIMER
61 if (!(led_state & LED_STATE_CLAIMED))
62 hw_led_state ^= LED_23;
66 #ifdef CONFIG_LEDS_CPU
68 /* The LART people like the LED to be off when the
70 if (!(led_state & LED_STATE_CLAIMED))
71 hw_led_state &= ~LED_23;
75 /* ... and on if the system is not idle */
76 if (!(led_state & LED_STATE_CLAIMED))
77 hw_led_state |= LED_23;
82 if (led_state & LED_STATE_CLAIMED)
83 hw_led_state &= ~LED_23;
87 if (led_state & LED_STATE_CLAIMED)
88 hw_led_state |= LED_23;
95 /* Now set the GPIO state, or nothing will happen at all */
96 if (led_state & LED_STATE_ENABLED) {
98 GPCR = hw_led_state ^ LED_MASK;
101 local_irq_restore(flags);