Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6] / arch / arm / mach-pxa / leds-idp.c
1 /*
2  * linux/arch/arm/mach-pxa/leds-idp.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  * Macros for actual LED manipulation should be in machine specific
11  * files in this 'mach' directory.
12  */
13
14
15 #include <linux/init.h>
16
17 #include <asm/hardware.h>
18 #include <asm/leds.h>
19 #include <asm/system.h>
20
21 #include <asm/arch/pxa-regs.h>
22 #include <asm/arch/idp.h>
23
24 #include "leds.h"
25
26 #define LED_STATE_ENABLED       1
27 #define LED_STATE_CLAIMED       2
28
29 static unsigned int led_state;
30 static unsigned int hw_led_state;
31
32 void idp_leds_event(led_event_t evt)
33 {
34         unsigned long flags;
35
36         local_irq_save(flags);
37
38         switch (evt) {
39         case led_start:
40                 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
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 = IDP_HB_LED | IDP_BUSY_LED;
51                 break;
52
53         case led_release:
54                 led_state &= ~LED_STATE_CLAIMED;
55                 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
56                 break;
57
58 #ifdef CONFIG_LEDS_TIMER
59         case led_timer:
60                 if (!(led_state & LED_STATE_CLAIMED))
61                         hw_led_state ^= IDP_HB_LED;
62                 break;
63 #endif
64
65 #ifdef CONFIG_LEDS_CPU
66         case led_idle_start:
67                 if (!(led_state & LED_STATE_CLAIMED))
68                         hw_led_state &= ~IDP_BUSY_LED;
69                 break;
70
71         case led_idle_end:
72                 if (!(led_state & LED_STATE_CLAIMED))
73                         hw_led_state |= IDP_BUSY_LED;
74                 break;
75 #endif
76
77         case led_halted:
78                 break;
79
80         case led_green_on:
81                 if (led_state & LED_STATE_CLAIMED)
82                         hw_led_state |= IDP_HB_LED;
83                 break;
84
85         case led_green_off:
86                 if (led_state & LED_STATE_CLAIMED)
87                         hw_led_state &= ~IDP_HB_LED;
88                 break;
89
90         case led_amber_on:
91                 break;
92
93         case led_amber_off:
94                 break;
95
96         case led_red_on:
97                 if (led_state & LED_STATE_CLAIMED)
98                         hw_led_state |= IDP_BUSY_LED;
99                 break;
100
101         case led_red_off:
102                 if (led_state & LED_STATE_CLAIMED)
103                         hw_led_state &= ~IDP_BUSY_LED;
104                 break;
105
106         default:
107                 break;
108         }
109
110         if  (led_state & LED_STATE_ENABLED)
111                 IDP_CPLD_LED_CONTROL = ( (IDP_CPLD_LED_CONTROL | IDP_LEDS_MASK) & ~hw_led_state);
112         else
113                 IDP_CPLD_LED_CONTROL |= IDP_LEDS_MASK;
114
115         local_irq_restore(flags);
116 }