leds-lubbock.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. * Major surgery on April 2004 by Nicolas Pitre for less global
  11. * namespace collision. Mostly adapted the Mainstone version.
  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 <asm/arch/pxa-regs.h>
  19. #include <asm/arch/lubbock.h>
  20. #include "leds.h"
  21. /*
  22. * 8 discrete leds available for general use:
  23. *
  24. * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
  25. * so be sure to not monkey with them here.
  26. */
  27. #define D28 (1 << 0)
  28. #define D27 (1 << 1)
  29. #define D26 (1 << 2)
  30. #define D25 (1 << 3)
  31. #define D24 (1 << 4)
  32. #define D23 (1 << 5)
  33. #define D22 (1 << 6)
  34. #define D21 (1 << 7)
  35. #define LED_STATE_ENABLED 1
  36. #define LED_STATE_CLAIMED 2
  37. static unsigned int led_state;
  38. static unsigned int hw_led_state;
  39. void lubbock_leds_event(led_event_t evt)
  40. {
  41. unsigned long flags;
  42. local_irq_save(flags);
  43. switch (evt) {
  44. case led_start:
  45. hw_led_state = 0;
  46. led_state = LED_STATE_ENABLED;
  47. break;
  48. case led_stop:
  49. led_state &= ~LED_STATE_ENABLED;
  50. break;
  51. case led_claim:
  52. led_state |= LED_STATE_CLAIMED;
  53. hw_led_state = 0;
  54. break;
  55. case led_release:
  56. led_state &= ~LED_STATE_CLAIMED;
  57. hw_led_state = 0;
  58. break;
  59. #ifdef CONFIG_LEDS_TIMER
  60. case led_timer:
  61. hw_led_state ^= D26;
  62. break;
  63. #endif
  64. #ifdef CONFIG_LEDS_CPU
  65. case led_idle_start:
  66. hw_led_state &= ~D27;
  67. break;
  68. case led_idle_end:
  69. hw_led_state |= D27;
  70. break;
  71. #endif
  72. case led_halted:
  73. break;
  74. case led_green_on:
  75. hw_led_state |= D21;
  76. break;
  77. case led_green_off:
  78. hw_led_state &= ~D21;
  79. break;
  80. case led_amber_on:
  81. hw_led_state |= D22;
  82. break;
  83. case led_amber_off:
  84. hw_led_state &= ~D22;
  85. break;
  86. case led_red_on:
  87. hw_led_state |= D23;
  88. break;
  89. case led_red_off:
  90. hw_led_state &= ~D23;
  91. break;
  92. default:
  93. break;
  94. }
  95. if (led_state & LED_STATE_ENABLED)
  96. LUB_DISC_BLNK_LED = (LUB_DISC_BLNK_LED | 0xff) & ~hw_led_state;
  97. else
  98. LUB_DISC_BLNK_LED |= 0xff;
  99. local_irq_restore(flags);
  100. }