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

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/arch/arm/mach-pxa/leds-cerf.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.  *  This program is free software; you can redistribute it and/or modify
  11.  *  it under the terms of the GNU General Public License version 2 as
  12.  *  published by the Free Software Foundation.
  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 pxa_cerf_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 = CERF_HEARTBEAT_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 = CERF_HEARTBEAT_LED;
  39. break;
  40. case led_release:
  41. led_state &= ~LED_STATE_CLAIMED;
  42. hw_led_state = CERF_HEARTBEAT_LED;
  43. break;
  44. #ifdef CONFIG_LEDS_TIMER
  45. case led_timer:
  46. if (!(led_state & LED_STATE_CLAIMED))
  47. hw_led_state ^= CERF_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 |= CERF_SYS_BUSY_LED;
  54. break;
  55. case led_idle_end:
  56. if (!(led_state & LED_STATE_CLAIMED))
  57. hw_led_state &= ~CERF_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 &= ~CERF_HEARTBEAT_LED;
  65. break;
  66. case led_green_off:
  67. if (led_state & LED_STATE_CLAIMED)
  68. hw_led_state |= CERF_HEARTBEAT_LED;
  69. break;
  70. case led_amber_on:
  71. break;
  72. case led_amber_off:
  73. break;
  74. #ifndef CONFIG_PXA_CERF_PDA
  75. case led_red_on:
  76. if (led_state & LED_STATE_CLAIMED)
  77. hw_led_state &= ~CERF_SYS_BUSY_LED;
  78. break;
  79. case led_red_off:
  80. if (led_state & LED_STATE_CLAIMED)
  81. hw_led_state |= CERF_SYS_BUSY_LED;
  82. break;
  83. #endif
  84. default:
  85. break;
  86. }
  87. if  (led_state & LED_STATE_ENABLED)
  88. {
  89. switch (hw_led_state) {
  90. case 0: // all on
  91. CERF_HEARTBEAT_LED_ON;
  92. CERF_SYS_BUSY_LED_ON;
  93. break;
  94. case 1: // turn off heartbeat, status on:
  95. CERF_HEARTBEAT_LED_OFF;
  96. CERF_SYS_BUSY_LED_ON;
  97. break;
  98. case 2: // status off, heartbeat on:
  99. CERF_HEARTBEAT_LED_ON;
  100. CERF_SYS_BUSY_LED_OFF;
  101. break;
  102. case 3: // turn them both off...
  103. CERF_HEARTBEAT_LED_OFF;
  104. CERF_SYS_BUSY_LED_OFF;
  105. break;
  106. default:
  107. break;
  108. }
  109. }
  110. local_irq_restore(flags);
  111. }