blob: 656b6eeb11997cd14028241123f10af4f89de5f7 [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 *
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
20#include <common.h>
21#include <led-display.h>
22#include <asm/io.h>
23
24#ifdef CONFIG_CMD_DISPLAY
25#define CWORD_CLEAR 0x80
26#define CLEAR_DELAY (110 * 2)
27#define DISPLAY_SIZE 8
28
29static int pos; /* Current display position */
30
31/* Handle different display commands */
32void display_set(int cmd)
33{
34 if (cmd & DISPLAY_CLEAR) {
35 out_8((unsigned char *)CONFIG_SYS_DISP_CWORD, CWORD_CLEAR);
36 udelay(1000 * CLEAR_DELAY);
37 }
38
39 if (cmd & DISPLAY_HOME) {
40 pos = 0;
41 }
42}
43
44/*
45 * Display a character at the current display position.
46 * Characters beyond the display size are ignored.
47 */
48int display_putc(char c)
49{
50 if (pos >= DISPLAY_SIZE)
51 return -1;
52
53 out_8((unsigned char *)CONFIG_SYS_DISP_CHR_RAM + pos++, c);
54
55 return c;
56}
57#endif