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