leds-trizeps4.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. #include <linux/config.h>
  13. #include <linux/init.h>
  14. #include <asm/hardware.h>
  15. #include <asm/system.h>
  16. #include <asm/types.h>
  17. #include <asm/leds.h>
  18. #include <asm/arch/pxa-regs.h>
  19. #include <asm/arch/trizeps4.h>
  20. #include "leds.h"
  21. #define LED_STATE_ENABLED 1
  22. #define LED_STATE_CLAIMED 2
  23. #define SYS_BUSY 0x01
  24. #define HEARTBEAT 0x02
  25. #define BLINK 0x04
  26. static unsigned int led_state;
  27. static unsigned int hw_led_state;
  28. void trizeps4_leds_event(led_event_t evt)
  29. {
  30. unsigned long flags;
  31. local_irq_save(flags);
  32. switch (evt) {
  33. case led_start:
  34. hw_led_state = 0;
  35. pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */
  36. pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */
  37. led_state = LED_STATE_ENABLED;
  38. break;
  39. case led_stop:
  40. led_state &= ~LED_STATE_ENABLED;
  41. break;
  42. case led_claim:
  43. led_state |= LED_STATE_CLAIMED;
  44. hw_led_state = 0;
  45. break;
  46. case led_release:
  47. led_state &= ~LED_STATE_CLAIMED;
  48. hw_led_state = 0;
  49. break;
  50. #ifdef CONFIG_LEDS_TIMER
  51. case led_timer:
  52. hw_led_state ^= HEARTBEAT;
  53. break;
  54. #endif
  55. #ifdef CONFIG_LEDS_CPU
  56. case led_idle_start:
  57. hw_led_state &= ~SYS_BUSY;
  58. break;
  59. case led_idle_end:
  60. hw_led_state |= SYS_BUSY;
  61. break;
  62. #endif
  63. case led_halted:
  64. break;
  65. case led_green_on:
  66. hw_led_state |= BLINK;
  67. break;
  68. case led_green_off:
  69. hw_led_state &= ~BLINK;
  70. break;
  71. case led_amber_on:
  72. break;
  73. case led_amber_off:
  74. break;
  75. case led_red_on:
  76. break;
  77. case led_red_off:
  78. break;
  79. default:
  80. break;
  81. }
  82. if (led_state & LED_STATE_ENABLED) {
  83. switch (hw_led_state) {
  84. case 0:
  85. GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
  86. GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
  87. break;
  88. case 1:
  89. GPCR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
  90. GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
  91. break;
  92. case 2:
  93. GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
  94. GPCR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
  95. break;
  96. case 3:
  97. GPCR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
  98. GPCR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
  99. break;
  100. }
  101. }
  102. else {
  103. /* turn all off */
  104. GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
  105. GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
  106. }
  107. local_irq_restore(flags);
  108. }