coreboot-kgpe-d16/src/drivers/uart/pl011.c
David Hendricks ff0d8698c2 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>
2018-02-13 01:19:40 +00:00

62 lines
1.5 KiB
C

/*
* 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
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <arch/io.h>
#include <boot/coreboot_tables.h>
#include <console/uart.h>
#include <drivers/uart/pl011.h>
void uart_init(int idx)
{
}
void uart_tx_byte(int idx, unsigned char 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)
{
return 0;
}
#ifndef __PRE_RAM__
void uart_fill_lb(void *data)
{
struct lb_serial serial;
serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED;
serial.baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
serial.baud = CONFIG_TTYS0_BAUD;
serial.regwidth = 1;
serial.input_hertz = uart_platform_refclk();
serial.uart_pci_addr = CONFIG_UART_PCI_ADDR;
lb_add_serial(&serial, data);
lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data);
}
#endif