Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / arm / mach-sa1100 / leds-hackkit.c
blob2e5fa14aa4ebb67bc9e9696145a8e08398c9a650
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/config.h>
13 #include <linux/init.h>
15 #include <asm/hardware.h>
16 #include <asm/leds.h>
17 #include <asm/system.h>
19 #include "leds.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)
34 unsigned long flags;
36 local_irq_save(flags);
38 switch(evt) {
39 case led_start:
40 /* pin 22/23 are outputs */
41 GPDR |= LED_MASK;
42 hw_led_state = LED_MASK;
43 led_state = LED_STATE_ENABLED;
44 break;
46 case led_stop:
47 led_state &= ~LED_STATE_ENABLED;
48 break;
50 case led_claim:
51 led_state |= LED_STATE_CLAIMED;
52 hw_led_state = LED_MASK;
53 break;
55 case led_release:
56 led_state &= ~LED_STATE_CLAIMED;
57 hw_led_state = LED_MASK;
58 break;
60 #ifdef CONFIG_LEDS_TIMER
61 case led_timer:
62 if (!(led_state & LED_STATE_CLAIMED))
63 hw_led_state ^= LED_GREEN;
64 break;
65 #endif
67 #ifdef CONFIG_LEDS_CPU
68 case led_idle_start:
69 /* The LART people like the LED to be off when the
70 system is idle... */
71 if (!(led_state & LED_STATE_CLAIMED))
72 hw_led_state &= ~LED_RED;
73 break;
75 case led_idle_end:
76 /* ... and on if the system is not idle */
77 if (!(led_state & LED_STATE_CLAIMED))
78 hw_led_state |= LED_RED;
79 break;
80 #endif
82 case led_red_on:
83 if (led_state & LED_STATE_CLAIMED)
84 hw_led_state &= ~LED_RED;
85 break;
87 case led_red_off:
88 if (led_state & LED_STATE_CLAIMED)
89 hw_led_state |= LED_RED;
90 break;
92 case led_green_on:
93 if (led_state & LED_STATE_CLAIMED)
94 hw_led_state &= ~LED_GREEN;
95 break;
97 case led_green_off:
98 if (led_state & LED_STATE_CLAIMED)
99 hw_led_state |= LED_GREEN;
100 break;
102 default:
103 break;
106 /* Now set the GPIO state, or nothing will happen at all */
107 if (led_state & LED_STATE_ENABLED) {
108 GPSR = hw_led_state;
109 GPCR = hw_led_state ^ LED_MASK;
112 local_irq_restore(flags);