]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-sa1100/leds-lart.c
[ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach
[net-next-2.6.git] / arch / arm / mach-sa1100 / leds-lart.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/arm/mach-sa1100/leds-lart.c
3 *
4 * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000
5 *
6 * LART uses the LED as follows:
7 * - GPIO23 is the LED, on if system is not idle
8 * You can use both CONFIG_LEDS_CPU and CONFIG_LEDS_TIMER at the same
9 * time, but in that case the timer events will still dictate the
10 * pace of the LED.
11 */
1da177e4
LT
12#include <linux/init.h>
13
a09e64fb 14#include <mach/hardware.h>
1da177e4
LT
15#include <asm/leds.h>
16#include <asm/system.h>
17
18#include "leds.h"
19
20
21#define LED_STATE_ENABLED 1
22#define LED_STATE_CLAIMED 2
23
24static unsigned int led_state;
25static unsigned int hw_led_state;
26
27#define LED_23 GPIO_GPIO23
28#define LED_MASK (LED_23)
29
30void lart_leds_event(led_event_t evt)
31{
32 unsigned long flags;
33
34 local_irq_save(flags);
35
36 switch(evt) {
37 case led_start:
38 /* pin 23 is output pin */
39 GPDR |= LED_23;
40 hw_led_state = LED_MASK;
41 led_state = LED_STATE_ENABLED;
42 break;
43
44 case led_stop:
45 led_state &= ~LED_STATE_ENABLED;
46 break;
47
48 case led_claim:
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = LED_MASK;
51 break;
52
53 case led_release:
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = LED_MASK;
56 break;
57
58#ifdef CONFIG_LEDS_TIMER
59 case led_timer:
60 if (!(led_state & LED_STATE_CLAIMED))
61 hw_led_state ^= LED_23;
62 break;
63#endif
64
65#ifdef CONFIG_LEDS_CPU
66 case led_idle_start:
67 /* The LART people like the LED to be off when the
68 system is idle... */
69 if (!(led_state & LED_STATE_CLAIMED))
70 hw_led_state &= ~LED_23;
71 break;
72
73 case led_idle_end:
74 /* ... and on if the system is not idle */
75 if (!(led_state & LED_STATE_CLAIMED))
76 hw_led_state |= LED_23;
77 break;
78#endif
79
80 case led_red_on:
81 if (led_state & LED_STATE_CLAIMED)
82 hw_led_state &= ~LED_23;
83 break;
84
85 case led_red_off:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state |= LED_23;
88 break;
89
90 default:
91 break;
92 }
93
94 /* Now set the GPIO state, or nothing will happen at all */
95 if (led_state & LED_STATE_ENABLED) {
96 GPSR = hw_led_state;
97 GPCR = hw_led_state ^ LED_MASK;
98 }
99
100 local_irq_restore(flags);
101}