e1000: Add device IDs of blade version of the 82571 quad port
[pv_ops_mirror.git] / arch / arm / mach-shark / leds.c
blob5386a81f796a07a9bbbd5eb89e9c7e24daba88d0
1 /*
2 * arch/arm/mach-shark/leds.c
3 * by Alexander Schulz
5 * derived from:
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
16 * Changelog:
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>
25 #include <asm/leds.h>
26 #include <asm/io.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) {
38 outw(addr,0x24);
39 return inw(0x26);
42 void sequoia_write(short value,short addr) {
43 outw(addr,0x24);
44 outw(value,0x26);
47 static void sequoia_leds_event(led_event_t evt)
49 unsigned long flags;
51 spin_lock_irqsave(&leds_lock, flags);
53 hw_led_state = sequoia_read(0x09);
55 switch (evt) {
56 case led_start:
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;
61 #else
62 hw_led_state &= ~SEQUOIA_LED_BACK;
63 #endif
64 led_state |= LED_STATE_ENABLED;
65 break;
67 case led_stop:
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;
72 break;
74 case led_claim:
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;
80 break;
82 case led_release:
83 led_state &= ~LED_STATE_CLAIMED;
84 hw_led_state = saved_state;
85 break;
87 #ifdef CONFIG_LEDS_TIMER
88 case led_timer:
89 if (!(led_state & LED_STATE_CLAIMED))
90 hw_led_state ^= SEQUOIA_LED_GREEN;
91 break;
92 #endif
94 #ifdef CONFIG_LEDS_CPU
95 case led_idle_start:
96 if (!(led_state & LED_STATE_CLAIMED))
97 hw_led_state &= ~SEQUOIA_LED_BACK;
98 break;
100 case led_idle_end:
101 if (!(led_state & LED_STATE_CLAIMED))
102 hw_led_state |= SEQUOIA_LED_BACK;
103 break;
104 #endif
106 case led_green_on:
107 if (led_state & LED_STATE_CLAIMED)
108 hw_led_state &= ~SEQUOIA_LED_GREEN;
109 break;
111 case led_green_off:
112 if (led_state & LED_STATE_CLAIMED)
113 hw_led_state |= SEQUOIA_LED_GREEN;
114 break;
116 case led_amber_on:
117 if (led_state & LED_STATE_CLAIMED)
118 hw_led_state &= ~SEQUOIA_LED_AMBER;
119 break;
121 case led_amber_off:
122 if (led_state & LED_STATE_CLAIMED)
123 hw_led_state |= SEQUOIA_LED_AMBER;
124 break;
126 case led_red_on:
127 if (led_state & LED_STATE_CLAIMED)
128 hw_led_state |= SEQUOIA_LED_BACK;
129 break;
131 case led_red_off:
132 if (led_state & LED_STATE_CLAIMED)
133 hw_led_state &= ~SEQUOIA_LED_BACK;
134 break;
136 default:
137 break;
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);
149 short temp;
151 leds_event = sequoia_leds_event;
153 /* Make LEDs independent of power-state */
154 request_region(0x24,4,"sequoia");
155 temp = sequoia_read(0x09);
156 temp |= 1<<10;
157 sequoia_write(temp,0x09);
158 leds_event(led_start);
159 return 0;
162 __initcall(leds_init);