[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / arm / mach-footbridge / netwinder-leds.c
blob7451fc07b85aa48199603f8603796d1be7af334f
1 /*
2 * linux/arch/arm/mach-footbridge/netwinder-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.
10 * NetWinder LED control routines.
12 * The Netwinder uses the leds as follows:
13 * - Green - toggles state every 50 timer interrupts
14 * - Red - On if the system is not idle
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);
36 extern spinlock_t gpio_lock;
38 static void netwinder_leds_event(led_event_t evt)
40 unsigned long flags;
42 spin_lock_irqsave(&leds_lock, flags);
44 switch (evt) {
45 case led_start:
46 led_state |= LED_STATE_ENABLED;
47 hw_led_state = GPIO_GREEN_LED;
48 break;
50 case led_stop:
51 led_state &= ~LED_STATE_ENABLED;
52 break;
54 case led_claim:
55 led_state |= LED_STATE_CLAIMED;
56 hw_led_state = 0;
57 break;
59 case led_release:
60 led_state &= ~LED_STATE_CLAIMED;
61 hw_led_state = 0;
62 break;
64 #ifdef CONFIG_LEDS_TIMER
65 case led_timer:
66 if (!(led_state & LED_STATE_CLAIMED))
67 hw_led_state ^= GPIO_GREEN_LED;
68 break;
69 #endif
71 #ifdef CONFIG_LEDS_CPU
72 case led_idle_start:
73 if (!(led_state & LED_STATE_CLAIMED))
74 hw_led_state &= ~GPIO_RED_LED;
75 break;
77 case led_idle_end:
78 if (!(led_state & LED_STATE_CLAIMED))
79 hw_led_state |= GPIO_RED_LED;
80 break;
81 #endif
83 case led_halted:
84 if (!(led_state & LED_STATE_CLAIMED))
85 hw_led_state |= GPIO_RED_LED;
86 break;
88 case led_green_on:
89 if (led_state & LED_STATE_CLAIMED)
90 hw_led_state |= GPIO_GREEN_LED;
91 break;
93 case led_green_off:
94 if (led_state & LED_STATE_CLAIMED)
95 hw_led_state &= ~GPIO_GREEN_LED;
96 break;
98 case led_amber_on:
99 if (led_state & LED_STATE_CLAIMED)
100 hw_led_state |= GPIO_GREEN_LED | GPIO_RED_LED;
101 break;
103 case led_amber_off:
104 if (led_state & LED_STATE_CLAIMED)
105 hw_led_state &= ~(GPIO_GREEN_LED | GPIO_RED_LED);
106 break;
108 case led_red_on:
109 if (led_state & LED_STATE_CLAIMED)
110 hw_led_state |= GPIO_RED_LED;
111 break;
113 case led_red_off:
114 if (led_state & LED_STATE_CLAIMED)
115 hw_led_state &= ~GPIO_RED_LED;
116 break;
118 default:
119 break;
122 spin_unlock_irqrestore(&leds_lock, flags);
124 if (led_state & LED_STATE_ENABLED) {
125 spin_lock_irqsave(&gpio_lock, flags);
126 gpio_modify_op(GPIO_RED_LED | GPIO_GREEN_LED, hw_led_state);
127 spin_unlock_irqrestore(&gpio_lock, flags);
131 static int __init leds_init(void)
133 if (machine_is_netwinder())
134 leds_event = netwinder_leds_event;
136 leds_event(led_start);
138 return 0;
141 __initcall(leds_init);