leds-lart.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "leds.h"
  16. #define LED_STATE_ENABLED 1
  17. #define LED_STATE_CLAIMED 2
  18. static unsigned int led_state;
  19. static unsigned int hw_led_state;
  20. #define LED_23 GPIO_GPIO23
  21. #define LED_MASK (LED_23)
  22. void lart_leds_event(led_event_t evt)
  23. {
  24. unsigned long flags;
  25. local_irq_save(flags);
  26. switch(evt) {
  27. case led_start:
  28. /* pin 23 is output pin */
  29. GPDR |= LED_23;
  30. hw_led_state = LED_MASK;
  31. led_state = LED_STATE_ENABLED;
  32. break;
  33. case led_stop:
  34. led_state &= ~LED_STATE_ENABLED;
  35. break;
  36. case led_claim:
  37. led_state |= LED_STATE_CLAIMED;
  38. hw_led_state = LED_MASK;
  39. break;
  40. case led_release:
  41. led_state &= ~LED_STATE_CLAIMED;
  42. hw_led_state = LED_MASK;
  43. break;
  44. #ifdef CONFIG_LEDS_TIMER
  45. case led_timer:
  46. if (!(led_state & LED_STATE_CLAIMED))
  47. hw_led_state ^= LED_23;
  48. break;
  49. #endif
  50. #ifdef CONFIG_LEDS_CPU
  51. case led_idle_start:
  52. /* The LART people like the LED to be off when the
  53. system is idle... */
  54. if (!(led_state & LED_STATE_CLAIMED))
  55. hw_led_state &= ~LED_23;
  56. break;
  57. case led_idle_end:
  58. /* ... and on if the system is not idle */
  59. if (!(led_state & LED_STATE_CLAIMED))
  60. hw_led_state |= LED_23;
  61. break;
  62. #endif
  63. case led_red_on:
  64. if (led_state & LED_STATE_CLAIMED)
  65. hw_led_state &= ~LED_23;
  66. break;
  67. case led_red_off:
  68. if (led_state & LED_STATE_CLAIMED)
  69. hw_led_state |= LED_23;
  70. break;
  71. default:
  72. break;
  73. }
  74. /* Now set the GPIO state, or nothing will happen at all */
  75. if (led_state & LED_STATE_ENABLED) {
  76. GPSR = hw_led_state;
  77. GPCR = hw_led_state ^ LED_MASK;
  78. }
  79. local_irq_restore(flags);
  80. }