aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2005-07-10 14:58:10 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-07-10 14:58:10 -0400
commit6f3e14163e066a6f43a54098a12185f25400fd68 (patch)
tree2c2818bbe759d4867df01dee69edd37540bcc30e /arch/arm/mach-omap1
parent3b59b6beb423267e8fe2ef3596d98aba0b910341 (diff)
[PATCH] ARM: 2799/1: OMAP update 4/11: Move OMAP1 LED code into mach-omap1 directory
Patch from Tony Lindgren This patch by Paul Mundt and other OMAP developers moves OMAP1 specific LED code into mach-omap1 directory. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-omap1')
-rw-r--r--arch/arm/mach-omap1/leds-h2p2-debug.c144
-rw-r--r--arch/arm/mach-omap1/leds-innovator.c103
-rw-r--r--arch/arm/mach-omap1/leds-osk.c194
-rw-r--r--arch/arm/mach-omap1/leds.c61
-rw-r--r--arch/arm/mach-omap1/leds.h3
5 files changed, 505 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/leds-h2p2-debug.c b/arch/arm/mach-omap1/leds-h2p2-debug.c
new file mode 100644
index 000000000000..6e98290cca5c
--- /dev/null
+++ b/arch/arm/mach-omap1/leds-h2p2-debug.c
@@ -0,0 +1,144 @@
1/*
2 * linux/arch/arm/mach-omap/leds-h2p2-debug.c
3 *
4 * Copyright 2003 by Texas Instruments Incorporated
5 *
6 * There are 16 LEDs on the debug board (all green); four may be used
7 * for logical 'green', 'amber', 'red', and 'blue' (after "claiming").
8 *
9 * The "surfer" expansion board and H2 sample board also have two-color
10 * green+red LEDs (in parallel), used here for timer and idle indicators.
11 */
12#include <linux/config.h>
13#include <linux/init.h>
14#include <linux/kernel_stat.h>
15#include <linux/sched.h>
16#include <linux/version.h>
17
18#include <asm/io.h>
19#include <asm/hardware.h>
20#include <asm/leds.h>
21#include <asm/system.h>
22
23#include <asm/arch/fpga.h>
24#include <asm/arch/gpio.h>
25
26#include "leds.h"
27
28
29#define GPIO_LED_RED 3
30#define GPIO_LED_GREEN OMAP_MPUIO(4)
31
32
33#define LED_STATE_ENABLED 0x01
34#define LED_STATE_CLAIMED 0x02
35#define LED_TIMER_ON 0x04
36
37#define GPIO_IDLE GPIO_LED_GREEN
38#define GPIO_TIMER GPIO_LED_RED
39
40
41void h2p2_dbg_leds_event(led_event_t evt)
42{
43 unsigned long flags;
44
45 static struct h2p2_dbg_fpga __iomem *fpga;
46 static u16 led_state, hw_led_state;
47
48 local_irq_save(flags);
49
50 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
51 goto done;
52
53 switch (evt) {
54 case led_start:
55 if (!fpga)
56 fpga = ioremap(H2P2_DBG_FPGA_START,
57 H2P2_DBG_FPGA_SIZE);
58 if (fpga) {
59 led_state |= LED_STATE_ENABLED;
60 __raw_writew(~0, &fpga->leds);
61 }
62 break;
63
64 case led_stop:
65 case led_halted:
66 /* all leds off during suspend or shutdown */
67 omap_set_gpio_dataout(GPIO_TIMER, 0);
68 omap_set_gpio_dataout(GPIO_IDLE, 0);
69 __raw_writew(~0, &fpga->leds);
70 led_state &= ~LED_STATE_ENABLED;
71 if (evt == led_halted) {
72 iounmap(fpga);
73 fpga = NULL;
74 }
75 goto done;
76
77 case led_claim:
78 led_state |= LED_STATE_CLAIMED;
79 hw_led_state = 0;
80 break;
81
82 case led_release:
83 led_state &= ~LED_STATE_CLAIMED;
84 break;
85
86#ifdef CONFIG_LEDS_TIMER
87 case led_timer:
88 led_state ^= LED_TIMER_ON;
89 omap_set_gpio_dataout(GPIO_TIMER, led_state & LED_TIMER_ON);
90 goto done;
91#endif
92
93#ifdef CONFIG_LEDS_CPU
94 case led_idle_start:
95 omap_set_gpio_dataout(GPIO_IDLE, 1);
96 goto done;
97
98 case led_idle_end:
99 omap_set_gpio_dataout(GPIO_IDLE, 0);
100 goto done;
101#endif
102
103 case led_green_on:
104 hw_led_state |= H2P2_DBG_FPGA_LED_GREEN;
105 break;
106 case led_green_off:
107 hw_led_state &= ~H2P2_DBG_FPGA_LED_GREEN;
108 break;
109
110 case led_amber_on:
111 hw_led_state |= H2P2_DBG_FPGA_LED_AMBER;
112 break;
113 case led_amber_off:
114 hw_led_state &= ~H2P2_DBG_FPGA_LED_AMBER;
115 break;
116
117 case led_red_on:
118 hw_led_state |= H2P2_DBG_FPGA_LED_RED;
119 break;
120 case led_red_off:
121 hw_led_state &= ~H2P2_DBG_FPGA_LED_RED;
122 break;
123
124 case led_blue_on:
125 hw_led_state |= H2P2_DBG_FPGA_LED_BLUE;
126 break;
127 case led_blue_off:
128 hw_led_state &= ~H2P2_DBG_FPGA_LED_BLUE;
129 break;
130
131 default:
132 break;
133 }
134
135
136 /*
137 * Actually burn the LEDs
138 */
139 if (led_state & LED_STATE_CLAIMED)
140 __raw_writew(~hw_led_state, &fpga->leds);
141
142done:
143 local_irq_restore(flags);
144}
diff --git a/arch/arm/mach-omap1/leds-innovator.c b/arch/arm/mach-omap1/leds-innovator.c
new file mode 100644
index 000000000000..8043b7d0f66e
--- /dev/null
+++ b/arch/arm/mach-omap1/leds-innovator.c
@@ -0,0 +1,103 @@
1/*
2 * linux/arch/arm/mach-omap/leds-innovator.c
3 */
4#include <linux/config.h>
5#include <linux/init.h>
6
7#include <asm/hardware.h>
8#include <asm/leds.h>
9#include <asm/system.h>
10
11#include "leds.h"
12
13
14#define LED_STATE_ENABLED 1
15#define LED_STATE_CLAIMED 2
16
17static unsigned int led_state;
18static unsigned int hw_led_state;
19
20void innovator_leds_event(led_event_t evt)
21{
22 unsigned long flags;
23
24 local_irq_save(flags);
25
26 switch (evt) {
27 case led_start:
28 hw_led_state = 0;
29 led_state = LED_STATE_ENABLED;
30 break;
31
32 case led_stop:
33 led_state &= ~LED_STATE_ENABLED;
34 hw_led_state = 0;
35 break;
36
37 case led_claim:
38 led_state |= LED_STATE_CLAIMED;
39 hw_led_state = 0;
40 break;
41
42 case led_release:
43 led_state &= ~LED_STATE_CLAIMED;
44 hw_led_state = 0;
45 break;
46
47#ifdef CONFIG_LEDS_TIMER
48 case led_timer:
49 if (!(led_state & LED_STATE_CLAIMED))
50 hw_led_state ^= 0;
51 break;
52#endif
53
54#ifdef CONFIG_LEDS_CPU
55 case led_idle_start:
56 if (!(led_state & LED_STATE_CLAIMED))
57 hw_led_state |= 0;
58 break;
59
60 case led_idle_end:
61 if (!(led_state & LED_STATE_CLAIMED))
62 hw_led_state &= ~0;
63 break;
64#endif
65
66 case led_halted:
67 break;
68
69 case led_green_on:
70 if (led_state & LED_STATE_CLAIMED)
71 hw_led_state &= ~0;
72 break;
73
74 case led_green_off:
75 if (led_state & LED_STATE_CLAIMED)
76 hw_led_state |= 0;
77 break;
78
79 case led_amber_on:
80 break;
81
82 case led_amber_off:
83 break;
84
85 case led_red_on:
86 if (led_state & LED_STATE_CLAIMED)
87 hw_led_state &= ~0;
88 break;
89
90 case led_red_off:
91 if (led_state & LED_STATE_CLAIMED)
92 hw_led_state |= 0;
93 break;
94
95 default:
96 break;
97 }
98
99 if (led_state & LED_STATE_ENABLED)
100 ;
101
102 local_irq_restore(flags);
103}
diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c
new file mode 100644
index 000000000000..4a0e8b9d4fc3
--- /dev/null
+++ b/arch/arm/mach-omap1/leds-osk.c
@@ -0,0 +1,194 @@
1/*
2 * linux/arch/arm/mach-omap/leds-osk.c
3 *
4 * LED driver for OSK, and optionally Mistral QVGA, boards
5 */
6#include <linux/config.h>
7#include <linux/init.h>
8#include <linux/workqueue.h>
9
10#include <asm/hardware.h>
11#include <asm/leds.h>
12#include <asm/system.h>
13
14#include <asm/arch/gpio.h>
15#include <asm/arch/tps65010.h>
16
17#include "leds.h"
18
19
20#define LED_STATE_ENABLED (1 << 0)
21#define LED_STATE_CLAIMED (1 << 1)
22static u8 led_state;
23
24#define GREEN_LED (1 << 0) /* TPS65010 LED1 */
25#define AMBER_LED (1 << 1) /* TPS65010 LED2 */
26#define RED_LED (1 << 2) /* TPS65010 GPIO2 */
27#define TIMER_LED (1 << 3) /* Mistral board */
28#define IDLE_LED (1 << 4) /* Mistral board */
29static u8 hw_led_state;
30
31
32/* TPS65010 leds are changed using i2c -- from a task context.
33 * Using one of these for the "idle" LED would be impractical...
34 */
35#define TPS_LEDS (GREEN_LED | RED_LED | AMBER_LED)
36
37static u8 tps_leds_change;
38
39static void tps_work(void *unused)
40{
41 for (;;) {
42 u8 leds;
43
44 local_irq_disable();
45 leds = tps_leds_change;
46 tps_leds_change = 0;
47 local_irq_enable();
48
49 if (!leds)
50 break;
51
52 /* careful: the set_led() value is on/off/blink */
53 if (leds & GREEN_LED)
54 tps65010_set_led(LED1, !!(hw_led_state & GREEN_LED));
55 if (leds & AMBER_LED)
56 tps65010_set_led(LED2, !!(hw_led_state & AMBER_LED));
57
58 /* the gpio led doesn't have that issue */
59 if (leds & RED_LED)
60 tps65010_set_gpio_out_value(GPIO2,
61 !(hw_led_state & RED_LED));
62 }
63}
64
65static DECLARE_WORK(work, tps_work, NULL);
66
67#ifdef CONFIG_FB_OMAP
68
69/* For now, all system indicators require the Mistral board, since that
70 * LED can be manipulated without a task context. This LED is either red,
71 * or green, but not both; it can't give the full "disco led" effect.
72 */
73
74#define GPIO_LED_RED 3
75#define GPIO_LED_GREEN OMAP_MPUIO(4)
76
77static void mistral_setled(void)
78{
79 int red = 0;
80 int green = 0;
81
82 if (hw_led_state & TIMER_LED)
83 red = 1;
84 else if (hw_led_state & IDLE_LED)
85 green = 1;
86 // else both sides are disabled
87
88 omap_set_gpio_dataout(GPIO_LED_GREEN, green);
89 omap_set_gpio_dataout(GPIO_LED_RED, red);
90}
91
92#endif
93
94void osk_leds_event(led_event_t evt)
95{
96 unsigned long flags;
97 u16 leds;
98
99 local_irq_save(flags);
100
101 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
102 goto done;
103
104 leds = hw_led_state;
105 switch (evt) {
106 case led_start:
107 led_state |= LED_STATE_ENABLED;
108 hw_led_state = 0;
109 leds = ~0;
110 break;
111
112 case led_halted:
113 case led_stop:
114 led_state &= ~LED_STATE_ENABLED;
115 hw_led_state = 0;
116 // NOTE: work may still be pending!!
117 break;
118
119 case led_claim:
120 led_state |= LED_STATE_CLAIMED;
121 hw_led_state = 0;
122 leds = ~0;
123 break;
124
125 case led_release:
126 led_state &= ~LED_STATE_CLAIMED;
127 hw_led_state = 0;
128 break;
129
130#ifdef CONFIG_FB_OMAP
131
132 case led_timer:
133 hw_led_state ^= TIMER_LED;
134 mistral_setled();
135 break;
136
137 case led_idle_start:
138 hw_led_state |= IDLE_LED;
139 mistral_setled();
140 break;
141
142 case led_idle_end:
143 hw_led_state &= ~IDLE_LED;
144 mistral_setled();
145 break;
146
147#endif /* CONFIG_FB_OMAP */
148
149 /* "green" == tps LED1 (leftmost, normally power-good)
150 * works only with DC adapter, not on battery power!
151 */
152 case led_green_on:
153 if (led_state & LED_STATE_CLAIMED)
154 hw_led_state |= GREEN_LED;
155 break;
156 case led_green_off:
157 if (led_state & LED_STATE_CLAIMED)
158 hw_led_state &= ~GREEN_LED;
159 break;
160
161 /* "amber" == tps LED2 (middle) */
162 case led_amber_on:
163 if (led_state & LED_STATE_CLAIMED)
164 hw_led_state |= AMBER_LED;
165 break;
166 case led_amber_off:
167 if (led_state & LED_STATE_CLAIMED)
168 hw_led_state &= ~AMBER_LED;
169 break;
170
171 /* "red" == LED on tps gpio3 (rightmost) */
172 case led_red_on:
173 if (led_state & LED_STATE_CLAIMED)
174 hw_led_state |= RED_LED;
175 break;
176 case led_red_off:
177 if (led_state & LED_STATE_CLAIMED)
178 hw_led_state &= ~RED_LED;
179 break;
180
181 default:
182 break;
183 }
184
185 leds ^= hw_led_state;
186 leds &= TPS_LEDS;
187 if (leds && (led_state & LED_STATE_CLAIMED)) {
188 tps_leds_change |= leds;
189 schedule_work(&work);
190 }
191
192done:
193 local_irq_restore(flags);
194}
diff --git a/arch/arm/mach-omap1/leds.c b/arch/arm/mach-omap1/leds.c
new file mode 100644
index 000000000000..8ab21fe98e1b
--- /dev/null
+++ b/arch/arm/mach-omap1/leds.c
@@ -0,0 +1,61 @@
1/*
2 * linux/arch/arm/mach-omap/leds.c
3 *
4 * OMAP LEDs dispatcher
5 */
6#include <linux/kernel.h>
7#include <linux/init.h>
8
9#include <asm/leds.h>
10#include <asm/mach-types.h>
11
12#include <asm/arch/gpio.h>
13#include <asm/arch/mux.h>
14
15#include "leds.h"
16
17static int __init
18omap_leds_init(void)
19{
20 if (machine_is_omap_innovator())
21 leds_event = innovator_leds_event;
22
23 else if (machine_is_omap_h2() || machine_is_omap_perseus2())
24 leds_event = h2p2_dbg_leds_event;
25
26 else if (machine_is_omap_osk())
27 leds_event = osk_leds_event;
28
29 else
30 return -1;
31
32 if (machine_is_omap_h2()
33 || machine_is_omap_perseus2()
34 || machine_is_omap_osk()) {
35
36 /* LED1/LED2 pins can be used as GPIO (as done here), or by
37 * the LPG (works even in deep sleep!), to drive a bicolor
38 * LED on the H2 sample board, and another on the H2/P2
39 * "surfer" expansion board.
40 *
41 * The same pins drive a LED on the OSK Mistral board, but
42 * that's a different kind of LED (just one color at a time).
43 */
44 omap_cfg_reg(P18_1610_GPIO3);
45 if (omap_request_gpio(3) == 0)
46 omap_set_gpio_direction(3, 0);
47 else
48 printk(KERN_WARNING "LED: can't get GPIO3/red?\n");
49
50 omap_cfg_reg(MPUIO4);
51 if (omap_request_gpio(OMAP_MPUIO(4)) == 0)
52 omap_set_gpio_direction(OMAP_MPUIO(4), 0);
53 else
54 printk(KERN_WARNING "LED: can't get MPUIO4/green?\n");
55 }
56
57 leds_event(led_start);
58 return 0;
59}
60
61__initcall(omap_leds_init);
diff --git a/arch/arm/mach-omap1/leds.h b/arch/arm/mach-omap1/leds.h
new file mode 100644
index 000000000000..a1e9fedc376c
--- /dev/null
+++ b/arch/arm/mach-omap1/leds.h
@@ -0,0 +1,3 @@
1extern void innovator_leds_event(led_event_t evt);
2extern void h2p2_dbg_leds_event(led_event_t evt);
3extern void osk_leds_event(led_event_t evt);