led.c 1.6 KB

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