led.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * linux/arch/sh/kernel/led_se.c
  3. *
  4. * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
  5. *
  6. * May be copied or modified under the terms of the GNU General Public
  7. * License. See linux/COPYING for more information.
  8. *
  9. * This file contains Solution Engine specific LED code.
  10. */
  11. #include <asm/se/se.h>
  12. static void mach_led(int position, int value)
  13. {
  14. volatile unsigned short* p = (volatile unsigned short*)PA_LED;
  15. if (value) {
  16. *p |= (1<<8);
  17. } else {
  18. *p &= ~(1<<8);
  19. }
  20. }
  21. #ifdef CONFIG_HEARTBEAT
  22. #include <linux/sched.h>
  23. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  24. void heartbeat_se(void)
  25. {
  26. static unsigned int cnt = 0, period = 0;
  27. volatile unsigned short* p = (volatile unsigned short*)PA_LED;
  28. static unsigned bit = 0, up = 1;
  29. cnt += 1;
  30. if (cnt < period) {
  31. return;
  32. }
  33. cnt = 0;
  34. /* Go through the points (roughly!):
  35. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  36. */
  37. period = 110 - ( (300<<FSHIFT)/
  38. ((avenrun[0]/5) + (3<<FSHIFT)) );
  39. if (up) {
  40. if (bit == 7) {
  41. bit--;
  42. up=0;
  43. } else {
  44. bit ++;
  45. }
  46. } else {
  47. if (bit == 0) {
  48. bit++;
  49. up=1;
  50. } else {
  51. bit--;
  52. }
  53. }
  54. *p = 1<<(bit+8);
  55. }
  56. #endif /* CONFIG_HEARTBEAT */