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
17 * 02-05-1999 RMK Various cleanups
19 #include <linux/config.h>
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/spinlock.h>
25 #include <asm/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/system.h>
30 #define LED_STATE_ENABLED 1
31 #define LED_STATE_CLAIMED 2
32 static char led_state
;
33 static char hw_led_state
;
35 static DEFINE_SPINLOCK(leds_lock
);
37 static void ebsa285_leds_event(led_event_t evt
)
41 spin_lock_irqsave(&leds_lock
, flags
);
45 hw_led_state
= XBUS_LED_RED
| XBUS_LED_GREEN
;
46 #ifndef CONFIG_LEDS_CPU
47 hw_led_state
|= XBUS_LED_AMBER
;
49 led_state
|= LED_STATE_ENABLED
;
53 led_state
&= ~LED_STATE_ENABLED
;
57 led_state
|= LED_STATE_CLAIMED
;
58 hw_led_state
= XBUS_LED_RED
| XBUS_LED_GREEN
| XBUS_LED_AMBER
;
62 led_state
&= ~LED_STATE_CLAIMED
;
63 hw_led_state
= XBUS_LED_RED
| XBUS_LED_GREEN
| XBUS_LED_AMBER
;
66 #ifdef CONFIG_LEDS_TIMER
68 if (!(led_state
& LED_STATE_CLAIMED
))
69 hw_led_state
^= XBUS_LED_GREEN
;
73 #ifdef CONFIG_LEDS_CPU
75 if (!(led_state
& LED_STATE_CLAIMED
))
76 hw_led_state
|= XBUS_LED_AMBER
;
80 if (!(led_state
& LED_STATE_CLAIMED
))
81 hw_led_state
&= ~XBUS_LED_AMBER
;
86 if (!(led_state
& LED_STATE_CLAIMED
))
87 hw_led_state
&= ~XBUS_LED_RED
;
91 if (led_state
& LED_STATE_CLAIMED
)
92 hw_led_state
&= ~XBUS_LED_GREEN
;
96 if (led_state
& LED_STATE_CLAIMED
)
97 hw_led_state
|= XBUS_LED_GREEN
;
101 if (led_state
& LED_STATE_CLAIMED
)
102 hw_led_state
&= ~XBUS_LED_AMBER
;
106 if (led_state
& LED_STATE_CLAIMED
)
107 hw_led_state
|= XBUS_LED_AMBER
;
111 if (led_state
& LED_STATE_CLAIMED
)
112 hw_led_state
&= ~XBUS_LED_RED
;
116 if (led_state
& LED_STATE_CLAIMED
)
117 hw_led_state
|= XBUS_LED_RED
;
124 if (led_state
& LED_STATE_ENABLED
)
125 *XBUS_LEDS
= hw_led_state
;
127 spin_unlock_irqrestore(&leds_lock
, flags
);
130 static int __init
leds_init(void)
132 if (machine_is_ebsa285() || machine_is_co285())
133 leds_event
= ebsa285_leds_event
;
135 leds_event(led_start
);
140 __initcall(leds_init
);