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