blob: 64e9b4b11b5454b83f192b93ac0b8ff0b5782d66 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-sa1100/leds-assabet.c
3 *
4 * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
5 *
6 * Original (leds-footbridge.c) by Russell King
7 *
8 * Assabet uses the LEDs as follows:
9 * - Green - toggles state every 50 timer interrupts
10 * - Red - on if system is not idle
11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/init.h>
13
Russell Kinga09e64f2008-08-05 16:14:15 +010014#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/leds.h>
16#include <asm/system.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010017#include <mach/assabet.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19#include "leds.h"
20
21
22#define LED_STATE_ENABLED 1
23#define LED_STATE_CLAIMED 2
24
25static unsigned int led_state;
26static unsigned int hw_led_state;
27
28#define ASSABET_BCR_LED_MASK (ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED)
29
30void assabet_leds_event(led_event_t evt)
31{
32 unsigned long flags;
33
34 local_irq_save(flags);
35
36 switch (evt) {
37 case led_start:
38 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
39 led_state = LED_STATE_ENABLED;
40 break;
41
42 case led_stop:
43 led_state &= ~LED_STATE_ENABLED;
44 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
45 ASSABET_BCR_frob(ASSABET_BCR_LED_MASK, hw_led_state);
46 break;
47
48 case led_claim:
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
51 break;
52
53 case led_release:
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN;
56 break;
57
58#ifdef CONFIG_LEDS_TIMER
59 case led_timer:
60 if (!(led_state & LED_STATE_CLAIMED))
61 hw_led_state ^= ASSABET_BCR_LED_GREEN;
62 break;
63#endif
64
65#ifdef CONFIG_LEDS_CPU
66 case led_idle_start:
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state |= ASSABET_BCR_LED_RED;
69 break;
70
71 case led_idle_end:
72 if (!(led_state & LED_STATE_CLAIMED))
73 hw_led_state &= ~ASSABET_BCR_LED_RED;
74 break;
75#endif
76
77 case led_halted:
78 break;
79
80 case led_green_on:
81 if (led_state & LED_STATE_CLAIMED)
82 hw_led_state &= ~ASSABET_BCR_LED_GREEN;
83 break;
84
85 case led_green_off:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state |= ASSABET_BCR_LED_GREEN;
88 break;
89
90 case led_amber_on:
91 break;
92
93 case led_amber_off:
94 break;
95
96 case led_red_on:
97 if (led_state & LED_STATE_CLAIMED)
98 hw_led_state &= ~ASSABET_BCR_LED_RED;
99 break;
100
101 case led_red_off:
102 if (led_state & LED_STATE_CLAIMED)
103 hw_led_state |= ASSABET_BCR_LED_RED;
104 break;
105
106 default:
107 break;
108 }
109
110 if (led_state & LED_STATE_ENABLED)
111 ASSABET_BCR_frob(ASSABET_BCR_LED_MASK, hw_led_state);
112
113 local_irq_restore(flags);
114}