Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / arm / mach-sa1100 / leds-hackkit.c
blob2bce137462e46a5b5ffa7753256fc841ed484350
1 /*
2 * linux/arch/arm/mach-sa1100/leds-hackkit.c
4 * based on leds-lart.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/init.h>
14 #include <mach/hardware.h>
15 #include <asm/leds.h>
16 #include <asm/system.h>
18 #include "leds.h"
21 #define LED_STATE_ENABLED 1
22 #define LED_STATE_CLAIMED 2
24 static unsigned int led_state;
25 static unsigned int hw_led_state;
27 #define LED_GREEN GPIO_GPIO23
28 #define LED_RED GPIO_GPIO22
29 #define LED_MASK (LED_RED | LED_GREEN)
31 void hackkit_leds_event(led_event_t evt)
33 unsigned long flags;
35 local_irq_save(flags);
37 switch(evt) {
38 case led_start:
39 /* pin 22/23 are outputs */
40 GPDR |= LED_MASK;
41 hw_led_state = LED_MASK;
42 led_state = LED_STATE_ENABLED;
43 break;
45 case led_stop:
46 led_state &= ~LED_STATE_ENABLED;
47 break;
49 case led_claim:
50 led_state |= LED_STATE_CLAIMED;
51 hw_led_state = LED_MASK;
52 break;
54 case led_release:
55 led_state &= ~LED_STATE_CLAIMED;
56 hw_led_state = LED_MASK;
57 break;
59 #ifdef CONFIG_LEDS_TIMER
60 case led_timer:
61 if (!(led_state & LED_STATE_CLAIMED))
62 hw_led_state ^= LED_GREEN;
63 break;
64 #endif
66 #ifdef CONFIG_LEDS_CPU
67 case led_idle_start:
68 /* The LART people like the LED to be off when the
69 system is idle... */
70 if (!(led_state & LED_STATE_CLAIMED))
71 hw_led_state &= ~LED_RED;
72 break;
74 case led_idle_end:
75 /* ... and on if the system is not idle */
76 if (!(led_state & LED_STATE_CLAIMED))
77 hw_led_state |= LED_RED;
78 break;
79 #endif
81 case led_red_on:
82 if (led_state & LED_STATE_CLAIMED)
83 hw_led_state &= ~LED_RED;
84 break;
86 case led_red_off:
87 if (led_state & LED_STATE_CLAIMED)
88 hw_led_state |= LED_RED;
89 break;
91 case led_green_on:
92 if (led_state & LED_STATE_CLAIMED)
93 hw_led_state &= ~LED_GREEN;
94 break;
96 case led_green_off:
97 if (led_state & LED_STATE_CLAIMED)
98 hw_led_state |= LED_GREEN;
99 break;
101 default:
102 break;
105 /* Now set the GPIO state, or nothing will happen at all */
106 if (led_state & LED_STATE_ENABLED) {
107 GPSR = hw_led_state;
108 GPCR = hw_led_state ^ LED_MASK;
111 local_irq_restore(flags);