led.c 813 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/sched.h>
  9. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  10. void heartbeat_sh03(void)
  11. {
  12. static unsigned int cnt = 0, period = 0;
  13. volatile unsigned char* p = (volatile unsigned char*)0xa0800000;
  14. static unsigned bit = 0, up = 1;
  15. cnt += 1;
  16. if (cnt < period) {
  17. return;
  18. }
  19. cnt = 0;
  20. /* Go through the points (roughly!):
  21. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  22. */
  23. period = 110 - ( (300<<FSHIFT)/
  24. ((avenrun[0]/5) + (3<<FSHIFT)) );
  25. if (up) {
  26. if (bit == 7) {
  27. bit--;
  28. up=0;
  29. } else {
  30. bit ++;
  31. }
  32. } else {
  33. if (bit == 0) {
  34. bit++;
  35. up=1;
  36. } else {
  37. bit--;
  38. }
  39. }
  40. *p = 1<<bit;
  41. }