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/module.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/spinlock.h>
24 #include <mach/hardware.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
)
40 spin_lock_irqsave(&leds_lock
, flags
);
44 hw_led_state
= XBUS_LED_RED
| XBUS_LED_GREEN
;
45 #ifndef CONFIG_LEDS_CPU
46 hw_led_state
|= XBUS_LED_AMBER
;
48 led_state
|= LED_STATE_ENABLED
;
52 led_state
&= ~LED_STATE_ENABLED
;
56 led_state
|= LED_STATE_CLAIMED
;
57 hw_led_state
= XBUS_LED_RED
| XBUS_LED_GREEN
| XBUS_LED_AMBER
;
61 led_state
&= ~LED_STATE_CLAIMED
;
62 hw_led_state
= XBUS_LED_RED
| XBUS_LED_GREEN
| XBUS_LED_AMBER
;
65 #ifdef CONFIG_LEDS_TIMER
67 if (!(led_state
& LED_STATE_CLAIMED
))
68 hw_led_state
^= XBUS_LED_GREEN
;
72 #ifdef CONFIG_LEDS_CPU
74 if (!(led_state
& LED_STATE_CLAIMED
))
75 hw_led_state
|= XBUS_LED_AMBER
;
79 if (!(led_state
& LED_STATE_CLAIMED
))
80 hw_led_state
&= ~XBUS_LED_AMBER
;
85 if (!(led_state
& LED_STATE_CLAIMED
))
86 hw_led_state
&= ~XBUS_LED_RED
;
90 if (led_state
& LED_STATE_CLAIMED
)
91 hw_led_state
&= ~XBUS_LED_GREEN
;
95 if (led_state
& LED_STATE_CLAIMED
)
96 hw_led_state
|= XBUS_LED_GREEN
;
100 if (led_state
& LED_STATE_CLAIMED
)
101 hw_led_state
&= ~XBUS_LED_AMBER
;
105 if (led_state
& LED_STATE_CLAIMED
)
106 hw_led_state
|= XBUS_LED_AMBER
;
110 if (led_state
& LED_STATE_CLAIMED
)
111 hw_led_state
&= ~XBUS_LED_RED
;
115 if (led_state
& LED_STATE_CLAIMED
)
116 hw_led_state
|= XBUS_LED_RED
;
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())
132 leds_event
= ebsa285_leds_event
;
134 leds_event(led_start
);
139 __initcall(leds_init
);