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>
26 #include <asm/system.h>
28 #define LED_STATE_ENABLED 1
29 #define LED_STATE_CLAIMED 2
31 #define SEQUOIA_LED_GREEN (1<<6)
32 #define SEQUOIA_LED_AMBER (1<<5)
33 #define SEQUOIA_LED_BACK (1<<7)
35 static char led_state
;
36 static short hw_led_state
;
37 static short saved_state
;
39 static DEFINE_SPINLOCK(leds_lock
);
41 short sequoia_read(int addr
) {
46 void sequoia_write(short value
,short addr
) {
51 static void sequoia_leds_event(led_event_t evt
)
55 spin_lock_irqsave(&leds_lock
, flags
);
57 hw_led_state
= sequoia_read(0x09);
61 hw_led_state
|= SEQUOIA_LED_GREEN
;
62 hw_led_state
|= SEQUOIA_LED_AMBER
;
63 #ifdef CONFIG_LEDS_CPU
64 hw_led_state
|= SEQUOIA_LED_BACK
;
66 hw_led_state
&= ~SEQUOIA_LED_BACK
;
68 led_state
|= LED_STATE_ENABLED
;
72 hw_led_state
&= ~SEQUOIA_LED_BACK
;
73 hw_led_state
|= SEQUOIA_LED_GREEN
;
74 hw_led_state
|= SEQUOIA_LED_AMBER
;
75 led_state
&= ~LED_STATE_ENABLED
;
79 led_state
|= LED_STATE_CLAIMED
;
80 saved_state
= hw_led_state
;
81 hw_led_state
&= ~SEQUOIA_LED_BACK
;
82 hw_led_state
|= SEQUOIA_LED_GREEN
;
83 hw_led_state
|= SEQUOIA_LED_AMBER
;
87 led_state
&= ~LED_STATE_CLAIMED
;
88 hw_led_state
= saved_state
;
91 #ifdef CONFIG_LEDS_TIMER
93 if (!(led_state
& LED_STATE_CLAIMED
))
94 hw_led_state
^= SEQUOIA_LED_GREEN
;
98 #ifdef CONFIG_LEDS_CPU
100 if (!(led_state
& LED_STATE_CLAIMED
))
101 hw_led_state
&= ~SEQUOIA_LED_BACK
;
105 if (!(led_state
& LED_STATE_CLAIMED
))
106 hw_led_state
|= SEQUOIA_LED_BACK
;
111 if (led_state
& LED_STATE_CLAIMED
)
112 hw_led_state
&= ~SEQUOIA_LED_GREEN
;
116 if (led_state
& LED_STATE_CLAIMED
)
117 hw_led_state
|= SEQUOIA_LED_GREEN
;
121 if (led_state
& LED_STATE_CLAIMED
)
122 hw_led_state
&= ~SEQUOIA_LED_AMBER
;
126 if (led_state
& LED_STATE_CLAIMED
)
127 hw_led_state
|= SEQUOIA_LED_AMBER
;
131 if (led_state
& LED_STATE_CLAIMED
)
132 hw_led_state
|= SEQUOIA_LED_BACK
;
136 if (led_state
& LED_STATE_CLAIMED
)
137 hw_led_state
&= ~SEQUOIA_LED_BACK
;
144 if (led_state
& LED_STATE_ENABLED
)
145 sequoia_write(hw_led_state
,0x09);
147 spin_unlock_irqrestore(&leds_lock
, flags
);
150 static int __init
leds_init(void)
152 extern void (*leds_event
)(led_event_t
);
155 leds_event
= sequoia_leds_event
;
157 /* Make LEDs independent of power-state */
158 request_region(0x24,4,"sequoia");
159 temp
= sequoia_read(0x09);
161 sequoia_write(temp
,0x09);
162 leds_event(led_start
);
166 __initcall(leds_init
);