led.c 968 B

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