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>
28 #define LED_STATE_ENABLED 1
29 #define LED_STATE_CLAIMED 2
30 static char led_state;
31 static char hw_led_state;
33 static DEFINE_SPINLOCK(leds_lock);
35 static void ebsa285_leds_event(led_event_t evt)
39 spin_lock_irqsave(&leds_lock, flags);
43 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN;
44 #ifndef CONFIG_LEDS_CPU
45 hw_led_state |= XBUS_LED_AMBER;
47 led_state |= LED_STATE_ENABLED;
51 led_state &= ~LED_STATE_ENABLED;
55 led_state |= LED_STATE_CLAIMED;
56 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
60 led_state &= ~LED_STATE_CLAIMED;
61 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
64 #ifdef CONFIG_LEDS_TIMER
66 if (!(led_state & LED_STATE_CLAIMED))
67 hw_led_state ^= XBUS_LED_GREEN;
71 #ifdef CONFIG_LEDS_CPU
73 if (!(led_state & LED_STATE_CLAIMED))
74 hw_led_state |= XBUS_LED_AMBER;
78 if (!(led_state & LED_STATE_CLAIMED))
79 hw_led_state &= ~XBUS_LED_AMBER;
84 if (!(led_state & LED_STATE_CLAIMED))
85 hw_led_state &= ~XBUS_LED_RED;
89 if (led_state & LED_STATE_CLAIMED)
90 hw_led_state &= ~XBUS_LED_GREEN;
94 if (led_state & LED_STATE_CLAIMED)
95 hw_led_state |= XBUS_LED_GREEN;
99 if (led_state & LED_STATE_CLAIMED)
100 hw_led_state &= ~XBUS_LED_AMBER;
104 if (led_state & LED_STATE_CLAIMED)
105 hw_led_state |= XBUS_LED_AMBER;
109 if (led_state & LED_STATE_CLAIMED)
110 hw_led_state &= ~XBUS_LED_RED;
114 if (led_state & LED_STATE_CLAIMED)
115 hw_led_state |= XBUS_LED_RED;
122 if (led_state & LED_STATE_ENABLED)
123 *XBUS_LEDS = hw_led_state;
125 spin_unlock_irqrestore(&leds_lock, flags);
128 static int __init leds_init(void)
130 if (machine_is_ebsa285())
131 leds_event = ebsa285_leds_event;
133 leds_event(led_start);
138 __initcall(leds_init);