2013-02-11 17:07:38 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Google, Inc.
|
2017-12-29 05:18:10 +01:00
|
|
|
* Copyright 2018-present Facebook, Inc.
|
2013-02-11 17:07:38 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2017-12-29 05:18:10 +01:00
|
|
|
#include <arch/io.h>
|
2014-03-15 00:32:55 +01:00
|
|
|
#include <boot/coreboot_tables.h>
|
2014-02-17 20:34:42 +01:00
|
|
|
#include <console/uart.h>
|
2017-12-29 05:18:10 +01:00
|
|
|
#include <drivers/uart/pl011.h>
|
2013-02-11 17:07:38 +01:00
|
|
|
|
2014-03-14 21:28:29 +01:00
|
|
|
void uart_init(int idx)
|
2014-02-24 19:51:30 +01:00
|
|
|
{
|
2013-02-11 17:07:38 +01:00
|
|
|
}
|
|
|
|
|
2014-03-14 21:28:29 +01:00
|
|
|
void uart_tx_byte(int idx, unsigned char data)
|
2013-02-11 17:07:38 +01:00
|
|
|
{
|
2017-12-29 05:18:10 +01:00
|
|
|
struct pl011_uart *regs = uart_platform_baseptr(idx);
|
|
|
|
|
|
|
|
write8(®s->dr, data);
|
|
|
|
uart_tx_flush(idx);
|
2013-02-11 17:07:38 +01:00
|
|
|
}
|
|
|
|
|
2014-03-14 21:28:29 +01:00
|
|
|
void uart_tx_flush(int idx)
|
2014-02-10 22:21:14 +01:00
|
|
|
{
|
2017-12-29 05:18:10 +01:00
|
|
|
struct pl011_uart *regs = uart_platform_baseptr(idx);
|
|
|
|
|
|
|
|
/* FIXME: add a timeout */
|
|
|
|
while (!(read32(®s->fr) & PL011_UARTFR_TXFE))
|
|
|
|
;
|
2013-02-11 17:07:38 +01:00
|
|
|
}
|
2014-02-14 09:31:38 +01:00
|
|
|
|
2014-03-14 21:28:29 +01:00
|
|
|
unsigned char uart_rx_byte(int idx)
|
2014-02-14 09:31:38 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-15 00:32:55 +01:00
|
|
|
|
|
|
|
#ifndef __PRE_RAM__
|
|
|
|
void uart_fill_lb(void *data)
|
|
|
|
{
|
|
|
|
struct lb_serial serial;
|
|
|
|
serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED;
|
2014-03-14 21:28:29 +01:00
|
|
|
serial.baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
|
2017-05-12 21:16:41 +02:00
|
|
|
serial.baud = CONFIG_TTYS0_BAUD;
|
2015-01-10 01:54:19 +01:00
|
|
|
serial.regwidth = 1;
|
2016-05-07 18:04:46 +02:00
|
|
|
serial.input_hertz = uart_platform_refclk();
|
2016-05-04 20:59:19 +02:00
|
|
|
serial.uart_pci_addr = CONFIG_UART_PCI_ADDR;
|
2014-03-15 00:32:55 +01:00
|
|
|
lb_add_serial(&serial, data);
|
|
|
|
|
|
|
|
lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data);
|
|
|
|
}
|
|
|
|
#endif
|