Jürgen Schindele | 326764a | 2006-06-29 16:01:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/leds-trizeps4.c |
| 3 | * |
| 4 | * Author: Jürgen Schindele |
| 5 | * Created: 20 02, 2006 |
| 6 | * Copyright: Jürgen Schindele |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
Jürgen Schindele | 326764a | 2006-06-29 16:01:43 +0100 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | |
| 15 | #include <asm/hardware.h> |
| 16 | #include <asm/system.h> |
| 17 | #include <asm/types.h> |
| 18 | #include <asm/leds.h> |
| 19 | |
| 20 | #include <asm/arch/pxa-regs.h> |
| 21 | #include <asm/arch/trizeps4.h> |
| 22 | |
| 23 | #include "leds.h" |
| 24 | |
| 25 | #define LED_STATE_ENABLED 1 |
| 26 | #define LED_STATE_CLAIMED 2 |
| 27 | |
| 28 | #define SYS_BUSY 0x01 |
| 29 | #define HEARTBEAT 0x02 |
| 30 | #define BLINK 0x04 |
| 31 | |
| 32 | static unsigned int led_state; |
| 33 | static unsigned int hw_led_state; |
| 34 | |
| 35 | void trizeps4_leds_event(led_event_t evt) |
| 36 | { |
| 37 | unsigned long flags; |
| 38 | |
| 39 | local_irq_save(flags); |
| 40 | |
| 41 | switch (evt) { |
| 42 | case led_start: |
| 43 | hw_led_state = 0; |
| 44 | pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */ |
| 45 | pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */ |
| 46 | led_state = LED_STATE_ENABLED; |
| 47 | break; |
| 48 | |
| 49 | case led_stop: |
| 50 | led_state &= ~LED_STATE_ENABLED; |
| 51 | break; |
| 52 | |
| 53 | case led_claim: |
| 54 | led_state |= LED_STATE_CLAIMED; |
| 55 | hw_led_state = 0; |
| 56 | break; |
| 57 | |
| 58 | case led_release: |
| 59 | led_state &= ~LED_STATE_CLAIMED; |
| 60 | hw_led_state = 0; |
| 61 | break; |
| 62 | |
| 63 | #ifdef CONFIG_LEDS_TIMER |
| 64 | case led_timer: |
| 65 | hw_led_state ^= HEARTBEAT; |
| 66 | break; |
| 67 | #endif |
| 68 | |
| 69 | #ifdef CONFIG_LEDS_CPU |
| 70 | case led_idle_start: |
| 71 | hw_led_state &= ~SYS_BUSY; |
| 72 | break; |
| 73 | |
| 74 | case led_idle_end: |
| 75 | hw_led_state |= SYS_BUSY; |
| 76 | break; |
| 77 | #endif |
| 78 | |
| 79 | case led_halted: |
| 80 | break; |
| 81 | |
| 82 | case led_green_on: |
| 83 | hw_led_state |= BLINK; |
| 84 | break; |
| 85 | |
| 86 | case led_green_off: |
| 87 | hw_led_state &= ~BLINK; |
| 88 | break; |
| 89 | |
| 90 | case led_amber_on: |
| 91 | break; |
| 92 | |
| 93 | case led_amber_off: |
| 94 | break; |
| 95 | |
| 96 | case led_red_on: |
| 97 | break; |
| 98 | |
| 99 | case led_red_off: |
| 100 | break; |
| 101 | |
| 102 | default: |
| 103 | break; |
| 104 | } |
| 105 | |
| 106 | if (led_state & LED_STATE_ENABLED) { |
| 107 | switch (hw_led_state) { |
| 108 | case 0: |
| 109 | GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED); |
| 110 | GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED); |
| 111 | break; |
| 112 | case 1: |
| 113 | GPCR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED); |
| 114 | GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED); |
| 115 | break; |
| 116 | case 2: |
| 117 | GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED); |
| 118 | GPCR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED); |
| 119 | break; |
| 120 | case 3: |
| 121 | GPCR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED); |
| 122 | GPCR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED); |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | else { |
| 127 | /* turn all off */ |
| 128 | GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED); |
| 129 | GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED); |
| 130 | } |
| 131 | |
| 132 | local_irq_restore(flags); |
| 133 | } |