Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / arm / mach-pxa / leds-lubbock.c
blob05cf56059a0f11273f045a6757fe36cddb21b540
1 /*
2 * linux/arch/arm/mach-pxa/leds-lubbock.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 * Major surgery on April 2004 by Nicolas Pitre for less global
11 * namespace collision. Mostly adapted the Mainstone version.
14 #include <linux/config.h>
15 #include <linux/init.h>
17 #include <asm/hardware.h>
18 #include <asm/leds.h>
19 #include <asm/system.h>
20 #include <asm/arch/pxa-regs.h>
21 #include <asm/arch/lubbock.h>
23 #include "leds.h"
26 * 8 discrete leds available for general use:
28 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
29 * so be sure to not monkey with them here.
32 #define D28 (1 << 0)
33 #define D27 (1 << 1)
34 #define D26 (1 << 2)
35 #define D25 (1 << 3)
36 #define D24 (1 << 4)
37 #define D23 (1 << 5)
38 #define D22 (1 << 6)
39 #define D21 (1 << 7)
41 #define LED_STATE_ENABLED 1
42 #define LED_STATE_CLAIMED 2
44 static unsigned int led_state;
45 static unsigned int hw_led_state;
47 void lubbock_leds_event(led_event_t evt)
49 unsigned long flags;
51 local_irq_save(flags);
53 switch (evt) {
54 case led_start:
55 hw_led_state = 0;
56 led_state = LED_STATE_ENABLED;
57 break;
59 case led_stop:
60 led_state &= ~LED_STATE_ENABLED;
61 break;
63 case led_claim:
64 led_state |= LED_STATE_CLAIMED;
65 hw_led_state = 0;
66 break;
68 case led_release:
69 led_state &= ~LED_STATE_CLAIMED;
70 hw_led_state = 0;
71 break;
73 #ifdef CONFIG_LEDS_TIMER
74 case led_timer:
75 hw_led_state ^= D26;
76 break;
77 #endif
79 #ifdef CONFIG_LEDS_CPU
80 case led_idle_start:
81 hw_led_state &= ~D27;
82 break;
84 case led_idle_end:
85 hw_led_state |= D27;
86 break;
87 #endif
89 case led_halted:
90 break;
92 case led_green_on:
93 hw_led_state |= D21;
94 break;
96 case led_green_off:
97 hw_led_state &= ~D21;
98 break;
100 case led_amber_on:
101 hw_led_state |= D22;
102 break;
104 case led_amber_off:
105 hw_led_state &= ~D22;
106 break;
108 case led_red_on:
109 hw_led_state |= D23;
110 break;
112 case led_red_off:
113 hw_led_state &= ~D23;
114 break;
116 default:
117 break;
120 if (led_state & LED_STATE_ENABLED)
121 LUB_DISC_BLNK_LED = (LUB_DISC_BLNK_LED | 0xff) & ~hw_led_state;
122 else
123 LUB_DISC_BLNK_LED |= 0xff;
125 local_irq_restore(flags);