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

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * linux/arch/arm/mach-sa1100/leds-simpad.c
  3.  *
  4.  * Author: Juergen Messerer <juergen.messerer@siemens.ch>
  5.  */
  6. #include <linux/config.h>
  7. #include <linux/init.h>
  8. #include <asm/hardware.h>
  9. #include <asm/leds.h>
  10. #include <asm/system.h>
  11. #include "leds.h"
  12. #define LED_STATE_ENABLED 1
  13. #define LED_STATE_CLAIMED 2
  14. static unsigned int led_state;
  15. static unsigned int hw_led_state;
  16. #define LED_GREEN (1)
  17. #define LED_MASK (1)
  18. extern void set_cs3_bit(int value);
  19. extern void clear_cs3_bit(int value);     
  20. void simpad_leds_event(led_event_t evt)
  21. {
  22. unsigned long flags;
  23. //local_irq_save(flags);
  24. switch (evt) 
  25. {
  26. case led_start:
  27.         hw_led_state = LED_GREEN;
  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_GREEN;
  36. break;
  37. case led_release:
  38. led_state &= ~LED_STATE_CLAIMED;
  39. hw_led_state = LED_GREEN;
  40. break;
  41. #ifdef CONFIG_LEDS_TIMER
  42. case led_timer:
  43. if (!(led_state & LED_STATE_CLAIMED))
  44. hw_led_state ^= LED_GREEN;
  45. break;
  46. #endif
  47. #ifdef CONFIG_LEDS_CPU
  48. case led_idle_start:
  49. break;
  50. case led_idle_end:
  51. break;
  52. #endif
  53. case led_halted:
  54. break;
  55. case led_green_on:
  56. if (led_state & LED_STATE_CLAIMED)
  57. hw_led_state |= LED_GREEN;
  58. break;
  59. case led_green_off:
  60. if (led_state & LED_STATE_CLAIMED)
  61. hw_led_state &= ~LED_GREEN;
  62. break;
  63. case led_amber_on:
  64. break;
  65. case led_amber_off:
  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. set_cs3_bit(LED2_ON);
  76. else 
  77.         clear_cs3_bit(LED2_ON);
  78. //local_irq_restore(flags);
  79. }