led.c 839 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * linux/arch/sh/boards/sh03/led.c
  3. *
  4. * Copyright (C) 2004 Saito.K Interface Corporation.
  5. *
  6. * This file contains Interface CTP/PCI-SH03 specific LED code.
  7. */
  8. #include <linux/config.h>
  9. #include <linux/sched.h>
  10. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  11. void heartbeat_sh03(void)
  12. {
  13. static unsigned int cnt = 0, period = 0;
  14. volatile unsigned char* p = (volatile unsigned char*)0xa0800000;
  15. static unsigned bit = 0, up = 1;
  16. cnt += 1;
  17. if (cnt < period) {
  18. return;
  19. }
  20. cnt = 0;
  21. /* Go through the points (roughly!):
  22. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  23. */
  24. period = 110 - ( (300<<FSHIFT)/
  25. ((avenrun[0]/5) + (3<<FSHIFT)) );
  26. if (up) {
  27. if (bit == 7) {
  28. bit--;
  29. up=0;
  30. } else {
  31. bit ++;
  32. }
  33. } else {
  34. if (bit == 0) {
  35. bit++;
  36. up=1;
  37. } else {
  38. bit--;
  39. }
  40. }
  41. *p = 1<<bit;
  42. }