Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 1 | /* |
| 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> |
| 17 | #include <uart.h> |
| 18 | |
Kyösti Mälkki | 7e75f20 | 2014-02-10 23:21:14 +0200 | [diff] [blame^] | 19 | static void pl011_uart_tx_byte(unsigned char data) |
| 20 | { |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 21 | static volatile unsigned int *uart0_address = |
Kyösti Mälkki | 7e75f20 | 2014-02-10 23:21:14 +0200 | [diff] [blame^] | 22 | (unsigned int *) CONFIG_CONSOLE_SERIAL_UART_ADDRESS; |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 23 | |
| 24 | *uart0_address = (unsigned int)data; |
| 25 | } |
| 26 | |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 27 | #if !defined(__PRE_RAM__) |
| 28 | |
| 29 | static const struct console_driver pl011_uart_console __console = { |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 30 | .tx_byte = pl011_uart_tx_byte, |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 31 | }; |
| 32 | |
Ronald G. Minnich | c8fadd9 | 2013-02-20 14:13:01 -0800 | [diff] [blame] | 33 | uint32_t uartmem_getbaseaddr(void) |
| 34 | { |
Kyösti Mälkki | 7e75f20 | 2014-02-10 23:21:14 +0200 | [diff] [blame^] | 35 | return CONFIG_CONSOLE_SERIAL_UART_ADDRESS; |
Ronald G. Minnich | c8fadd9 | 2013-02-20 14:13:01 -0800 | [diff] [blame] | 36 | } |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 37 | #else |
| 38 | void uart_init(void) |
| 39 | { |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | void uart_tx_byte(unsigned char data) |
| 43 | { |
| 44 | pl011_uart_tx_byte(data); |
| 45 | } |
| 46 | |
Kyösti Mälkki | 7e75f20 | 2014-02-10 23:21:14 +0200 | [diff] [blame^] | 47 | void uart_tx_flush(void) |
| 48 | { |
Hung-Te Lin | 7635a60 | 2013-02-12 00:07:38 +0800 | [diff] [blame] | 49 | } |
| 50 | #endif |