diff options
author | David Hendricks <dhendricks@fb.com> | 2017-12-28 20:18:10 -0800 |
---|---|---|
committer | David Hendricks <david.hendricks@gmail.com> | 2018-02-13 01:19:40 +0000 |
commit | ff0d8698c2111d405e845536757e9105cfe78e8e (patch) | |
tree | 30458f8b481c51690dbdbc382978f603e448142c /src/drivers/uart/pl011.c | |
parent | 3b63e0fb5a903adf5c9164b4810e6def9c754a7e (diff) | |
download | coreboot-ff0d8698c2111d405e845536757e9105cfe78e8e.tar.xz |
drivers/uart/pl011: Improve PL011 driver
This adds a struct for registers along with some bits from ATF to
the generic PL011 driver. It also adds a naive implementation of
uart_tx_flush() which was previously stubbed out.
Change-Id: Iee3fc6308cb92ad784e5ff3ac3a6e995d535be65
Signed-off-by: David Hendricks <dhendricks@fb.com>
Reviewed-on: https://review.coreboot.org/23031
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/drivers/uart/pl011.c')
-rw-r--r-- | src/drivers/uart/pl011.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/drivers/uart/pl011.c b/src/drivers/uart/pl011.c index 709320b288..e690a9afb5 100644 --- a/src/drivers/uart/pl011.c +++ b/src/drivers/uart/pl011.c @@ -2,6 +2,7 @@ * This file is part of the coreboot project. * * Copyright (C) 2013 Google, Inc. + * Copyright 2018-present Facebook, Inc. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -13,13 +14,10 @@ * GNU General Public License for more details. */ +#include <arch/io.h> #include <boot/coreboot_tables.h> #include <console/uart.h> - -static void pl011_uart_tx_byte(unsigned int *uart_base, unsigned char data) -{ - *uart_base = (unsigned int)data; -} +#include <drivers/uart/pl011.h> void uart_init(int idx) { @@ -27,12 +25,19 @@ void uart_init(int idx) void uart_tx_byte(int idx, unsigned char data) { - unsigned int *uart_base = uart_platform_baseptr(idx); - pl011_uart_tx_byte(uart_base, data); + struct pl011_uart *regs = uart_platform_baseptr(idx); + + write8(®s->dr, data); + uart_tx_flush(idx); } void uart_tx_flush(int idx) { + struct pl011_uart *regs = uart_platform_baseptr(idx); + + /* FIXME: add a timeout */ + while (!(read32(®s->fr) & PL011_UARTFR_TXFE)) + ; } unsigned char uart_rx_byte(int idx) |