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

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * linux/arch/arm/mach-pxa/leds-idp.c
  3.  *
  4.  * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu>
  5.  *
  6.  * Copyright (c) 2001 Jeff Sutherland <jeffs@accelent.com>
  7.  *
  8.  * Original (leds-footbridge.c) by Russell King
  9.  * 
  10.  * Macros for actual LED manipulation should be in machine specific
  11.  * files in this 'mach' directory.
  12.  */
  13. #include <linux/config.h>
  14. #include <linux/init.h>
  15. #include <asm/hardware.h>
  16. #include <asm/leds.h>
  17. #include <asm/system.h>
  18. #include "leds.h"
  19. #define LED_STATE_ENABLED 1
  20. #define LED_STATE_CLAIMED 2
  21. static unsigned int led_state;
  22. static unsigned int hw_led_state;
  23. void idp_leds_event(led_event_t evt)
  24. {
  25. unsigned long flags;
  26. local_irq_save(flags);
  27. switch (evt) {
  28. case led_start:
  29. hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
  30. led_state = LED_STATE_ENABLED;
  31. break;
  32. case led_stop:
  33. led_state &= ~LED_STATE_ENABLED;
  34. break;
  35. case led_claim:
  36. led_state |= LED_STATE_CLAIMED;
  37. hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
  38. break;
  39. case led_release:
  40. led_state &= ~LED_STATE_CLAIMED;
  41. hw_led_state = IDP_HB_LED | IDP_BUSY_LED;
  42. break;
  43. #ifdef CONFIG_LEDS_TIMER
  44. case led_timer:
  45. if (!(led_state & LED_STATE_CLAIMED))
  46. hw_led_state ^= IDP_HB_LED;
  47. break;
  48. #endif
  49. #ifdef CONFIG_LEDS_CPU
  50. case led_idle_start:
  51. if (!(led_state & LED_STATE_CLAIMED))
  52. hw_led_state |= IDP_BUSY_LED;
  53. break;
  54. case led_idle_end:
  55. if (!(led_state & LED_STATE_CLAIMED))
  56. hw_led_state &= ~IDP_BUSY_LED;
  57. break;
  58. #endif
  59. case led_halted:
  60. break;
  61. case led_green_on:
  62. if (led_state & LED_STATE_CLAIMED)
  63. hw_led_state &= ~IDP_HB_LED;
  64. break;
  65. case led_green_off:
  66. if (led_state & LED_STATE_CLAIMED)
  67. hw_led_state |= IDP_HB_LED;
  68. break;
  69. case led_amber_on:
  70. break;
  71. case led_amber_off:
  72. break;
  73. case led_red_on:
  74. if (led_state & LED_STATE_CLAIMED)
  75. hw_led_state &= ~IDP_BUSY_LED;
  76. break;
  77. case led_red_off:
  78. if (led_state & LED_STATE_CLAIMED)
  79. hw_led_state |= IDP_BUSY_LED;
  80. break;
  81. default:
  82. break;
  83. }
  84. if  (led_state & LED_STATE_ENABLED)
  85. IDP_WRITE_LEDS(hw_led_state);
  86. local_irq_restore(flags);
  87. }