led.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <linux/config.h>
  12. #include <asm/se7206.h>
  13. #ifdef CONFIG_HEARTBEAT
  14. #include <linux/sched.h>
  15. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  16. void heartbeat_se(void)
  17. {
  18. static unsigned int cnt = 0, period = 0;
  19. volatile unsigned short* p = (volatile unsigned short*)PA_LED;
  20. static unsigned bit = 0, up = 1;
  21. cnt += 1;
  22. if (cnt < period) {
  23. return;
  24. }
  25. cnt = 0;
  26. /* Go through the points (roughly!):
  27. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  28. */
  29. period = 110 - ( (300<<FSHIFT)/
  30. ((avenrun[0]/5) + (3<<FSHIFT)) );
  31. if (up) {
  32. if (bit == 7) {
  33. bit--;
  34. up=0;
  35. } else {
  36. bit ++;
  37. }
  38. } else {
  39. if (bit == 0) {
  40. bit++;
  41. up=1;
  42. } else {
  43. bit--;
  44. }
  45. }
  46. *p = 1<<(bit+8);
  47. }
  48. #endif /* CONFIG_HEARTBEAT */