led.c 1.0 KB

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