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>
27 #define LED_STATE_ENABLED 1
28 #define LED_STATE_CLAIMED 2
30 #define SEQUOIA_LED_GREEN (1<<6)
31 #define SEQUOIA_LED_AMBER (1<<5)
32 #define SEQUOIA_LED_BACK (1<<7)
34 static char led_state
;
35 static short hw_led_state
;
36 static short saved_state
;
38 static DEFINE_RAW_SPINLOCK(leds_lock
);
40 short sequoia_read(int addr
) {
45 void sequoia_write(short value
,short addr
) {
50 static void sequoia_leds_event(led_event_t evt
)
54 raw_spin_lock_irqsave(&leds_lock
, flags
);
56 hw_led_state
= sequoia_read(0x09);
60 hw_led_state
|= SEQUOIA_LED_GREEN
;
61 hw_led_state
|= SEQUOIA_LED_AMBER
;
62 #ifdef CONFIG_LEDS_CPU
63 hw_led_state
|= SEQUOIA_LED_BACK
;
65 hw_led_state
&= ~SEQUOIA_LED_BACK
;
67 led_state
|= LED_STATE_ENABLED
;
71 hw_led_state
&= ~SEQUOIA_LED_BACK
;
72 hw_led_state
|= SEQUOIA_LED_GREEN
;
73 hw_led_state
|= SEQUOIA_LED_AMBER
;
74 led_state
&= ~LED_STATE_ENABLED
;
78 led_state
|= LED_STATE_CLAIMED
;
79 saved_state
= hw_led_state
;
80 hw_led_state
&= ~SEQUOIA_LED_BACK
;
81 hw_led_state
|= SEQUOIA_LED_GREEN
;
82 hw_led_state
|= SEQUOIA_LED_AMBER
;
86 led_state
&= ~LED_STATE_CLAIMED
;
87 hw_led_state
= saved_state
;
90 #ifdef CONFIG_LEDS_TIMER
92 if (!(led_state
& LED_STATE_CLAIMED
))
93 hw_led_state
^= SEQUOIA_LED_GREEN
;
97 #ifdef CONFIG_LEDS_CPU
99 if (!(led_state
& LED_STATE_CLAIMED
))
100 hw_led_state
&= ~SEQUOIA_LED_BACK
;
104 if (!(led_state
& LED_STATE_CLAIMED
))
105 hw_led_state
|= SEQUOIA_LED_BACK
;
110 if (led_state
& LED_STATE_CLAIMED
)
111 hw_led_state
&= ~SEQUOIA_LED_GREEN
;
115 if (led_state
& LED_STATE_CLAIMED
)
116 hw_led_state
|= SEQUOIA_LED_GREEN
;
120 if (led_state
& LED_STATE_CLAIMED
)
121 hw_led_state
&= ~SEQUOIA_LED_AMBER
;
125 if (led_state
& LED_STATE_CLAIMED
)
126 hw_led_state
|= SEQUOIA_LED_AMBER
;
130 if (led_state
& LED_STATE_CLAIMED
)
131 hw_led_state
|= SEQUOIA_LED_BACK
;
135 if (led_state
& LED_STATE_CLAIMED
)
136 hw_led_state
&= ~SEQUOIA_LED_BACK
;
143 if (led_state
& LED_STATE_ENABLED
)
144 sequoia_write(hw_led_state
,0x09);
146 raw_spin_unlock_irqrestore(&leds_lock
, flags
);
149 static int __init
leds_init(void)
151 extern void (*leds_event
)(led_event_t
);
154 leds_event
= sequoia_leds_event
;
156 /* Make LEDs independent of power-state */
157 request_region(0x24,4,"sequoia");
158 temp
= sequoia_read(0x09);
160 sequoia_write(temp
,0x09);
161 leds_event(led_start
);
165 __initcall(leds_init
);