2 * linux/arch/arm/mach-omap1/leds-h2p2-debug.c
4 * Copyright 2003 by Texas Instruments Incorporated
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").
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.
12 #include <linux/gpio.h>
13 #include <linux/init.h>
14 #include <linux/kernel_stat.h>
15 #include <linux/sched.h>
18 #include <mach/hardware.h>
20 #include <asm/mach-types.h>
22 #include <plat/fpga.h>
27 #define GPIO_LED_RED 3
28 #define GPIO_LED_GREEN OMAP_MPUIO(4)
31 #define LED_STATE_ENABLED 0x01
32 #define LED_STATE_CLAIMED 0x02
33 #define LED_TIMER_ON 0x04
35 #define GPIO_IDLE GPIO_LED_GREEN
36 #define GPIO_TIMER GPIO_LED_RED
39 void h2p2_dbg_leds_event(led_event_t evt
)
43 static struct h2p2_dbg_fpga __iomem
*fpga
;
44 static u16 led_state
, hw_led_state
;
46 local_irq_save(flags
);
48 if (!(led_state
& LED_STATE_ENABLED
) && evt
!= led_start
)
54 fpga
= ioremap(H2P2_DBG_FPGA_START
,
57 led_state
|= LED_STATE_ENABLED
;
58 __raw_writew(~0, &fpga
->leds
);
64 /* all leds off during suspend or shutdown */
66 if (! machine_is_omap_perseus2()) {
67 gpio_set_value(GPIO_TIMER
, 0);
68 gpio_set_value(GPIO_IDLE
, 0);
71 __raw_writew(~0, &fpga
->leds
);
72 led_state
&= ~LED_STATE_ENABLED
;
73 if (evt
== led_halted
) {
81 led_state
|= LED_STATE_CLAIMED
;
86 led_state
&= ~LED_STATE_CLAIMED
;
89 #ifdef CONFIG_LEDS_TIMER
91 led_state
^= LED_TIMER_ON
;
93 if (machine_is_omap_perseus2())
94 hw_led_state
^= H2P2_DBG_FPGA_P2_LED_TIMER
;
96 gpio_set_value(GPIO_TIMER
, led_state
& LED_TIMER_ON
);
103 #ifdef CONFIG_LEDS_CPU
105 if (machine_is_omap_perseus2())
106 hw_led_state
|= H2P2_DBG_FPGA_P2_LED_IDLE
;
108 gpio_set_value(GPIO_IDLE
, 1);
115 if (machine_is_omap_perseus2())
116 hw_led_state
&= ~H2P2_DBG_FPGA_P2_LED_IDLE
;
118 gpio_set_value(GPIO_IDLE
, 0);
126 hw_led_state
|= H2P2_DBG_FPGA_LED_GREEN
;
129 hw_led_state
&= ~H2P2_DBG_FPGA_LED_GREEN
;
133 hw_led_state
|= H2P2_DBG_FPGA_LED_AMBER
;
136 hw_led_state
&= ~H2P2_DBG_FPGA_LED_AMBER
;
140 hw_led_state
|= H2P2_DBG_FPGA_LED_RED
;
143 hw_led_state
&= ~H2P2_DBG_FPGA_LED_RED
;
147 hw_led_state
|= H2P2_DBG_FPGA_LED_BLUE
;
150 hw_led_state
&= ~H2P2_DBG_FPGA_LED_BLUE
;
159 * Actually burn the LEDs
161 if (led_state
& LED_STATE_ENABLED
)
162 __raw_writew(~hw_led_state
, &fpga
->leds
);
165 local_irq_restore(flags
);