[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / arm / mach-sa1100 / leds-cerf.c
blobf6635a2d0e8303de319e169e6bbf5b88ccb7362a
1 /*
2 * linux/arch/arm/mach-sa1100/leds-cerf.c
4 * Author: ???
5 */
6 #include <linux/config.h>
7 #include <linux/init.h>
9 #include <asm/hardware.h>
10 #include <asm/leds.h>
11 #include <asm/system.h>
13 #include "leds.h"
16 #define LED_STATE_ENABLED 1
17 #define LED_STATE_CLAIMED 2
19 static unsigned int led_state;
20 static unsigned int hw_led_state;
22 #define LED_D0 GPIO_GPIO(0)
23 #define LED_D1 GPIO_GPIO(1)
24 #define LED_D2 GPIO_GPIO(2)
25 #define LED_D3 GPIO_GPIO(3)
26 #define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3)
28 void cerf_leds_event(led_event_t evt)
30 unsigned long flags;
32 local_irq_save(flags);
34 switch (evt) {
35 case led_start:
36 hw_led_state = LED_MASK;
37 led_state = LED_STATE_ENABLED;
38 break;
40 case led_stop:
41 led_state &= ~LED_STATE_ENABLED;
42 break;
44 case led_claim:
45 led_state |= LED_STATE_CLAIMED;
46 hw_led_state = LED_MASK;
47 break;
48 case led_release:
49 led_state &= ~LED_STATE_CLAIMED;
50 hw_led_state = LED_MASK;
51 break;
53 #ifdef CONFIG_LEDS_TIMER
54 case led_timer:
55 if (!(led_state & LED_STATE_CLAIMED))
56 hw_led_state ^= LED_D0;
57 break;
58 #endif
60 #ifdef CONFIG_LEDS_CPU
61 case led_idle_start:
62 if (!(led_state & LED_STATE_CLAIMED))
63 hw_led_state &= ~LED_D1;
64 break;
66 case led_idle_end:
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state |= LED_D1;
69 break;
70 #endif
71 case led_green_on:
72 if (!(led_state & LED_STATE_CLAIMED))
73 hw_led_state &= ~LED_D2;
74 break;
76 case led_green_off:
77 if (!(led_state & LED_STATE_CLAIMED))
78 hw_led_state |= LED_D2;
79 break;
81 case led_amber_on:
82 if (!(led_state & LED_STATE_CLAIMED))
83 hw_led_state &= ~LED_D3;
84 break;
86 case led_amber_off:
87 if (!(led_state & LED_STATE_CLAIMED))
88 hw_led_state |= LED_D3;
89 break;
91 case led_red_on:
92 if (!(led_state & LED_STATE_CLAIMED))
93 hw_led_state &= ~LED_D1;
94 break;
96 case led_red_off:
97 if (!(led_state & LED_STATE_CLAIMED))
98 hw_led_state |= LED_D1;
99 break;
101 default:
102 break;
105 if (led_state & LED_STATE_ENABLED) {
106 GPSR = hw_led_state;
107 GPCR = hw_led_state ^ LED_MASK;
110 local_irq_restore(flags);