led.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) NEC Electronics Corporation 2004-2006
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/types.h>
  20. #include <linux/string.h>
  21. #include <asm/emma/emma2rh.h>
  22. const unsigned long clear = 0x20202020;
  23. #define LED_BASE 0xb1400038
  24. void markeins_led_clear(void)
  25. {
  26. emma2rh_out32(LED_BASE, clear);
  27. emma2rh_out32(LED_BASE + 4, clear);
  28. }
  29. void markeins_led(const char *str)
  30. {
  31. int i;
  32. int len = strlen(str);
  33. markeins_led_clear();
  34. if (len > 8)
  35. len = 8;
  36. if (emma2rh_in32(0xb0000800) & (0x1 << 18))
  37. for (i = 0; i < len; i++)
  38. emma2rh_out8(LED_BASE + i, str[i]);
  39. else
  40. for (i = 0; i < len; i++)
  41. emma2rh_out8(LED_BASE + (i & 4) + (3 - (i & 3)),
  42. str[i]);
  43. }
  44. void markeins_led_hex(u32 val)
  45. {
  46. char str[10];
  47. sprintf(str, "%08x", val);
  48. markeins_led(str);
  49. }