2 * arch/arm/mach-shark/leds.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/kernel.h>
19 #include <linux/module.h>
20 #include <linux/init.h>
21 #include <linux/spinlock.h>
22 #include <linux/ioport.h>
24 #include <asm/hardware.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 short hw_led_state
;
33 static short saved_state
;
35 static DEFINE_SPINLOCK(leds_lock
);
37 short sequoia_read(int addr
) {
42 void sequoia_write(short value
,short addr
) {
47 static void sequoia_leds_event(led_event_t evt
)
51 spin_lock_irqsave(&leds_lock
, flags
);
53 hw_led_state
= sequoia_read(0x09);
57 hw_led_state
|= SEQUOIA_LED_GREEN
;
58 hw_led_state
|= SEQUOIA_LED_AMBER
;
59 #ifdef CONFIG_LEDS_CPU
60 hw_led_state
|= SEQUOIA_LED_BACK
;
62 hw_led_state
&= ~SEQUOIA_LED_BACK
;
64 led_state
|= LED_STATE_ENABLED
;
68 hw_led_state
&= ~SEQUOIA_LED_BACK
;
69 hw_led_state
|= SEQUOIA_LED_GREEN
;
70 hw_led_state
|= SEQUOIA_LED_AMBER
;
71 led_state
&= ~LED_STATE_ENABLED
;
75 led_state
|= LED_STATE_CLAIMED
;
76 saved_state
= hw_led_state
;
77 hw_led_state
&= ~SEQUOIA_LED_BACK
;
78 hw_led_state
|= SEQUOIA_LED_GREEN
;
79 hw_led_state
|= SEQUOIA_LED_AMBER
;
83 led_state
&= ~LED_STATE_CLAIMED
;
84 hw_led_state
= saved_state
;
87 #ifdef CONFIG_LEDS_TIMER
89 if (!(led_state
& LED_STATE_CLAIMED
))
90 hw_led_state
^= SEQUOIA_LED_GREEN
;
94 #ifdef CONFIG_LEDS_CPU
96 if (!(led_state
& LED_STATE_CLAIMED
))
97 hw_led_state
&= ~SEQUOIA_LED_BACK
;
101 if (!(led_state
& LED_STATE_CLAIMED
))
102 hw_led_state
|= SEQUOIA_LED_BACK
;
107 if (led_state
& LED_STATE_CLAIMED
)
108 hw_led_state
&= ~SEQUOIA_LED_GREEN
;
112 if (led_state
& LED_STATE_CLAIMED
)
113 hw_led_state
|= SEQUOIA_LED_GREEN
;
117 if (led_state
& LED_STATE_CLAIMED
)
118 hw_led_state
&= ~SEQUOIA_LED_AMBER
;
122 if (led_state
& LED_STATE_CLAIMED
)
123 hw_led_state
|= SEQUOIA_LED_AMBER
;
127 if (led_state
& LED_STATE_CLAIMED
)
128 hw_led_state
|= SEQUOIA_LED_BACK
;
132 if (led_state
& LED_STATE_CLAIMED
)
133 hw_led_state
&= ~SEQUOIA_LED_BACK
;
140 if (led_state
& LED_STATE_ENABLED
)
141 sequoia_write(hw_led_state
,0x09);
143 spin_unlock_irqrestore(&leds_lock
, flags
);
146 static int __init
leds_init(void)
148 extern void (*leds_event
)(led_event_t
);
151 leds_event
= sequoia_leds_event
;
153 /* Make LEDs independent of power-state */
154 request_region(0x24,4,"sequoia");
155 temp
= sequoia_read(0x09);
157 sequoia_write(temp
,0x09);
158 leds_event(led_start
);
162 __initcall(leds_init
);