[ARM] pxa: move i2c register and bit definitions into i2c-pxa.c
[linux-2.6] / 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/init.h>
15
16 #include <mach/hardware.h>
17 #include <asm/leds.h>
18 #include <asm/system.h>
19 #include <mach/pxa-regs.h>
20 #include <mach/lubbock.h>
21
22 #include "leds.h"
23
24 /*
25  * 8 discrete leds available for general use:
26  *
27  * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
28  * so be sure to not monkey with them here.
29  */
30
31 #define D28                     (1 << 0)
32 #define D27                     (1 << 1)
33 #define D26                     (1 << 2)
34 #define D25                     (1 << 3)
35 #define D24                     (1 << 4)
36 #define D23                     (1 << 5)
37 #define D22                     (1 << 6)
38 #define D21                     (1 << 7)
39
40 #define LED_STATE_ENABLED       1
41 #define LED_STATE_CLAIMED       2
42
43 static unsigned int led_state;
44 static unsigned int hw_led_state;
45
46 void lubbock_leds_event(led_event_t evt)
47 {
48         unsigned long flags;
49
50         local_irq_save(flags);
51
52         switch (evt) {
53         case led_start:
54                 hw_led_state = 0;
55                 led_state = LED_STATE_ENABLED;
56                 break;
57
58         case led_stop:
59                 led_state &= ~LED_STATE_ENABLED;
60                 break;
61
62         case led_claim:
63                 led_state |= LED_STATE_CLAIMED;
64                 hw_led_state = 0;
65                 break;
66
67         case led_release:
68                 led_state &= ~LED_STATE_CLAIMED;
69                 hw_led_state = 0;
70                 break;
71
72 #ifdef CONFIG_LEDS_TIMER
73         case led_timer:
74                 hw_led_state ^= D26;
75                 break;
76 #endif
77
78 #ifdef CONFIG_LEDS_CPU
79         case led_idle_start:
80                 hw_led_state &= ~D27;
81                 break;
82
83         case led_idle_end:
84                 hw_led_state |= D27;
85                 break;
86 #endif
87
88         case led_halted:
89                 break;
90
91         case led_green_on:
92                 hw_led_state |= D21;
93                 break;
94
95         case led_green_off:
96                 hw_led_state &= ~D21;
97                 break;
98
99         case led_amber_on:
100                 hw_led_state |= D22;
101                 break;
102
103         case led_amber_off:
104                 hw_led_state &= ~D22;
105                 break;
106
107         case led_red_on:
108                 hw_led_state |= D23;
109                 break;
110
111         case led_red_off:
112                 hw_led_state &= ~D23;
113                 break;
114
115         default:
116                 break;
117         }
118
119         if  (led_state & LED_STATE_ENABLED)
120                 LUB_DISC_BLNK_LED = (LUB_DISC_BLNK_LED | 0xff) & ~hw_led_state;
121         else
122                 LUB_DISC_BLNK_LED |= 0xff;
123
124         local_irq_restore(flags);
125 }