pdsp188x.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2010 Sergey Poselenov, Emcraft Systems, <sposelenov@emcraft.com>
  3. * Copyright 2010 Ilya Yanok, Emcraft Systems, <yanok@emcraft.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  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., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #include <common.h>
  20. #include <led-display.h>
  21. #include <asm/io.h>
  22. #ifdef CONFIG_CMD_DISPLAY
  23. #define CWORD_CLEAR 0x80
  24. #define CLEAR_DELAY (110 * 2)
  25. #define DISPLAY_SIZE 8
  26. static int pos; /* Current display position */
  27. /* Handle different display commands */
  28. void display_set(int cmd)
  29. {
  30. if (cmd & DISPLAY_CLEAR) {
  31. out_8((unsigned char *)CONFIG_SYS_DISP_CWORD, CWORD_CLEAR);
  32. udelay(1000 * CLEAR_DELAY);
  33. }
  34. if (cmd & DISPLAY_HOME) {
  35. pos = 0;
  36. }
  37. }
  38. /*
  39. * Display a character at the current display position.
  40. * Characters beyond the display size are ignored.
  41. */
  42. int display_putc(char c)
  43. {
  44. if (pos >= DISPLAY_SIZE)
  45. return -1;
  46. out_8((unsigned char *)CONFIG_SYS_DISP_CHR_RAM + pos++, c);
  47. return c;
  48. }
  49. #endif