led.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * linux/arch/sh/overdrive/led.c
  3. *
  4. * Copyright (C) 1999 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 an Overdrive specific LED feature.
  10. */
  11. #include <linux/config.h>
  12. #include <asm/system.h>
  13. #include <asm/io.h>
  14. #include <asm/overdrive/overdrive.h>
  15. static void mach_led(int position, int value)
  16. {
  17. unsigned long flags;
  18. unsigned long reg;
  19. local_irq_save(flags);
  20. reg = readl(OVERDRIVE_CTRL);
  21. if (value) {
  22. reg |= (1<<3);
  23. } else {
  24. reg &= ~(1<<3);
  25. }
  26. writel(reg, OVERDRIVE_CTRL);
  27. local_irq_restore(flags);
  28. }
  29. #ifdef CONFIG_HEARTBEAT
  30. #include <linux/sched.h>
  31. /* acts like an actual heart beat -- ie thump-thump-pause... */
  32. void heartbeat_od(void)
  33. {
  34. static unsigned cnt = 0, period = 0, dist = 0;
  35. if (cnt == 0 || cnt == dist)
  36. mach_led( -1, 1);
  37. else if (cnt == 7 || cnt == dist+7)
  38. mach_led( -1, 0);
  39. if (++cnt > period) {
  40. cnt = 0;
  41. /* The hyperbolic function below modifies the heartbeat period
  42. * length in dependency of the current (5min) load. It goes
  43. * through the points f(0)=126, f(1)=86, f(5)=51,
  44. * f(inf)->30. */
  45. period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
  46. dist = period / 4;
  47. }
  48. }
  49. #endif /* CONFIG_HEARTBEAT */