led.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * linux/arch/sh/kernel/led_rts7751r2d.c
  3. *
  4. * Copyright (C) Atom Create Engineering Co., Ltd.
  5. *
  6. * May be copied or modified under the terms of GNU General Public
  7. * License. See linux/COPYING for more information.
  8. *
  9. * This file contains Renesas Technology Sales RTS7751R2D specific LED code.
  10. */
  11. #include <linux/config.h>
  12. #include <asm/io.h>
  13. #include <asm/rts7751r2d/rts7751r2d.h>
  14. extern unsigned int debug_counter;
  15. #ifdef CONFIG_HEARTBEAT
  16. #include <linux/sched.h>
  17. /* Cycle the LED's in the clasic Knightriger/Sun pattern */
  18. void heartbeat_rts7751r2d(void)
  19. {
  20. static unsigned int cnt = 0, period = 0;
  21. volatile unsigned short *p = (volatile unsigned short *)PA_OUTPORT;
  22. static unsigned bit = 0, up = 1;
  23. cnt += 1;
  24. if (cnt < period)
  25. return;
  26. cnt = 0;
  27. /* Go through the points (roughly!):
  28. * f(0)=10, f(1)=16, f(2)=20, f(5)=35, f(int)->110
  29. */
  30. period = 110 - ((300 << FSHIFT)/((avenrun[0]/5) + (3<<FSHIFT)));
  31. *p = 1 << bit;
  32. if (up)
  33. if (bit == 7) {
  34. bit--;
  35. up = 0;
  36. } else
  37. bit++;
  38. else if (bit == 0)
  39. up = 1;
  40. else
  41. bit--;
  42. }
  43. #endif /* CONFIG_HEARTBEAT */
  44. void rts7751r2d_led(unsigned short value)
  45. {
  46. ctrl_outw(value, PA_OUTPORT);
  47. }
  48. void debug_led_disp(void)
  49. {
  50. unsigned short value;
  51. value = (unsigned short)debug_counter++;
  52. rts7751r2d_led(value);
  53. if (value == 0xff)
  54. debug_counter = 0;
  55. }