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/config.h>
13 #include <linux/init.h>
14 #include <linux/kernel_stat.h>
15 #include <linux/sched.h>
18 #include <asm/hardware.h>
20 #include <asm/system.h>
22 #include <asm/arch/fpga.h>
23 #include <asm/arch/gpio.h>
28 #define GPIO_LED_RED 3
29 #define GPIO_LED_GREEN OMAP_MPUIO(4)
32 #define LED_STATE_ENABLED 0x01
33 #define LED_STATE_CLAIMED 0x02
34 #define LED_TIMER_ON 0x04
36 #define GPIO_IDLE GPIO_LED_GREEN
37 #define GPIO_TIMER GPIO_LED_RED
40 void h2p2_dbg_leds_event(led_event_t evt)
44 static struct h2p2_dbg_fpga __iomem *fpga;
45 static u16 led_state, hw_led_state;
47 local_irq_save(flags);
49 if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
55 fpga = ioremap(H2P2_DBG_FPGA_START,
58 led_state |= LED_STATE_ENABLED;
59 __raw_writew(~0, &fpga->leds);
65 /* all leds off during suspend or shutdown */
66 omap_set_gpio_dataout(GPIO_TIMER, 0);
67 omap_set_gpio_dataout(GPIO_IDLE, 0);
68 __raw_writew(~0, &fpga->leds);
69 led_state &= ~LED_STATE_ENABLED;
70 if (evt == led_halted) {
77 led_state |= LED_STATE_CLAIMED;
82 led_state &= ~LED_STATE_CLAIMED;
85 #ifdef CONFIG_LEDS_TIMER
87 led_state ^= LED_TIMER_ON;
88 omap_set_gpio_dataout(GPIO_TIMER, led_state & LED_TIMER_ON);
92 #ifdef CONFIG_LEDS_CPU
94 omap_set_gpio_dataout(GPIO_IDLE, 1);
98 omap_set_gpio_dataout(GPIO_IDLE, 0);
103 hw_led_state |= H2P2_DBG_FPGA_LED_GREEN;
106 hw_led_state &= ~H2P2_DBG_FPGA_LED_GREEN;
110 hw_led_state |= H2P2_DBG_FPGA_LED_AMBER;
113 hw_led_state &= ~H2P2_DBG_FPGA_LED_AMBER;
117 hw_led_state |= H2P2_DBG_FPGA_LED_RED;
120 hw_led_state &= ~H2P2_DBG_FPGA_LED_RED;
124 hw_led_state |= H2P2_DBG_FPGA_LED_BLUE;
127 hw_led_state &= ~H2P2_DBG_FPGA_LED_BLUE;
136 * Actually burn the LEDs
138 if (led_state & LED_STATE_CLAIMED)
139 __raw_writew(~hw_led_state, &fpga->leds);
142 local_irq_restore(flags);