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