mv643xx_eth: 64bit mib counter read fix
[linux-2.6/mini2440.git] / arch / arm / mach-sa1100 / leds-badge4.c
blobcf1e38458b81c939ae3cf518a5c01ae687b02d79
1 /*
2 * linux/arch/arm/mach-sa1100/leds-badge4.c
4 * Author: Christopher Hoover <ch@hpl.hp.com>
5 * Copyright (C) 2002 Hewlett-Packard Company
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 #include <linux/init.h>
15 #include <mach/hardware.h>
16 #include <asm/leds.h>
17 #include <asm/system.h>
19 #include "leds.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_RED GPIO_GPIO(7)
28 #define LED_GREEN GPIO_GPIO(9)
29 #define LED_MASK (LED_RED|LED_GREEN)
31 #define LED_IDLE LED_GREEN
32 #define LED_TIMER LED_RED
34 void badge4_leds_event(led_event_t evt)
36 unsigned long flags;
38 local_irq_save(flags);
40 switch (evt) {
41 case led_start:
42 GPDR |= LED_MASK;
43 hw_led_state = LED_MASK;
44 led_state = LED_STATE_ENABLED;
45 break;
47 case led_stop:
48 led_state &= ~LED_STATE_ENABLED;
49 break;
51 case led_claim:
52 led_state |= LED_STATE_CLAIMED;
53 hw_led_state = LED_MASK;
54 break;
56 case led_release:
57 led_state &= ~LED_STATE_CLAIMED;
58 hw_led_state = LED_MASK;
59 break;
61 #ifdef CONFIG_LEDS_TIMER
62 case led_timer:
63 if (!(led_state & LED_STATE_CLAIMED))
64 hw_led_state ^= LED_TIMER;
65 break;
66 #endif
68 #ifdef CONFIG_LEDS_CPU
69 case led_idle_start:
70 /* LED off when system is idle */
71 if (!(led_state & LED_STATE_CLAIMED))
72 hw_led_state &= ~LED_IDLE;
73 break;
75 case led_idle_end:
76 if (!(led_state & LED_STATE_CLAIMED))
77 hw_led_state |= LED_IDLE;
78 break;
79 #endif
81 case led_red_on:
82 if (!(led_state & LED_STATE_CLAIMED))
83 hw_led_state &= ~LED_RED;
84 break;
86 case led_red_off:
87 if (!(led_state & LED_STATE_CLAIMED))
88 hw_led_state |= LED_RED;
89 break;
91 case led_green_on:
92 if (!(led_state & LED_STATE_CLAIMED))
93 hw_led_state &= ~LED_GREEN;
94 break;
96 case led_green_off:
97 if (!(led_state & LED_STATE_CLAIMED))
98 hw_led_state |= LED_GREEN;
99 break;
101 default:
102 break;
105 if (led_state & LED_STATE_ENABLED) {
106 GPSR = hw_led_state;
107 GPCR = hw_led_state ^ LED_MASK;
110 local_irq_restore(flags);