[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / arm / mach-footbridge / ebsa285-leds.c
blob2c7c3630401bd2968544653331380dd719ab29a0
1 /*
2 * linux/arch/arm/mach-footbridge/ebsa285-leds.c
4 * Copyright (C) 1998-1999 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 * EBSA-285 control routines.
11 * The EBSA-285 uses the leds as follows:
12 * - Green - toggles state every 50 timer interrupts
13 * - Amber - On if system is not idle
14 * - Red - currently unused
16 * Changelog:
17 * 02-05-1999 RMK Various cleanups
19 #include <linux/config.h>
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/spinlock.h>
25 #include <asm/hardware.h>
26 #include <asm/leds.h>
27 #include <asm/mach-types.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 char hw_led_state;
35 static DEFINE_SPINLOCK(leds_lock);
37 static void ebsa285_leds_event(led_event_t evt)
39 unsigned long flags;
41 spin_lock_irqsave(&leds_lock, flags);
43 switch (evt) {
44 case led_start:
45 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN;
46 #ifndef CONFIG_LEDS_CPU
47 hw_led_state |= XBUS_LED_AMBER;
48 #endif
49 led_state |= LED_STATE_ENABLED;
50 break;
52 case led_stop:
53 led_state &= ~LED_STATE_ENABLED;
54 break;
56 case led_claim:
57 led_state |= LED_STATE_CLAIMED;
58 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
59 break;
61 case led_release:
62 led_state &= ~LED_STATE_CLAIMED;
63 hw_led_state = XBUS_LED_RED | XBUS_LED_GREEN | XBUS_LED_AMBER;
64 break;
66 #ifdef CONFIG_LEDS_TIMER
67 case led_timer:
68 if (!(led_state & LED_STATE_CLAIMED))
69 hw_led_state ^= XBUS_LED_GREEN;
70 break;
71 #endif
73 #ifdef CONFIG_LEDS_CPU
74 case led_idle_start:
75 if (!(led_state & LED_STATE_CLAIMED))
76 hw_led_state |= XBUS_LED_AMBER;
77 break;
79 case led_idle_end:
80 if (!(led_state & LED_STATE_CLAIMED))
81 hw_led_state &= ~XBUS_LED_AMBER;
82 break;
83 #endif
85 case led_halted:
86 if (!(led_state & LED_STATE_CLAIMED))
87 hw_led_state &= ~XBUS_LED_RED;
88 break;
90 case led_green_on:
91 if (led_state & LED_STATE_CLAIMED)
92 hw_led_state &= ~XBUS_LED_GREEN;
93 break;
95 case led_green_off:
96 if (led_state & LED_STATE_CLAIMED)
97 hw_led_state |= XBUS_LED_GREEN;
98 break;
100 case led_amber_on:
101 if (led_state & LED_STATE_CLAIMED)
102 hw_led_state &= ~XBUS_LED_AMBER;
103 break;
105 case led_amber_off:
106 if (led_state & LED_STATE_CLAIMED)
107 hw_led_state |= XBUS_LED_AMBER;
108 break;
110 case led_red_on:
111 if (led_state & LED_STATE_CLAIMED)
112 hw_led_state &= ~XBUS_LED_RED;
113 break;
115 case led_red_off:
116 if (led_state & LED_STATE_CLAIMED)
117 hw_led_state |= XBUS_LED_RED;
118 break;
120 default:
121 break;
124 if (led_state & LED_STATE_ENABLED)
125 *XBUS_LEDS = hw_led_state;
127 spin_unlock_irqrestore(&leds_lock, flags);
130 static int __init leds_init(void)
132 if (machine_is_ebsa285() || machine_is_co285())
133 leds_event = ebsa285_leds_event;
135 leds_event(led_start);
137 return 0;
140 __initcall(leds_init);