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>
This commit is contained in:
David Hendricks
2017-12-28 20:18:10 -08:00
committed by David Hendricks
parent 3b63e0fb5a
commit ff0d8698c2
2 changed files with 106 additions and 7 deletions

View File

@@ -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)