led.c 1.2 KB

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