arm: vf610: fix double iomux configuration for vf610twr board
[u-boot/qq2440-u-boot.git] / drivers / misc / cbmem_console.c
blob80a84fdf8f9bd7dd45f1b31614c39992b0d0ec2c
1 /*
2 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18 #include <common.h>
20 #ifndef CONFIG_SYS_COREBOOT
21 #error This driver requires coreboot
22 #endif
24 #include <asm/arch/sysinfo.h>
26 struct cbmem_console {
27 u32 buffer_size;
28 u32 buffer_cursor;
29 u8 buffer_body[0];
30 } __attribute__ ((__packed__));
32 static struct cbmem_console *cbmem_console_p;
34 void cbmemc_putc(char data)
36 int cursor;
38 cursor = cbmem_console_p->buffer_cursor++;
39 if (cursor < cbmem_console_p->buffer_size)
40 cbmem_console_p->buffer_body[cursor] = data;
43 void cbmemc_puts(const char *str)
45 char c;
47 while ((c = *str++) != 0)
48 cbmemc_putc(c);
51 int cbmemc_init(void)
53 int rc;
54 struct stdio_dev cons_dev;
55 cbmem_console_p = lib_sysinfo.cbmem_cons;
57 memset(&cons_dev, 0, sizeof(cons_dev));
59 strcpy(cons_dev.name, "cbmem");
60 cons_dev.flags = DEV_FLAGS_OUTPUT; /* Output only */
61 cons_dev.putc = cbmemc_putc;
62 cons_dev.puts = cbmemc_puts;
64 rc = stdio_register(&cons_dev);
66 return (rc == 0) ? 1 : rc;