blob: aa4351a0ad488265e3c9b6a865bbd0b5ef69add8 [file] [log] [blame]
Ilya Yanok435a63d2010-09-09 23:03:32 +02001/*
2 * Copyright 2010 Sergey Poselenov, Emcraft Systems, <sposelenov@emcraft.com>
3 * Copyright 2010 Ilya Yanok, Emcraft Systems, <yanok@emcraft.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Ilya Yanok435a63d2010-09-09 23:03:32 +02006 */
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
17static int pos; /* Current display position */
18
19/* Handle different display commands */
20void 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 */
36int 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