summaryrefslogtreecommitdiff
path: root/src/drivers/uart/pl011.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/uart/pl011.c')
-rw-r--r--src/drivers/uart/pl011.c19
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(&regs->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(&regs->fr) & PL011_UARTFR_TXFE))
+ ;
}
unsigned char uart_rx_byte(int idx)