Path: blob/master/arch/arm/mach-omap1/leds-h2p2-debug.c
10817 views
/*1* linux/arch/arm/mach-omap1/leds-h2p2-debug.c2*3* Copyright 2003 by Texas Instruments Incorporated4*5* There are 16 LEDs on the debug board (all green); four may be used6* for logical 'green', 'amber', 'red', and 'blue' (after "claiming").7*8* The "surfer" expansion board and H2 sample board also have two-color9* green+red LEDs (in parallel), used here for timer and idle indicators.10*/11#include <linux/init.h>12#include <linux/kernel_stat.h>13#include <linux/sched.h>14#include <linux/io.h>1516#include <mach/hardware.h>17#include <asm/leds.h>18#include <asm/system.h>19#include <asm/mach-types.h>2021#include <plat/fpga.h>22#include <mach/gpio.h>2324#include "leds.h"252627#define GPIO_LED_RED 328#define GPIO_LED_GREEN OMAP_MPUIO(4)293031#define LED_STATE_ENABLED 0x0132#define LED_STATE_CLAIMED 0x0233#define LED_TIMER_ON 0x043435#define GPIO_IDLE GPIO_LED_GREEN36#define GPIO_TIMER GPIO_LED_RED373839void h2p2_dbg_leds_event(led_event_t evt)40{41unsigned long flags;4243static struct h2p2_dbg_fpga __iomem *fpga;44static u16 led_state, hw_led_state;4546local_irq_save(flags);4748if (!(led_state & LED_STATE_ENABLED) && evt != led_start)49goto done;5051switch (evt) {52case led_start:53if (!fpga)54fpga = ioremap(H2P2_DBG_FPGA_START,55H2P2_DBG_FPGA_SIZE);56if (fpga) {57led_state |= LED_STATE_ENABLED;58__raw_writew(~0, &fpga->leds);59}60break;6162case led_stop:63case led_halted:64/* all leds off during suspend or shutdown */6566if (! machine_is_omap_perseus2()) {67gpio_set_value(GPIO_TIMER, 0);68gpio_set_value(GPIO_IDLE, 0);69}7071__raw_writew(~0, &fpga->leds);72led_state &= ~LED_STATE_ENABLED;73if (evt == led_halted) {74iounmap(fpga);75fpga = NULL;76}7778goto done;7980case led_claim:81led_state |= LED_STATE_CLAIMED;82hw_led_state = 0;83break;8485case led_release:86led_state &= ~LED_STATE_CLAIMED;87break;8889#ifdef CONFIG_LEDS_TIMER90case led_timer:91led_state ^= LED_TIMER_ON;9293if (machine_is_omap_perseus2())94hw_led_state ^= H2P2_DBG_FPGA_P2_LED_TIMER;95else {96gpio_set_value(GPIO_TIMER, led_state & LED_TIMER_ON);97goto done;98}99100break;101#endif102103#ifdef CONFIG_LEDS_CPU104case led_idle_start:105if (machine_is_omap_perseus2())106hw_led_state |= H2P2_DBG_FPGA_P2_LED_IDLE;107else {108gpio_set_value(GPIO_IDLE, 1);109goto done;110}111112break;113114case led_idle_end:115if (machine_is_omap_perseus2())116hw_led_state &= ~H2P2_DBG_FPGA_P2_LED_IDLE;117else {118gpio_set_value(GPIO_IDLE, 0);119goto done;120}121122break;123#endif124125case led_green_on:126hw_led_state |= H2P2_DBG_FPGA_LED_GREEN;127break;128case led_green_off:129hw_led_state &= ~H2P2_DBG_FPGA_LED_GREEN;130break;131132case led_amber_on:133hw_led_state |= H2P2_DBG_FPGA_LED_AMBER;134break;135case led_amber_off:136hw_led_state &= ~H2P2_DBG_FPGA_LED_AMBER;137break;138139case led_red_on:140hw_led_state |= H2P2_DBG_FPGA_LED_RED;141break;142case led_red_off:143hw_led_state &= ~H2P2_DBG_FPGA_LED_RED;144break;145146case led_blue_on:147hw_led_state |= H2P2_DBG_FPGA_LED_BLUE;148break;149case led_blue_off:150hw_led_state &= ~H2P2_DBG_FPGA_LED_BLUE;151break;152153default:154break;155}156157158/*159* Actually burn the LEDs160*/161if (led_state & LED_STATE_ENABLED)162__raw_writew(~hw_led_state, &fpga->leds);163164done:165local_irq_restore(flags);166}167168169