blob: 0c7ac08ed554514ac374b8168b585afce29b57ac [file] [log] [blame]
Hung-Te Lin7635a602013-02-12 00:07:38 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google, Inc.
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
Kyösti Mälkkibbf6f3d2014-03-15 01:32:55 +020016#include <boot/coreboot_tables.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020017#include <console/uart.h>
Hung-Te Lin7635a602013-02-12 00:07:38 +080018
Kyösti Mälkkic2610a42014-02-24 20:51:30 +020019static void pl011_uart_tx_byte(unsigned int *uart_base, unsigned char data)
Kyösti Mälkki7e75f202014-02-10 23:21:14 +020020{
Kyösti Mälkkic2610a42014-02-24 20:51:30 +020021 *uart_base = (unsigned int)data;
22}
Hung-Te Lin7635a602013-02-12 00:07:38 +080023
Kyösti Mälkki70342a72014-03-14 22:28:29 +020024void uart_init(int idx)
Hung-Te Lin7635a602013-02-12 00:07:38 +080025{
Hung-Te Lin7635a602013-02-12 00:07:38 +080026}
27
Kyösti Mälkki70342a72014-03-14 22:28:29 +020028void uart_tx_byte(int idx, unsigned char data)
Hung-Te Lin7635a602013-02-12 00:07:38 +080029{
Kyösti Mälkki70342a72014-03-14 22:28:29 +020030 unsigned int *uart_base = uart_platform_baseptr(idx);
Kyösti Mälkkic2610a42014-02-24 20:51:30 +020031 pl011_uart_tx_byte(uart_base, data);
Hung-Te Lin7635a602013-02-12 00:07:38 +080032}
33
Kyösti Mälkki70342a72014-03-14 22:28:29 +020034void uart_tx_flush(int idx)
Kyösti Mälkki7e75f202014-02-10 23:21:14 +020035{
Hung-Te Lin7635a602013-02-12 00:07:38 +080036}
Kyösti Mälkki0567c912014-02-14 10:31:38 +020037
Kyösti Mälkki70342a72014-03-14 22:28:29 +020038unsigned char uart_rx_byte(int idx)
Kyösti Mälkki0567c912014-02-14 10:31:38 +020039{
40 return 0;
41}
Kyösti Mälkkibbf6f3d2014-03-15 01:32:55 +020042
43#ifndef __PRE_RAM__
44void uart_fill_lb(void *data)
45{
46 struct lb_serial serial;
47 serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED;
Kyösti Mälkki70342a72014-03-14 22:28:29 +020048 serial.baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
Kyösti Mälkkibbf6f3d2014-03-15 01:32:55 +020049 serial.baud = default_baudrate();
Vadim Bendebury9dccf1c2015-01-09 16:54:19 -080050 serial.regwidth = 1;
Lee Leahy6ec72c92016-05-07 09:04:46 -070051 serial.input_hertz = uart_platform_refclk();
Lee Leahyf92a98c2016-05-04 11:59:19 -070052 serial.uart_pci_addr = CONFIG_UART_PCI_ADDR;
Kyösti Mälkkibbf6f3d2014-03-15 01:32:55 +020053 lb_add_serial(&serial, data);
54
55 lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data);
56}
57#endif