led.c 929 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * arch/sh64/kernel/led.c
  3. *
  4. * Copyright (C) 2002 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. * Flash the LEDs
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/sched.h>
  13. void mach_led(int pos, int val);
  14. /* acts like an actual heart beat -- ie thump-thump-pause... */
  15. void heartbeat(void)
  16. {
  17. static unsigned int cnt = 0, period = 0, dist = 0;
  18. if (cnt == 0 || cnt == dist) {
  19. mach_led(-1, 1);
  20. } else if (cnt == 7 || cnt == dist + 7) {
  21. mach_led(-1, 0);
  22. }
  23. if (++cnt > period) {
  24. cnt = 0;
  25. /*
  26. * The hyperbolic function below modifies the heartbeat period
  27. * length in dependency of the current (5min) load. It goes
  28. * through the points f(0)=126, f(1)=86, f(5)=51, f(inf)->30.
  29. */
  30. period = ((672 << FSHIFT) / (5 * avenrun[0] +
  31. (7 << FSHIFT))) + 30;
  32. dist = period / 4;
  33. }
  34. }