1 /*
2  *  linux/arch/arm/mach-sa1100/leds-graphicsmaster.c
3  *
4  * GraphicsClient Plus LEDs support
5  * Woojung Huh, Feb 13, 2001
6  */
7 #include <linux/config.h>
8 #include <linux/init.h>
9 
10 #include <asm/hardware.h>
11 #include <asm/leds.h>
12 #include <asm/system.h>
13 
14 #include "leds.h"
15 
16 
17 #define LED_STATE_ENABLED	1
18 #define LED_STATE_CLAIMED	2
19 
20 static unsigned int led_state;
21 static unsigned int hw_led_state;
22 
23 #define LED_TIMER       ADS_LED0  /* green heartbeat */
24 #define LED_USER        ADS_LED1  /* amber, boots to on */
25 #define LED_IDLE        ADS_LED2  /* red has the idle led, if any */
26 
27 #define LED_MASK	(ADS_LED0|ADS_LED1|ADS_LED2)
28 
graphicsmaster_leds_event(led_event_t evt)29 void graphicsmaster_leds_event(led_event_t evt)
30 {
31 	unsigned long flags;
32 
33 	local_irq_save(flags);
34 
35 	switch (evt) {
36 	case led_start:
37 		hw_led_state = 0;        /* gc leds are positive logic */
38 		led_state = LED_STATE_ENABLED;
39 		break;
40 
41 	case led_stop:
42 		led_state &= ~LED_STATE_ENABLED;
43 		break;
44 
45 	case led_claim:
46 		led_state |= LED_STATE_CLAIMED;
47 		hw_led_state = LED_MASK;
48 		break;
49 
50 	case led_release:
51 		led_state &= ~LED_STATE_CLAIMED;
52 		hw_led_state = LED_MASK;
53 		break;
54 
55 #ifdef CONFIG_LEDS_TIMER
56 	case led_timer:
57 		if (!(led_state & LED_STATE_CLAIMED))
58 			hw_led_state ^= LED_TIMER;
59 		break;
60 #endif
61 
62 #ifdef CONFIG_LEDS_CPU
63 	case led_idle_start:
64 		if (!(led_state & LED_STATE_CLAIMED))
65 			hw_led_state &= ~LED_IDLE;
66 		break;
67 
68 	case led_idle_end:
69 		if (!(led_state & LED_STATE_CLAIMED))
70 			hw_led_state |= LED_IDLE;
71 		break;
72 #endif
73 
74 	case led_green_on:
75 		break;
76 
77 	case led_green_off:
78 		break;
79 
80 	case led_amber_on:
81 		hw_led_state |= LED_USER;
82 		break;
83 
84 	case led_amber_off:
85 		hw_led_state &= ~LED_USER;
86 		break;
87 
88 	case led_red_on:
89 		break;
90 
91 	case led_red_off:
92 		break;
93 
94 	default:
95 		break;
96 	}
97 
98 	if  (led_state & LED_STATE_ENABLED) {
99 		GPSR = hw_led_state;
100 		GPCR = hw_led_state ^ LED_MASK;
101 	}
102 
103 	local_irq_restore(flags);
104 }
105