]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-pxa/leds-mainstone.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
[karo-tx-linux.git] / arch / arm / mach-pxa / leds-mainstone.c
1 /*
2  * linux/arch/arm/mach-pxa/leds-mainstone.c
3  *
4  * Author:     Nicolas Pitre
5  * Created:    Nov 05, 2002
6  * Copyright:  MontaVista Software Inc.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include <linux/init.h>
14
15 #include <mach/hardware.h>
16 #include <asm/leds.h>
17
18 #include <mach/pxa27x.h>
19 #include <mach/mainstone.h>
20
21 #include "leds.h"
22
23
24 /* 8 discrete leds available for general use: */
25 #define D28                     (1 << 0)
26 #define D27                     (1 << 1)
27 #define D26                     (1 << 2)
28 #define D25                     (1 << 3)
29 #define D24                     (1 << 4)
30 #define D23                     (1 << 5)
31 #define D22                     (1 << 6)
32 #define D21                     (1 << 7)
33
34 #define LED_STATE_ENABLED       1
35 #define LED_STATE_CLAIMED       2
36
37 static unsigned int led_state;
38 static unsigned int hw_led_state;
39
40 void mainstone_leds_event(led_event_t evt)
41 {
42         unsigned long flags;
43
44         local_irq_save(flags);
45
46         switch (evt) {
47         case led_start:
48                 hw_led_state = 0;
49                 led_state = LED_STATE_ENABLED;
50                 break;
51
52         case led_stop:
53                 led_state &= ~LED_STATE_ENABLED;
54                 break;
55
56         case led_claim:
57                 led_state |= LED_STATE_CLAIMED;
58                 hw_led_state = 0;
59                 break;
60
61         case led_release:
62                 led_state &= ~LED_STATE_CLAIMED;
63                 hw_led_state = 0;
64                 break;
65
66 #ifdef CONFIG_LEDS_TIMER
67         case led_timer:
68                 hw_led_state ^= D26;
69                 break;
70 #endif
71
72 #ifdef CONFIG_LEDS_CPU
73         case led_idle_start:
74                 hw_led_state &= ~D27;
75                 break;
76
77         case led_idle_end:
78                 hw_led_state |= D27;
79                 break;
80 #endif
81
82         case led_halted:
83                 break;
84
85         case led_green_on:
86                 hw_led_state |= D21;
87                 break;
88
89         case led_green_off:
90                 hw_led_state &= ~D21;
91                 break;
92
93         case led_amber_on:
94                 hw_led_state |= D22;
95                 break;
96
97         case led_amber_off:
98                 hw_led_state &= ~D22;
99                 break;
100
101         case led_red_on:
102                 hw_led_state |= D23;
103                 break;
104
105         case led_red_off:
106                 hw_led_state &= ~D23;
107                 break;
108
109         default:
110                 break;
111         }
112
113         if  (led_state & LED_STATE_ENABLED)
114                 MST_LEDCTRL = (MST_LEDCTRL | 0xff) & ~hw_led_state;
115         else
116                 MST_LEDCTRL |= 0xff;
117
118         local_irq_restore(flags);
119 }