leds-lart.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * linux/arch/arm/mach-sa1100/leds-lart.c
  3. *
  4. * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000
  5. *
  6. * LART uses the LED as follows:
  7. * - GPIO23 is the LED, on if system is not idle
  8. * You can use both CONFIG_LEDS_CPU and CONFIG_LEDS_TIMER at the same
  9. * time, but in that case the timer events will still dictate the
  10. * pace of the LED.
  11. */
  12. #include <linux/init.h>
  13. #include <mach/hardware.h>
  14. #include <asm/leds.h>
  15. #include <asm/system.h>
  16. #include "leds.h"
  17. #define LED_STATE_ENABLED 1
  18. #define LED_STATE_CLAIMED 2
  19. static unsigned int led_state;
  20. static unsigned int hw_led_state;
  21. #define LED_23 GPIO_GPIO23
  22. #define LED_MASK (LED_23)
  23. void lart_leds_event(led_event_t evt)
  24. {
  25. unsigned long flags;
  26. local_irq_save(flags);
  27. switch(evt) {
  28. case led_start:
  29. /* pin 23 is output pin */
  30. GPDR |= LED_23;
  31. hw_led_state = LED_MASK;
  32. led_state = LED_STATE_ENABLED;
  33. break;
  34. case led_stop:
  35. led_state &= ~LED_STATE_ENABLED;
  36. break;
  37. case led_claim:
  38. led_state |= LED_STATE_CLAIMED;
  39. hw_led_state = LED_MASK;
  40. break;
  41. case led_release:
  42. led_state &= ~LED_STATE_CLAIMED;
  43. hw_led_state = LED_MASK;
  44. break;
  45. #ifdef CONFIG_LEDS_TIMER
  46. case led_timer:
  47. if (!(led_state & LED_STATE_CLAIMED))
  48. hw_led_state ^= LED_23;
  49. break;
  50. #endif
  51. #ifdef CONFIG_LEDS_CPU
  52. case led_idle_start:
  53. /* The LART people like the LED to be off when the
  54. system is idle... */
  55. if (!(led_state & LED_STATE_CLAIMED))
  56. hw_led_state &= ~LED_23;
  57. break;
  58. case led_idle_end:
  59. /* ... and on if the system is not idle */
  60. if (!(led_state & LED_STATE_CLAIMED))
  61. hw_led_state |= LED_23;
  62. break;
  63. #endif
  64. case led_red_on:
  65. if (led_state & LED_STATE_CLAIMED)
  66. hw_led_state &= ~LED_23;
  67. break;
  68. case led_red_off:
  69. if (led_state & LED_STATE_CLAIMED)
  70. hw_led_state |= LED_23;
  71. break;
  72. default:
  73. break;
  74. }
  75. /* Now set the GPIO state, or nothing will happen at all */
  76. if (led_state & LED_STATE_ENABLED) {
  77. GPSR = hw_led_state;
  78. GPCR = hw_led_state ^ LED_MASK;
  79. }
  80. local_irq_restore(flags);
  81. }