led.c 766 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * arch/sh/boards/se/7343/led.c
  3. *
  4. */
  5. #include <linux/config.h>
  6. #include <linux/sched.h>
  7. #include <asm/mach/se7343.h>
  8. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  9. void heartbeat_7343se(void)
  10. {
  11. static unsigned int cnt = 0, period = 0;
  12. volatile unsigned short *p = (volatile unsigned short *) PA_LED;
  13. static unsigned bit = 0, up = 1;
  14. cnt += 1;
  15. if (cnt < period) {
  16. return;
  17. }
  18. cnt = 0;
  19. /* Go through the points (roughly!):
  20. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  21. */
  22. period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
  23. if (up) {
  24. if (bit == 7) {
  25. bit--;
  26. up = 0;
  27. } else {
  28. bit++;
  29. }
  30. } else {
  31. if (bit == 0) {
  32. bit++;
  33. up = 1;
  34. } else {
  35. bit--;
  36. }
  37. }
  38. *p = 1 << (bit + LED_SHIFT);
  39. }