blob: 8b9c17142d5a8ed89657eb83794ce4fd52071a05 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-pxa/leds-idp.c
3 *
4 * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
5 *
6 * Copyright (c) 2001 Jeff Sutherland <jeffs@accelent.com>
7 *
8 * Original (leds-footbridge.c) by Russell King
9 *
10 * Macros for actual LED manipulation should be in machine specific
11 * files in this 'mach' directory.
12 */
13
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/init.h>
16
Russell Kinga09e64f2008-08-05 16:14:15 +010017#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/leds.h>
19#include <asm/system.h>
20
Eric Miao51c62982009-01-02 23:17:22 +080021#include <mach/pxa25x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/idp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include "leds.h"
25
26#define LED_STATE_ENABLED 1
27#define LED_STATE_CLAIMED 2
28
29static unsigned int led_state;
30static unsigned int hw_led_state;
31
32void idp_leds_event(led_event_t evt)
33{
34 unsigned long flags;
35
36 local_irq_save(flags);
37
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;
43
44 case led_stop:
45 led_state &= ~LED_STATE_ENABLED;
46 break;
47
48 case led_claim:
49 led_state |= LED_STATE_CLAIMED;
50 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
51 break;
52
53 case led_release:
54 led_state &= ~LED_STATE_CLAIMED;
55 hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
56 break;
57
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
64
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;
70
71 case led_idle_end:
72 if (!(led_state & LED_STATE_CLAIMED))
73 hw_led_state |= IDP_BUSY_LED;
74 break;
75#endif
76
77 case led_halted:
78 break;
79
80 case led_green_on:
81 if (led_state & LED_STATE_CLAIMED)
82 hw_led_state |= IDP_HB_LED;
83 break;
84
85 case led_green_off:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state &= ~IDP_HB_LED;
88 break;
89
90 case led_amber_on:
91 break;
92
93 case led_amber_off:
94 break;
95
96 case led_red_on:
97 if (led_state & LED_STATE_CLAIMED)
98 hw_led_state |= IDP_BUSY_LED;
99 break;
100
101 case led_red_off:
102 if (led_state & LED_STATE_CLAIMED)
103 hw_led_state &= ~IDP_BUSY_LED;
104 break;
105
106 default:
107 break;
108 }
109
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;
114
115 local_irq_restore(flags);
116}