led.c 739 B

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