2 * linux/arch/arm/mach-sa1100/leds-brutus.c
4 * Copyright (C) 2000 Nicolas Pitre
6 * Brutus uses the LEDs as follows:
7 * - D3 (Green, GPIO9) - toggles state every 50 timer interrupts
8 * - D17 (Red, GPIO20) - on if system is not idle
9 * - D4 (Green, GPIO8) - misc function
11 #include <linux/config.h>
12 #include <linux/init.h>
14 #include <asm/hardware.h>
16 #include <asm/system.h>
21 #define LED_STATE_ENABLED 1
22 #define LED_STATE_CLAIMED 2
24 static unsigned int led_state;
25 static unsigned int hw_led_state;
27 #define LED_D3 GPIO_GPIO(9)
28 #define LED_D4 GPIO_GPIO(8)
29 #define LED_D17 GPIO_GPIO(20)
30 #define LED_MASK (LED_D3|LED_D4|LED_D17)
32 void brutus_leds_event(led_event_t evt)
36 local_irq_save(flags);
40 hw_led_state = LED_MASK;
41 led_state = LED_STATE_ENABLED;
45 led_state &= ~LED_STATE_ENABLED;
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = LED_MASK;
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = LED_MASK;
58 #ifdef CONFIG_LEDS_TIMER
60 if (!(led_state & LED_STATE_CLAIMED))
61 hw_led_state ^= LED_D3;
65 #ifdef CONFIG_LEDS_CPU
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state |= LED_D17;
72 if (!(led_state & LED_STATE_CLAIMED))
73 hw_led_state &= ~LED_D17;
78 hw_led_state &= ~LED_D4;
82 hw_led_state |= LED_D4;
92 if (led_state & LED_STATE_CLAIMED)
93 hw_led_state &= ~LED_D17;
97 if (led_state & LED_STATE_CLAIMED)
98 hw_led_state |= LED_D17;
105 if (led_state & LED_STATE_ENABLED) {
107 GPCR = hw_led_state ^ LED_MASK;
110 local_irq_restore(flags);