leds-graphicsmaster.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/arch/arm/mach-sa1100/leds-graphicsmaster.c
  3.  *
  4.  * GraphicsClient Plus LEDs support
  5.  * Woojung Huh, Feb 13, 2001
  6.  */
  7. #include <linux/config.h>
  8. #include <linux/init.h>
  9. #include <asm/hardware.h>
  10. #include <asm/leds.h>
  11. #include <asm/system.h>
  12. #include "leds.h"
  13. #define LED_STATE_ENABLED 1
  14. #define LED_STATE_CLAIMED 2
  15. static unsigned int led_state;
  16. static unsigned int hw_led_state;
  17. #define LED_TIMER       ADS_LED0  /* green heartbeat */
  18. #define LED_USER        ADS_LED1  /* amber, boots to on */
  19. #define LED_IDLE        ADS_LED2  /* red has the idle led, if any */
  20. #define LED_MASK (ADS_LED0|ADS_LED1|ADS_LED2)
  21. void graphicsmaster_leds_event(led_event_t evt)
  22. {
  23. unsigned long flags;
  24. save_flags_cli(flags);
  25. switch (evt) {
  26. case led_start:
  27. hw_led_state = 0;        /* gc leds are positive logic */
  28. led_state = LED_STATE_ENABLED;
  29. break;
  30. case led_stop:
  31. led_state &= ~LED_STATE_ENABLED;
  32. break;
  33. case led_claim:
  34. led_state |= LED_STATE_CLAIMED;
  35. hw_led_state = LED_MASK;
  36. break;
  37. case led_release:
  38. led_state &= ~LED_STATE_CLAIMED;
  39. hw_led_state = LED_MASK;
  40. break;
  41. #ifdef CONFIG_LEDS_TIMER
  42. case led_timer:
  43. if (!(led_state & LED_STATE_CLAIMED))
  44. hw_led_state ^= LED_TIMER;
  45. break;
  46. #endif
  47. #ifdef CONFIG_LEDS_CPU
  48. case led_idle_start:
  49. if (!(led_state & LED_STATE_CLAIMED))
  50. hw_led_state &= ~LED_IDLE;
  51. break;
  52. case led_idle_end:
  53. if (!(led_state & LED_STATE_CLAIMED))
  54. hw_led_state |= LED_IDLE;
  55. break;
  56. #endif
  57. case led_green_on:
  58. break;
  59. case led_green_off:
  60. break;
  61. case led_amber_on:
  62. hw_led_state |= LED_USER;
  63. break;
  64. case led_amber_off:
  65. hw_led_state &= ~LED_USER;
  66. break;
  67. case led_red_on:
  68. break;
  69. case led_red_off:
  70. break;
  71. default:
  72. break;
  73. }
  74. if  (led_state & LED_STATE_ENABLED) {
  75. GPSR = hw_led_state;
  76. GPCR = hw_led_state ^ LED_MASK;
  77. }
  78. restore_flags(flags);
  79. }