v2.4.8 -> v2.4.8.1
[opensuse:kernel.git] / arch / arm / mach-sa1100 / leds-brutus.c
1 /*
2  * linux/arch/arm/mach-sa1100/leds-brutus.c
3  *
4  * Copyright (C) 2000 Nicolas Pitre
5  *
6  * Brutus uses the LEDs as follows:
7  *   - D3 (Green, GPIO9) - toggles state every 50 timer interrupts
8  *   - D17 (Red, GPIO20) - on if system is not idle
9  *   - D4 (Green, GPIO8) - misc function
10  */
11 #include <linux/config.h>
12 #include <linux/init.h>
13
14 #include <asm/hardware.h>
15 #include <asm/leds.h>
16 #include <asm/system.h>
17
18 #include "leds.h"
19
20
21 #define LED_STATE_ENABLED       1
22 #define LED_STATE_CLAIMED       2
23
24 static unsigned int led_state;
25 static unsigned int hw_led_state;
26
27 #define LED_D3          GPIO_GPIO(9)
28 #define LED_D4          GPIO_GPIO(8)
29 #define LED_D17         GPIO_GPIO(20)
30 #define LED_MASK        (LED_D3|LED_D4|LED_D17)
31
32 void brutus_leds_event(led_event_t evt)
33 {
34         unsigned long flags;
35
36         local_irq_save(flags);
37
38         switch (evt) {
39         case led_start:
40                 hw_led_state = LED_MASK;
41                 led_state = LED_STATE_ENABLED;
42                 break;
43
44         case led_stop:
45                 led_state &= ~LED_STATE_ENABLED;
46                 break;
47
48         case led_claim:
49                 led_state |= LED_STATE_CLAIMED;
50                 hw_led_state = LED_MASK;
51                 break;
52
53         case led_release:
54                 led_state &= ~LED_STATE_CLAIMED;
55                 hw_led_state = LED_MASK;
56                 break;
57
58 #ifdef CONFIG_LEDS_TIMER
59         case led_timer:
60                 if (!(led_state & LED_STATE_CLAIMED))
61                         hw_led_state ^= LED_D3;
62                 break;
63 #endif
64
65 #ifdef CONFIG_LEDS_CPU
66         case led_idle_start:
67                 if (!(led_state & LED_STATE_CLAIMED))
68                         hw_led_state |= LED_D17;
69                 break;
70
71         case led_idle_end:
72                 if (!(led_state & LED_STATE_CLAIMED))
73                         hw_led_state &= ~LED_D17;
74                 break;
75 #endif
76
77         case led_green_on:
78                 hw_led_state &= ~LED_D4;
79                 break;
80
81         case led_green_off:
82                 hw_led_state |= LED_D4;
83                 break;
84
85         case led_amber_on:
86                 break;
87
88         case led_amber_off:
89                 break;
90
91         case led_red_on:
92                 if (led_state & LED_STATE_CLAIMED)
93                         hw_led_state &= ~LED_D17;
94                 break;
95
96         case led_red_off:
97                 if (led_state & LED_STATE_CLAIMED)
98                         hw_led_state |= LED_D17;
99                 break;
100
101         default:
102                 break;
103         }
104
105         if  (led_state & LED_STATE_ENABLED) {
106                 GPSR = hw_led_state;
107                 GPCR = hw_led_state ^ LED_MASK;
108         }
109
110         local_irq_restore(flags);
111 }