leds-cerf.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * linux/arch/arm/mach-sa1100/leds-cerf.c
  3. *
  4. * Author: ???
  5. */
  6. #include <linux/init.h>
  7. #include <mach/hardware.h>
  8. #include <asm/leds.h>
  9. #include <asm/system.h>
  10. #include "leds.h"
  11. #define LED_STATE_ENABLED 1
  12. #define LED_STATE_CLAIMED 2
  13. static unsigned int led_state;
  14. static unsigned int hw_led_state;
  15. #define LED_D0 GPIO_GPIO(0)
  16. #define LED_D1 GPIO_GPIO(1)
  17. #define LED_D2 GPIO_GPIO(2)
  18. #define LED_D3 GPIO_GPIO(3)
  19. #define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3)
  20. void cerf_leds_event(led_event_t evt)
  21. {
  22. unsigned long flags;
  23. local_irq_save(flags);
  24. switch (evt) {
  25. case led_start:
  26. hw_led_state = LED_MASK;
  27. led_state = LED_STATE_ENABLED;
  28. break;
  29. case led_stop:
  30. led_state &= ~LED_STATE_ENABLED;
  31. break;
  32. case led_claim:
  33. led_state |= LED_STATE_CLAIMED;
  34. hw_led_state = LED_MASK;
  35. break;
  36. case led_release:
  37. led_state &= ~LED_STATE_CLAIMED;
  38. hw_led_state = LED_MASK;
  39. break;
  40. #ifdef CONFIG_LEDS_TIMER
  41. case led_timer:
  42. if (!(led_state & LED_STATE_CLAIMED))
  43. hw_led_state ^= LED_D0;
  44. break;
  45. #endif
  46. #ifdef CONFIG_LEDS_CPU
  47. case led_idle_start:
  48. if (!(led_state & LED_STATE_CLAIMED))
  49. hw_led_state &= ~LED_D1;
  50. break;
  51. case led_idle_end:
  52. if (!(led_state & LED_STATE_CLAIMED))
  53. hw_led_state |= LED_D1;
  54. break;
  55. #endif
  56. case led_green_on:
  57. if (!(led_state & LED_STATE_CLAIMED))
  58. hw_led_state &= ~LED_D2;
  59. break;
  60. case led_green_off:
  61. if (!(led_state & LED_STATE_CLAIMED))
  62. hw_led_state |= LED_D2;
  63. break;
  64. case led_amber_on:
  65. if (!(led_state & LED_STATE_CLAIMED))
  66. hw_led_state &= ~LED_D3;
  67. break;
  68. case led_amber_off:
  69. if (!(led_state & LED_STATE_CLAIMED))
  70. hw_led_state |= LED_D3;
  71. break;
  72. case led_red_on:
  73. if (!(led_state & LED_STATE_CLAIMED))
  74. hw_led_state &= ~LED_D1;
  75. break;
  76. case led_red_off:
  77. if (!(led_state & LED_STATE_CLAIMED))
  78. hw_led_state |= LED_D1;
  79. break;
  80. default:
  81. break;
  82. }
  83. if (led_state & LED_STATE_ENABLED) {
  84. GPSR = hw_led_state;
  85. GPCR = hw_led_state ^ LED_MASK;
  86. }
  87. local_irq_restore(flags);
  88. }