Staging: hv: mousevsc: Cleanup alloc_input_device()
[zen-stable.git] / arch / arm / mach-pxa / leds-idp.c
blob8b9c17142d5a8ed89657eb83794ce4fd52071a05
1 /*
2 * linux/arch/arm/mach-pxa/leds-idp.c
4 * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
6 * Copyright (c) 2001 Jeff Sutherland <jeffs@accelent.com>
8 * Original (leds-footbridge.c) by Russell King
10 * Macros for actual LED manipulation should be in machine specific
11 * files in this 'mach' directory.
15 #include <linux/init.h>
17 #include <mach/hardware.h>
18 #include <asm/leds.h>
19 #include <asm/system.h>
21 #include <mach/pxa25x.h>
22 #include <mach/idp.h>
24 #include "leds.h"
26 #define LED_STATE_ENABLED 1
27 #define LED_STATE_CLAIMED 2
29 static unsigned int led_state;
30 static unsigned int hw_led_state;
32 void idp_leds_event(led_event_t evt)
34 unsigned long flags;
36 local_irq_save(flags);
38 switch (evt) {
39 case led_start:
40 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
41 led_state = LED_STATE_ENABLED;
42 break;
44 case led_stop:
45 led_state &= ~LED_STATE_ENABLED;
46 break;
48 case led_claim:
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
51 break;
53 case led_release:
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
56 break;
58 #ifdef CONFIG_LEDS_TIMER
59 case led_timer:
60 if (!(led_state & LED_STATE_CLAIMED))
61 hw_led_state ^= IDP_HB_LED;
62 break;
63 #endif
65 #ifdef CONFIG_LEDS_CPU
66 case led_idle_start:
67 if (!(led_state & LED_STATE_CLAIMED))
68 hw_led_state &= ~IDP_BUSY_LED;
69 break;
71 case led_idle_end:
72 if (!(led_state & LED_STATE_CLAIMED))
73 hw_led_state |= IDP_BUSY_LED;
74 break;
75 #endif
77 case led_halted:
78 break;
80 case led_green_on:
81 if (led_state & LED_STATE_CLAIMED)
82 hw_led_state |= IDP_HB_LED;
83 break;
85 case led_green_off:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state &= ~IDP_HB_LED;
88 break;
90 case led_amber_on:
91 break;
93 case led_amber_off:
94 break;
96 case led_red_on:
97 if (led_state & LED_STATE_CLAIMED)
98 hw_led_state |= IDP_BUSY_LED;
99 break;
101 case led_red_off:
102 if (led_state & LED_STATE_CLAIMED)
103 hw_led_state &= ~IDP_BUSY_LED;
104 break;
106 default:
107 break;
110 if (led_state & LED_STATE_ENABLED)
111 IDP_CPLD_LED_CONTROL = ( (IDP_CPLD_LED_CONTROL | IDP_LEDS_MASK) & ~hw_led_state);
112 else
113 IDP_CPLD_LED_CONTROL |= IDP_LEDS_MASK;
115 local_irq_restore(flags);