led.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * linux/arch/sh/boards/mpc1211/led.c
  3. *
  4. * Copyright (C) 2001 Saito.K & Jeanne
  5. *
  6. * This file contains Interface MPC-1211 specific LED code.
  7. */
  8. static void mach_led(int position, int value)
  9. {
  10. volatile unsigned char* p = (volatile unsigned char*)0xa2000000;
  11. if (value) {
  12. *p |= 1;
  13. } else {
  14. *p &= ~1;
  15. }
  16. }
  17. #ifdef CONFIG_HEARTBEAT
  18. #include <linux/sched.h>
  19. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  20. void heartbeat_mpc1211(void)
  21. {
  22. static unsigned int cnt = 0, period = 0;
  23. volatile unsigned char* p = (volatile unsigned char*)0xa2000000;
  24. static unsigned bit = 0, up = 1;
  25. cnt += 1;
  26. if (cnt < period) {
  27. return;
  28. }
  29. cnt = 0;
  30. /* Go through the points (roughly!):
  31. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  32. */
  33. period = 110 - ( (300<<FSHIFT)/
  34. ((avenrun[0]/5) + (3<<FSHIFT)) );
  35. if (up) {
  36. if (bit == 7) {
  37. bit--;
  38. up=0;
  39. } else {
  40. bit ++;
  41. }
  42. } else {
  43. if (bit == 0) {
  44. bit++;
  45. up=1;
  46. } else {
  47. bit--;
  48. }
  49. }
  50. *p = 1<<bit;
  51. }
  52. #endif /* CONFIG_HEARTBEAT */