[ARM] 3113/1: PXA: Allow machines to override (and also reuse) pxa pm functions
[linux-2.6.git] / arch / arm / mach-pxa / leds-mainstone.c
blobbbd3f87a9fc2222e176e4fddd4e61080b965086e
1 /*
2 * linux/arch/arm/mach-pxa/leds-mainstone.c
4 * Author: Nicolas Pitre
5 * Created: Nov 05, 2002
6 * Copyright: MontaVista Software Inc.
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.
13 #include <linux/config.h>
14 #include <linux/init.h>
16 #include <asm/hardware.h>
17 #include <asm/leds.h>
18 #include <asm/system.h>
20 #include <asm/arch/pxa-regs.h>
21 #include <asm/arch/mainstone.h>
23 #include "leds.h"
26 /* 8 discrete leds available for general use: */
27 #define D28 (1 << 0)
28 #define D27 (1 << 1)
29 #define D26 (1 << 2)
30 #define D25 (1 << 3)
31 #define D24 (1 << 4)
32 #define D23 (1 << 5)
33 #define D22 (1 << 6)
34 #define D21 (1 << 7)
36 #define LED_STATE_ENABLED 1
37 #define LED_STATE_CLAIMED 2
39 static unsigned int led_state;
40 static unsigned int hw_led_state;
42 void mainstone_leds_event(led_event_t evt)
44 unsigned long flags;
46 local_irq_save(flags);
48 switch (evt) {
49 case led_start:
50 hw_led_state = 0;
51 led_state = LED_STATE_ENABLED;
52 break;
54 case led_stop:
55 led_state &= ~LED_STATE_ENABLED;
56 break;
58 case led_claim:
59 led_state |= LED_STATE_CLAIMED;
60 hw_led_state = 0;
61 break;
63 case led_release:
64 led_state &= ~LED_STATE_CLAIMED;
65 hw_led_state = 0;
66 break;
68 #ifdef CONFIG_LEDS_TIMER
69 case led_timer:
70 hw_led_state ^= D26;
71 break;
72 #endif
74 #ifdef CONFIG_LEDS_CPU
75 case led_idle_start:
76 hw_led_state &= ~D27;
77 break;
79 case led_idle_end:
80 hw_led_state |= D27;
81 break;
82 #endif
84 case led_halted:
85 break;
87 case led_green_on:
88 hw_led_state |= D21;;
89 break;
91 case led_green_off:
92 hw_led_state &= ~D21;
93 break;
95 case led_amber_on:
96 hw_led_state |= D22;;
97 break;
99 case led_amber_off:
100 hw_led_state &= ~D22;
101 break;
103 case led_red_on:
104 hw_led_state |= D23;;
105 break;
107 case led_red_off:
108 hw_led_state &= ~D23;
109 break;
111 default:
112 break;
115 if (led_state & LED_STATE_ENABLED)
116 MST_LEDCTRL = (MST_LEDCTRL | 0xff) & ~hw_led_state;
117 else
118 MST_LEDCTRL |= 0xff;
120 local_irq_restore(flags);