]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/misc/pdsp188x.c
aa4351a0ad488265e3c9b6a865bbd0b5ef69add8
[people/ms/u-boot.git] / drivers / misc / pdsp188x.c
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
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