pdsp188x.c 911 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2010 Sergey Poselenov, Emcraft Systems, <sposelenov@emcraft.com>
  3. * Copyright 2010 Ilya Yanok, Emcraft Systems, <yanok@emcraft.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <led-display.h>
  9. #include <asm/io.h>
  10. #ifdef CONFIG_CMD_DISPLAY
  11. #define CWORD_CLEAR 0x80
  12. #define CLEAR_DELAY (110 * 2)
  13. #define DISPLAY_SIZE 8
  14. static int pos; /* Current display position */
  15. /* Handle different display commands */
  16. void display_set(int cmd)
  17. {
  18. if (cmd & DISPLAY_CLEAR) {
  19. out_8((unsigned char *)CONFIG_SYS_DISP_CWORD, CWORD_CLEAR);
  20. udelay(1000 * CLEAR_DELAY);
  21. }
  22. if (cmd & DISPLAY_HOME) {
  23. pos = 0;
  24. }
  25. }
  26. /*
  27. * Display a character at the current display position.
  28. * Characters beyond the display size are ignored.
  29. */
  30. int display_putc(char c)
  31. {
  32. if (pos >= DISPLAY_SIZE)
  33. return -1;
  34. out_8((unsigned char *)CONFIG_SYS_DISP_CHR_RAM + pos++, c);
  35. return c;
  36. }
  37. #endif