Automatic merge of rsync://www.parisc-linux.org/~jejb/git/scsi-for-linus-2.6.git
[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/config.h>
16 #include <linux/init.h>
17
18 #include <asm/hardware.h>
19 #include <asm/leds.h>
20 #include <asm/system.h>
21
22 #include <asm/arch/pxa-regs.h>
23 #include <asm/arch/idp.h>
24
25 #include "leds.h"
26
27 #define LED_STATE_ENABLED       1
28 #define LED_STATE_CLAIMED       2
29
30 static unsigned int led_state;
31 static unsigned int hw_led_state;
32
33 void idp_leds_event(led_event_t evt)
34 {
35         unsigned long flags;
36
37         local_irq_save(flags);
38
39         switch (evt) {
40         case led_start:
41                 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
42                 led_state = LED_STATE_ENABLED;
43                 break;
44
45         case led_stop:
46                 led_state &= ~LED_STATE_ENABLED;
47                 break;
48
49         case led_claim:
50                 led_state |= LED_STATE_CLAIMED;
51                 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
52                 break;
53
54         case led_release:
55                 led_state &= ~LED_STATE_CLAIMED;
56                 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
57                 break;
58
59 #ifdef CONFIG_LEDS_TIMER
60         case led_timer:
61                 if (!(led_state & LED_STATE_CLAIMED))
62                         hw_led_state ^= IDP_HB_LED;
63                 break;
64 #endif
65
66 #ifdef CONFIG_LEDS_CPU
67         case led_idle_start:
68                 if (!(led_state & LED_STATE_CLAIMED))
69                         hw_led_state &= ~IDP_BUSY_LED;
70                 break;
71
72         case led_idle_end:
73                 if (!(led_state & LED_STATE_CLAIMED))
74                         hw_led_state |= IDP_BUSY_LED;
75                 break;
76 #endif
77
78         case led_halted:
79                 break;
80
81         case led_green_on:
82                 if (led_state & LED_STATE_CLAIMED)
83                         hw_led_state |= IDP_HB_LED;
84                 break;
85
86         case led_green_off:
87                 if (led_state & LED_STATE_CLAIMED)
88                         hw_led_state &= ~IDP_HB_LED;
89                 break;
90
91         case led_amber_on:
92                 break;
93
94         case led_amber_off:
95                 break;
96
97         case led_red_on:
98                 if (led_state & LED_STATE_CLAIMED)
99                         hw_led_state |= IDP_BUSY_LED;
100                 break;
101
102         case led_red_off:
103                 if (led_state & LED_STATE_CLAIMED)
104                         hw_led_state &= ~IDP_BUSY_LED;
105                 break;
106
107         default:
108                 break;
109         }
110
111         if  (led_state & LED_STATE_ENABLED)
112                 IDP_CPLD_LED_CONTROL = ( (IDP_CPLD_LED_CONTROL | IDP_LEDS_MASK) & ~hw_led_state);
113         else
114                 IDP_CPLD_LED_CONTROL |= IDP_LEDS_MASK;
115
116         local_irq_restore(flags);
117 }