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

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * linux/arch/arm/mach-pxa/leds-lubbock.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.  * See leds.h for bit definitions.  The first version defines D28 on the
  11.  * Lubbock dev board as the heartbeat, and D27 as the Sys_busy led.
  12.  * There's plenty more if you're interested in adding them :)
  13.  */
  14. #include <linux/config.h>
  15. #include <linux/init.h>
  16. #include <asm/hardware.h>
  17. #include <asm/leds.h>
  18. #include <asm/system.h>
  19. #include "leds.h"
  20. #define LED_STATE_ENABLED 1
  21. #define LED_STATE_CLAIMED 2
  22. static unsigned int led_state;
  23. static unsigned int hw_led_state;
  24. void lubbock_leds_event(led_event_t evt)
  25. {
  26. unsigned long flags;
  27. local_irq_save(flags);
  28. switch (evt) {
  29. case led_start:
  30. hw_led_state = HEARTBEAT_LED | SYS_BUSY_LED;
  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 = HEARTBEAT_LED | SYS_BUSY_LED;
  39. break;
  40. case led_release:
  41. led_state &= ~LED_STATE_CLAIMED;
  42. hw_led_state = HEARTBEAT_LED | SYS_BUSY_LED;
  43. break;
  44. #ifdef CONFIG_LEDS_TIMER
  45. case led_timer:
  46. if (!(led_state & LED_STATE_CLAIMED))
  47. hw_led_state ^= HEARTBEAT_LED;
  48. break;
  49. #endif
  50. #ifdef CONFIG_LEDS_CPU
  51. case led_idle_start:
  52. if (!(led_state & LED_STATE_CLAIMED))
  53. hw_led_state |= SYS_BUSY_LED;
  54. break;
  55. case led_idle_end:
  56. if (!(led_state & LED_STATE_CLAIMED))
  57. hw_led_state &= ~SYS_BUSY_LED;
  58. break;
  59. #endif
  60. case led_halted:
  61. break;
  62. case led_green_on:
  63. if (led_state & LED_STATE_CLAIMED)
  64. hw_led_state &= ~HEARTBEAT_LED;
  65. break;
  66. case led_green_off:
  67. if (led_state & LED_STATE_CLAIMED)
  68. hw_led_state |= HEARTBEAT_LED;
  69. break;
  70. case led_amber_on:
  71. break;
  72. case led_amber_off:
  73. break;
  74. case led_red_on:
  75. if (led_state & LED_STATE_CLAIMED)
  76. hw_led_state &= ~SYS_BUSY_LED;
  77. break;
  78. case led_red_off:
  79. if (led_state & LED_STATE_CLAIMED)
  80. hw_led_state |= SYS_BUSY_LED;
  81. break;
  82. default:
  83. break;
  84. }
  85. if  (led_state & LED_STATE_ENABLED)
  86. {
  87. switch (hw_led_state) {
  88. case 0: // all on
  89. HEARTBEAT_LED_ON;
  90. SYS_BUSY_LED_ON;
  91. break;
  92. case 1: // turn off heartbeat, status on:
  93. HEARTBEAT_LED_OFF;
  94. SYS_BUSY_LED_ON;
  95. break;
  96. case 2: // status off, heartbeat on:
  97. HEARTBEAT_LED_ON;
  98. SYS_BUSY_LED_OFF;
  99. break;
  100. case 3: // turn them both off...
  101. HEARTBEAT_LED_OFF;
  102. SYS_BUSY_LED_OFF;
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. local_irq_restore(flags);
  109. }