2 * linux/arch/arm/mach-omap/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/config.h>
13 #include <linux/init.h>
14 #include <linux/kernel_stat.h>
15 #include <linux/sched.h>
16 #include <linux/version.h>
19 #include <asm/hardware.h>
21 #include <asm/system.h>
23 #include <asm/arch/fpga.h>
24 #include <asm/arch/gpio.h>
29 #define GPIO_LED_RED 3
30 #define GPIO_LED_GREEN OMAP_MPUIO(4)
33 #define LED_STATE_ENABLED 0x01
34 #define LED_STATE_CLAIMED 0x02
35 #define LED_TIMER_ON 0x04
37 #define GPIO_IDLE GPIO_LED_GREEN
38 #define GPIO_TIMER GPIO_LED_RED
41 void h2p2_dbg_leds_event(led_event_t evt
)
45 static struct h2p2_dbg_fpga __iomem
*fpga
;
46 static u16 led_state
, hw_led_state
;
48 local_irq_save(flags
);
50 if (!(led_state
& LED_STATE_ENABLED
) && evt
!= led_start
)
56 fpga
= ioremap(H2P2_DBG_FPGA_START
,
59 led_state
|= LED_STATE_ENABLED
;
60 __raw_writew(~0, &fpga
->leds
);
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
) {
78 led_state
|= LED_STATE_CLAIMED
;
83 led_state
&= ~LED_STATE_CLAIMED
;
86 #ifdef CONFIG_LEDS_TIMER
88 led_state
^= LED_TIMER_ON
;
89 omap_set_gpio_dataout(GPIO_TIMER
, led_state
& LED_TIMER_ON
);
93 #ifdef CONFIG_LEDS_CPU
95 omap_set_gpio_dataout(GPIO_IDLE
, 1);
99 omap_set_gpio_dataout(GPIO_IDLE
, 0);
104 hw_led_state
|= H2P2_DBG_FPGA_LED_GREEN
;
107 hw_led_state
&= ~H2P2_DBG_FPGA_LED_GREEN
;
111 hw_led_state
|= H2P2_DBG_FPGA_LED_AMBER
;
114 hw_led_state
&= ~H2P2_DBG_FPGA_LED_AMBER
;
118 hw_led_state
|= H2P2_DBG_FPGA_LED_RED
;
121 hw_led_state
&= ~H2P2_DBG_FPGA_LED_RED
;
125 hw_led_state
|= H2P2_DBG_FPGA_LED_BLUE
;
128 hw_led_state
&= ~H2P2_DBG_FPGA_LED_BLUE
;
137 * Actually burn the LEDs
139 if (led_state
& LED_STATE_CLAIMED
)
140 __raw_writew(~hw_led_state
, &fpga
->leds
);
143 local_irq_restore(flags
);