blob: db4af5eee8b21649b2dc1ef661bfb970896812c7 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/init.h>
14
Russell Kinga09e64f2008-08-05 16:14:15 +010015#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/leds.h>
17#include <asm/system.h>
18
Eric Miao51c62982009-01-02 23:17:22 +080019#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/mainstone.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
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
38static unsigned int led_state;
39static unsigned int hw_led_state;
40
41void 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:
Alexey Dobriyan53b35312006-03-24 03:16:13 -080087 hw_led_state |= D21;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 break;
89
90 case led_green_off:
91 hw_led_state &= ~D21;
92 break;
93
94 case led_amber_on:
Alexey Dobriyan53b35312006-03-24 03:16:13 -080095 hw_led_state |= D22;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 break;
97
98 case led_amber_off:
99 hw_led_state &= ~D22;
100 break;
101
102 case led_red_on:
Alexey Dobriyan53b35312006-03-24 03:16:13 -0800103 hw_led_state |= D23;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 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}