ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / arm / mach-pxa / leds-lubbock.c
1 /*
2  * linux/arch/arm/mach-pxa/leds-lubbock.c
3  *
4  * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
5  *
6  * Copyright (c) 2001 Jeff Sutherland <jeffs@accelent.com>
7  *
8  * Original (leds-footbridge.c) by Russell King
9  *
10  * Major surgery on April 2004 by Nicolas Pitre for less global
11  * namespace collision.  Mostly adapted the Mainstone version.
12  */
13
14 #include <linux/config.h>
15 #include <linux/init.h>
16
17 #include <asm/hardware.h>
18 #include <asm/leds.h>
19 #include <asm/system.h>
20
21 #include "leds.h"
22
23 /*
24  * 8 discrete leds available for general use:
25  *
26  * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
27  * so be sure to not monkey with them here.
28  */
29
30 #define D28                     (1 << 0)
31 #define D27                     (1 << 1)
32 #define D26                     (1 << 2)
33 #define D25                     (1 << 3)
34 #define D24                     (1 << 4)
35 #define D23                     (1 << 5)
36 #define D22                     (1 << 6)
37 #define D21                     (1 << 7)
38
39 #define LED_STATE_ENABLED       1
40 #define LED_STATE_CLAIMED       2
41
42 static unsigned int led_state;
43 static unsigned int hw_led_state;
44
45 void lubbock_leds_event(led_event_t evt)
46 {
47         unsigned long flags;
48
49         local_irq_save(flags);
50
51         switch (evt) {
52         case led_start:
53                 hw_led_state = 0;
54                 led_state = LED_STATE_ENABLED;
55                 break;
56
57         case led_stop:
58                 led_state &= ~LED_STATE_ENABLED;
59                 break;
60
61         case led_claim:
62                 led_state |= LED_STATE_CLAIMED;
63                 hw_led_state = 0;
64                 break;
65
66         case led_release:
67                 led_state &= ~LED_STATE_CLAIMED;
68                 hw_led_state = 0;
69                 break;
70
71 #ifdef CONFIG_LEDS_TIMER
72         case led_timer:
73                 hw_led_state ^= D26;
74                 break;
75 #endif
76
77 #ifdef CONFIG_LEDS_CPU
78         case led_idle_start:
79                 hw_led_state &= ~D27;
80                 break;
81
82         case led_idle_end:
83                 hw_led_state |= D27;
84                 break;
85 #endif
86
87         case led_halted:
88                 break;
89
90         case led_green_on:
91                 hw_led_state |= D21;;
92                 break;
93
94         case led_green_off:
95                 hw_led_state &= ~D21;
96                 break;
97
98         case led_amber_on:
99                 hw_led_state |= D22;;
100                 break;
101
102         case led_amber_off:
103                 hw_led_state &= ~D22;
104                 break;
105
106         case led_red_on:
107                 hw_led_state |= D23;;
108                 break;
109
110         case led_red_off:
111                 hw_led_state &= ~D23;
112                 break;
113
114         default:
115                 break;
116         }
117
118         if  (led_state & LED_STATE_ENABLED)
119                 LUB_DISC_BLNK_LED = (LUB_DISC_BLNK_LED | 0xff) & ~hw_led_state;
120         else
121                 LUB_DISC_BLNK_LED |= 0xff;
122
123         local_irq_restore(flags);
124 }