led.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * arch/sh/boards/se/73180/led.c
  3. *
  4. * Derived from arch/sh/boards/se/770x/led.c
  5. *
  6. * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
  7. *
  8. * May be copied or modified under the terms of the GNU General Public
  9. * License. See linux/COPYING for more information.
  10. *
  11. * This file contains Solution Engine specific LED code.
  12. */
  13. #include <linux/config.h>
  14. #include <linux/sched.h>
  15. #include <asm/mach/se73180.h>
  16. static void
  17. mach_led(int position, int value)
  18. {
  19. volatile unsigned short *p = (volatile unsigned short *) PA_LED;
  20. if (value) {
  21. *p |= (1 << LED_SHIFT);
  22. } else {
  23. *p &= ~(1 << LED_SHIFT);
  24. }
  25. }
  26. /* Cycle the LED's in the clasic Knightrider/Sun pattern */
  27. void
  28. heartbeat_73180se(void)
  29. {
  30. static unsigned int cnt = 0, period = 0;
  31. volatile unsigned short *p = (volatile unsigned short *) PA_LED;
  32. static unsigned bit = 0, up = 1;
  33. cnt += 1;
  34. if (cnt < period) {
  35. return;
  36. }
  37. cnt = 0;
  38. /* Go through the points (roughly!):
  39. * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
  40. */
  41. period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
  42. if (up) {
  43. if (bit == 7) {
  44. bit--;
  45. up = 0;
  46. } else {
  47. bit++;
  48. }
  49. } else {
  50. if (bit == 0) {
  51. bit++;
  52. up = 1;
  53. } else {
  54. bit--;
  55. }
  56. }
  57. *p = 1 << (bit + LED_SHIFT);
  58. }