be2net: Add description about various RSS hash types
[cascardo/linux.git] / arch / arm / mach-footbridge / ebsa285-leds.c
1 /*
2  *  linux/arch/arm/mach-footbridge/ebsa285-leds.c
3  *
4  *  Copyright (C) 1998-1999 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  * EBSA-285 control routines.
10  *
11  * The EBSA-285 uses the leds as follows:
12  *  - Green - toggles state every 50 timer interrupts
13  *  - Amber - On if system is not idle
14  *  - Red   - currently unused
15  *
16  * Changelog:
17  *   02-05-1999 RMK     Various cleanups
18  */
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/spinlock.h>
23
24 #include <mach/hardware.h>
25 #include <asm/leds.h>
26 #include <asm/mach-types.h>
27
28 #define LED_STATE_ENABLED       1
29 #define LED_STATE_CLAIMED       2
30 static char led_state;
31 static char hw_led_state;
32
33 static DEFINE_SPINLOCK(leds_lock);
34
35 static void ebsa285_leds_event(led_event_t evt)
36 {
37         unsigned long flags;
38
39         spin_lock_irqsave(&leds_lock, flags);
40
41         switch (evt) {
42         case led_start:
43                 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN;
44 #ifndef CONFIG_LEDS_CPU
45                 hw_led_state |= XBUS_LED_AMBER;
46 #endif
47                 led_state |= LED_STATE_ENABLED;
48                 break;
49
50         case led_stop:
51                 led_state &= ~LED_STATE_ENABLED;
52                 break;
53
54         case led_claim:
55                 led_state |= LED_STATE_CLAIMED;
56                 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
57                 break;
58
59         case led_release:
60                 led_state &= ~LED_STATE_CLAIMED;
61                 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
62                 break;
63
64 #ifdef CONFIG_LEDS_TIMER
65         case led_timer:
66                 if (!(led_state & LED_STATE_CLAIMED))
67                         hw_led_state ^= XBUS_LED_GREEN;
68                 break;
69 #endif
70
71 #ifdef CONFIG_LEDS_CPU
72         case led_idle_start:
73                 if (!(led_state & LED_STATE_CLAIMED))
74                         hw_led_state |= XBUS_LED_AMBER;
75                 break;
76
77         case led_idle_end:
78                 if (!(led_state & LED_STATE_CLAIMED))
79                         hw_led_state &= ~XBUS_LED_AMBER;
80                 break;
81 #endif
82
83         case led_halted:
84                 if (!(led_state & LED_STATE_CLAIMED))
85                         hw_led_state &= ~XBUS_LED_RED;
86                 break;
87
88         case led_green_on:
89                 if (led_state & LED_STATE_CLAIMED)
90                         hw_led_state &= ~XBUS_LED_GREEN;
91                 break;
92
93         case led_green_off:
94                 if (led_state & LED_STATE_CLAIMED)
95                         hw_led_state |= XBUS_LED_GREEN;
96                 break;
97
98         case led_amber_on:
99                 if (led_state & LED_STATE_CLAIMED)
100                         hw_led_state &= ~XBUS_LED_AMBER;
101                 break;
102
103         case led_amber_off:
104                 if (led_state & LED_STATE_CLAIMED)
105                         hw_led_state |= XBUS_LED_AMBER;
106                 break;
107
108         case led_red_on:
109                 if (led_state & LED_STATE_CLAIMED)
110                         hw_led_state &= ~XBUS_LED_RED;
111                 break;
112
113         case led_red_off:
114                 if (led_state & LED_STATE_CLAIMED)
115                         hw_led_state |= XBUS_LED_RED;
116                 break;
117
118         default:
119                 break;
120         }
121
122         if  (led_state & LED_STATE_ENABLED)
123                 *XBUS_LEDS = hw_led_state;
124
125         spin_unlock_irqrestore(&leds_lock, flags);
126 }
127
128 static int __init leds_init(void)
129 {
130         if (machine_is_ebsa285())
131                 leds_event = ebsa285_leds_event;
132
133         leds_event(led_start);
134
135         return 0;
136 }
137
138 __initcall(leds_init);