led.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * linux/arch/sh/stboards/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 ST40STB1 HARP and compatible code.
  10. */
  11. #include <linux/config.h>
  12. #include <asm/io.h>
  13. #include <asm/harp/harp.h>
  14. /* Harp: Flash LD10 (front pannel) connected to EPLD (IC8) */
  15. /* Overdrive: Flash LD1 (front panel) connected to EPLD (IC4) */
  16. /* Works for HARP and overdrive */
  17. static void mach_led(int position, int value)
  18. {
  19. if (value) {
  20. ctrl_outl(EPLD_LED_ON, EPLD_LED);
  21. } else {
  22. ctrl_outl(EPLD_LED_OFF, EPLD_LED);
  23. }
  24. }
  25. #ifdef CONFIG_HEARTBEAT
  26. #include <linux/sched.h>
  27. /* acts like an actual heart beat -- ie thump-thump-pause... */
  28. void heartbeat_harp(void)
  29. {
  30. static unsigned cnt = 0, period = 0, dist = 0;
  31. if (cnt == 0 || cnt == dist)
  32. mach_led( -1, 1);
  33. else if (cnt == 7 || cnt == dist+7)
  34. mach_led( -1, 0);
  35. if (++cnt > period) {
  36. cnt = 0;
  37. /* The hyperbolic function below modifies the heartbeat period
  38. * length in dependency of the current (5min) load. It goes
  39. * through the points f(0)=126, f(1)=86, f(5)=51,
  40. * f(inf)->30. */
  41. period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
  42. dist = period / 4;
  43. }
  44. }
  45. #endif