2 * linux/arch/arm/mach-sa1100/leds-flexanet.c
4 * by Jordi Colomer <jco@ict.es>
8 * - Red - toggles state every 50 timer interrupts (Heartbeat)
9 * - Green - on if system is not idle (CPU load)
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_bcr
;
26 static unsigned int hw_led_gpio
;
29 void flexanet_leds_event(led_event_t evt
)
33 local_irq_save(flags
);
37 /* start using LEDs and enable its hardware */
38 hw_led_bcr
= FHH_BCR_LED_GREEN
;
39 hw_led_gpio
= GPIO_LED_RED
;
40 led_state
= LED_STATE_ENABLED
;
45 led_state
&= ~LED_STATE_ENABLED
;
49 /* select LEDs for direct access */
50 led_state
|= LED_STATE_CLAIMED
;
56 /* release LEDs from direct access */
57 led_state
&= ~LED_STATE_CLAIMED
;
62 #ifdef CONFIG_LEDS_TIMER
64 /* toggle heartbeat LED */
65 if (!(led_state
& LED_STATE_CLAIMED
))
66 hw_led_gpio
^= GPIO_LED_RED
;
70 #ifdef CONFIG_LEDS_CPU
72 /* turn off CPU load LED */
73 if (!(led_state
& LED_STATE_CLAIMED
))
74 hw_led_bcr
&= ~FHH_BCR_LED_GREEN
;
78 /* turn on CPU load LED */
79 if (!(led_state
& LED_STATE_CLAIMED
))
80 hw_led_bcr
|= FHH_BCR_LED_GREEN
;
88 /* direct LED access (must be previously claimed) */
90 if (led_state
& LED_STATE_CLAIMED
)
91 hw_led_bcr
|= FHH_BCR_LED_GREEN
;
95 if (led_state
& LED_STATE_CLAIMED
)
96 hw_led_bcr
&= ~FHH_BCR_LED_GREEN
;
106 if (led_state
& LED_STATE_CLAIMED
)
107 hw_led_gpio
|= GPIO_LED_RED
;
111 if (led_state
& LED_STATE_CLAIMED
)
112 hw_led_gpio
&= ~GPIO_LED_RED
;
119 if (led_state
& LED_STATE_ENABLED
)
122 FHH_BCR
= flexanet_BCR
= (flexanet_BCR
& ~FHH_BCR_LED_GREEN
) | hw_led_bcr
;
124 GPCR
= hw_led_gpio
^ GPIO_LED_RED
;
127 local_irq_restore(flags
);