Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / arch / arm / mach-omap1 / leds-osk.c
blobda09f4364979808421b2f482b68a32ea84ec898c
1 /*
2 * linux/arch/arm/mach-omap1/leds-osk.c
4 * LED driver for OSK with optional Mistral QVGA board
5 */
6 #include <linux/gpio.h>
7 #include <linux/init.h>
9 #include <mach/hardware.h>
10 #include <asm/leds.h>
11 #include <asm/system.h>
13 #include "leds.h"
16 #define LED_STATE_ENABLED (1 << 0)
17 #define LED_STATE_CLAIMED (1 << 1)
18 static u8 led_state;
20 #define TIMER_LED (1 << 3) /* Mistral board */
21 #define IDLE_LED (1 << 4) /* Mistral board */
22 static u8 hw_led_state;
25 #ifdef CONFIG_OMAP_OSK_MISTRAL
27 /* For now, all system indicators require the Mistral board, since that
28 * LED can be manipulated without a task context. This LED is either red,
29 * or green, but not both; it can't give the full "disco led" effect.
32 #define GPIO_LED_RED 3
33 #define GPIO_LED_GREEN OMAP_MPUIO(4)
35 static void mistral_setled(void)
37 int red = 0;
38 int green = 0;
40 if (hw_led_state & TIMER_LED)
41 red = 1;
42 else if (hw_led_state & IDLE_LED)
43 green = 1;
44 /* else both sides are disabled */
46 gpio_set_value(GPIO_LED_GREEN, green);
47 gpio_set_value(GPIO_LED_RED, red);
50 #endif
52 void osk_leds_event(led_event_t evt)
54 unsigned long flags;
55 u16 leds;
57 local_irq_save(flags);
59 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
60 goto done;
62 leds = hw_led_state;
63 switch (evt) {
64 case led_start:
65 led_state |= LED_STATE_ENABLED;
66 hw_led_state = 0;
67 leds = ~0;
68 break;
70 case led_halted:
71 case led_stop:
72 led_state &= ~LED_STATE_ENABLED;
73 hw_led_state = 0;
74 break;
76 case led_claim:
77 led_state |= LED_STATE_CLAIMED;
78 hw_led_state = 0;
79 leds = ~0;
80 break;
82 case led_release:
83 led_state &= ~LED_STATE_CLAIMED;
84 hw_led_state = 0;
85 break;
87 #ifdef CONFIG_OMAP_OSK_MISTRAL
89 case led_timer:
90 hw_led_state ^= TIMER_LED;
91 mistral_setled();
92 break;
94 case led_idle_start: /* idle == off */
95 hw_led_state &= ~IDLE_LED;
96 mistral_setled();
97 break;
99 case led_idle_end:
100 hw_led_state |= IDLE_LED;
101 mistral_setled();
102 break;
104 #endif /* CONFIG_OMAP_OSK_MISTRAL */
106 default:
107 break;
110 leds ^= hw_led_state;
112 done:
113 local_irq_restore(flags);