2 * arch/arm/kernel/leds-shark.c
6 * arch/arm/kernel/leds-footbridge.c
7 * Copyright (C) 1998-1999 Russell King
9 * DIGITAL Shark LED control routines.
11 * The leds use is as follows:
12 * - Green front - toggles state every 50 timer interrupts
13 * - Amber front - Unused, this is a dual color led (Amber/Green)
14 * - Amber back - On if system is not idle
18 #include <linux/config.h>
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/init.h>
22 #include <linux/spinlock.h>
23 #include <linux/ioport.h>
25 #include <asm/hardware.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 short hw_led_state;
34 static short saved_state;
36 static DEFINE_SPINLOCK(leds_lock);
38 short sequoia_read(int addr) {
43 void sequoia_write(short value,short addr) {
48 static void sequoia_leds_event(led_event_t evt)
52 spin_lock_irqsave(&leds_lock, flags);
54 hw_led_state = sequoia_read(0x09);
58 hw_led_state |= SEQUOIA_LED_GREEN;
59 hw_led_state |= SEQUOIA_LED_AMBER;
60 #ifdef CONFIG_LEDS_CPU
61 hw_led_state |= SEQUOIA_LED_BACK;
63 hw_led_state &= ~SEQUOIA_LED_BACK;
65 led_state |= LED_STATE_ENABLED;
69 hw_led_state &= ~SEQUOIA_LED_BACK;
70 hw_led_state |= SEQUOIA_LED_GREEN;
71 hw_led_state |= SEQUOIA_LED_AMBER;
72 led_state &= ~LED_STATE_ENABLED;
76 led_state |= LED_STATE_CLAIMED;
77 saved_state = hw_led_state;
78 hw_led_state &= ~SEQUOIA_LED_BACK;
79 hw_led_state |= SEQUOIA_LED_GREEN;
80 hw_led_state |= SEQUOIA_LED_AMBER;
84 led_state &= ~LED_STATE_CLAIMED;
85 hw_led_state = saved_state;
88 #ifdef CONFIG_LEDS_TIMER
90 if (!(led_state & LED_STATE_CLAIMED))
91 hw_led_state ^= SEQUOIA_LED_GREEN;
95 #ifdef CONFIG_LEDS_CPU
97 if (!(led_state & LED_STATE_CLAIMED))
98 hw_led_state &= ~SEQUOIA_LED_BACK;
102 if (!(led_state & LED_STATE_CLAIMED))
103 hw_led_state |= SEQUOIA_LED_BACK;
108 if (led_state & LED_STATE_CLAIMED)
109 hw_led_state &= ~SEQUOIA_LED_GREEN;
113 if (led_state & LED_STATE_CLAIMED)
114 hw_led_state |= SEQUOIA_LED_GREEN;
118 if (led_state & LED_STATE_CLAIMED)
119 hw_led_state &= ~SEQUOIA_LED_AMBER;
123 if (led_state & LED_STATE_CLAIMED)
124 hw_led_state |= SEQUOIA_LED_AMBER;
128 if (led_state & LED_STATE_CLAIMED)
129 hw_led_state |= SEQUOIA_LED_BACK;
133 if (led_state & LED_STATE_CLAIMED)
134 hw_led_state &= ~SEQUOIA_LED_BACK;
141 if (led_state & LED_STATE_ENABLED)
142 sequoia_write(hw_led_state,0x09);
144 spin_unlock_irqrestore(&leds_lock, flags);
147 static int __init leds_init(void)
149 extern void (*leds_event)(led_event_t);
152 leds_event = sequoia_leds_event;
154 /* Make LEDs independent of power-state */
155 request_region(0x24,4,"sequoia");
156 temp = sequoia_read(0x09);
158 sequoia_write(temp,0x09);
159 leds_event(led_start);
163 __initcall(leds_init);