generic: add __FINITDATA
[wrt350n-kernel.git] / arch / arm / mach-footbridge / ebsa285-leds.c
bloba64e22226515ba88ec289e00648c448b017f5fe8
1 /*
2 * linux/arch/arm/mach-footbridge/ebsa285-leds.c
4 * Copyright (C) 1998-1999 Russell King
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.
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
16 * Changelog:
17 * 02-05-1999 RMK Various cleanups
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/spinlock.h>
24 #include <asm/hardware.h>
25 #include <asm/leds.h>
26 #include <asm/mach-types.h>
27 #include <asm/system.h>
29 #define LED_STATE_ENABLED 1
30 #define LED_STATE_CLAIMED 2
31 static char led_state;
32 static char hw_led_state;
34 static DEFINE_SPINLOCK(leds_lock);
36 static void ebsa285_leds_event(led_event_t evt)
38 unsigned long flags;
40 spin_lock_irqsave(&leds_lock, flags);
42 switch (evt) {
43 case led_start:
44 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN;
45 #ifndef CONFIG_LEDS_CPU
46 hw_led_state |= XBUS_LED_AMBER;
47 #endif
48 led_state |= LED_STATE_ENABLED;
49 break;
51 case led_stop:
52 led_state &= ~LED_STATE_ENABLED;
53 break;
55 case led_claim:
56 led_state |= LED_STATE_CLAIMED;
57 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
58 break;
60 case led_release:
61 led_state &= ~LED_STATE_CLAIMED;
62 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
63 break;
65 #ifdef CONFIG_LEDS_TIMER
66 case led_timer:
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state ^= XBUS_LED_GREEN;
69 break;
70 #endif
72 #ifdef CONFIG_LEDS_CPU
73 case led_idle_start:
74 if (!(led_state & LED_STATE_CLAIMED))
75 hw_led_state |= XBUS_LED_AMBER;
76 break;
78 case led_idle_end:
79 if (!(led_state & LED_STATE_CLAIMED))
80 hw_led_state &= ~XBUS_LED_AMBER;
81 break;
82 #endif
84 case led_halted:
85 if (!(led_state & LED_STATE_CLAIMED))
86 hw_led_state &= ~XBUS_LED_RED;
87 break;
89 case led_green_on:
90 if (led_state & LED_STATE_CLAIMED)
91 hw_led_state &= ~XBUS_LED_GREEN;
92 break;
94 case led_green_off:
95 if (led_state & LED_STATE_CLAIMED)
96 hw_led_state |= XBUS_LED_GREEN;
97 break;
99 case led_amber_on:
100 if (led_state & LED_STATE_CLAIMED)
101 hw_led_state &= ~XBUS_LED_AMBER;
102 break;
104 case led_amber_off:
105 if (led_state & LED_STATE_CLAIMED)
106 hw_led_state |= XBUS_LED_AMBER;
107 break;
109 case led_red_on:
110 if (led_state & LED_STATE_CLAIMED)
111 hw_led_state &= ~XBUS_LED_RED;
112 break;
114 case led_red_off:
115 if (led_state & LED_STATE_CLAIMED)
116 hw_led_state |= XBUS_LED_RED;
117 break;
119 default:
120 break;
123 if (led_state & LED_STATE_ENABLED)
124 *XBUS_LEDS = hw_led_state;
126 spin_unlock_irqrestore(&leds_lock, flags);
129 static int __init leds_init(void)
131 if (machine_is_ebsa285() || machine_is_co285())
132 leds_event = ebsa285_leds_event;
134 leds_event(led_start);
136 return 0;
139 __initcall(leds_init);