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