blob: 376e95c0c8a893b791d5aaf8d2e6529884d93e4c [file] [log] [blame]
Hung-Te Lin7635a602013-02-12 00:07:38 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google, Inc.
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <console/console.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020017#include <console/uart.h>
Hung-Te Lin7635a602013-02-12 00:07:38 +080018
Kyösti Mälkki7e75f202014-02-10 23:21:14 +020019static void pl011_uart_tx_byte(unsigned char data)
20{
Hung-Te Lin7635a602013-02-12 00:07:38 +080021 static volatile unsigned int *uart0_address =
Kyösti Mälkki7e75f202014-02-10 23:21:14 +020022 (unsigned int *) CONFIG_CONSOLE_SERIAL_UART_ADDRESS;
Hung-Te Lin7635a602013-02-12 00:07:38 +080023
24 *uart0_address = (unsigned int)data;
25}
26
Hung-Te Lin7635a602013-02-12 00:07:38 +080027#if !defined(__PRE_RAM__)
28
29static const struct console_driver pl011_uart_console __console = {
Hung-Te Lin7635a602013-02-12 00:07:38 +080030 .tx_byte = pl011_uart_tx_byte,
Hung-Te Lin7635a602013-02-12 00:07:38 +080031};
32
Ronald G. Minnichc8fadd92013-02-20 14:13:01 -080033uint32_t uartmem_getbaseaddr(void)
34{
Kyösti Mälkki7e75f202014-02-10 23:21:14 +020035 return CONFIG_CONSOLE_SERIAL_UART_ADDRESS;
Ronald G. Minnichc8fadd92013-02-20 14:13:01 -080036}
Hung-Te Lin7635a602013-02-12 00:07:38 +080037#else
38void uart_init(void)
39{
Hung-Te Lin7635a602013-02-12 00:07:38 +080040}
41
42void uart_tx_byte(unsigned char data)
43{
44 pl011_uart_tx_byte(data);
45}
46
Kyösti Mälkki7e75f202014-02-10 23:21:14 +020047void uart_tx_flush(void)
48{
Hung-Te Lin7635a602013-02-12 00:07:38 +080049}
50#endif