led.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <asm/io.h>
  12. #include <asm/rts7751r2d/rts7751r2d.h>
  13. extern unsigned int debug_counter;
  14. #ifdef CONFIG_HEARTBEAT
  15. #include <linux/sched.h>
  16. /* Cycle the LED's in the clasic Knightriger/Sun pattern */
  17. void heartbeat_rts7751r2d(void)
  18. {
  19. static unsigned int cnt = 0, period = 0;
  20. volatile unsigned short *p = (volatile unsigned short *)PA_OUTPORT;
  21. static unsigned bit = 0, up = 1;
  22. cnt += 1;
  23. if (cnt < period)
  24. return;
  25. cnt = 0;
  26. /* Go through the points (roughly!):
  27. * f(0)=10, f(1)=16, f(2)=20, f(5)=35, f(int)->110
  28. */
  29. period = 110 - ((300 << FSHIFT)/((avenrun[0]/5) + (3<<FSHIFT)));
  30. *p = 1 << bit;
  31. if (up)
  32. if (bit == 7) {
  33. bit--;
  34. up = 0;
  35. } else
  36. bit++;
  37. else if (bit == 0)
  38. up = 1;
  39. else
  40. bit--;
  41. }
  42. #endif /* CONFIG_HEARTBEAT */
  43. void rts7751r2d_led(unsigned short value)
  44. {
  45. ctrl_outw(value, PA_OUTPORT);
  46. }
  47. void debug_led_disp(void)
  48. {
  49. unsigned short value;
  50. value = (unsigned short)debug_counter++;
  51. rts7751r2d_led(value);
  52. if (value == 0xff)
  53. debug_counter = 0;
  54. }