leds-trizeps4.c 2.6 KB

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