1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
4 #include <boot/coreboot_tables.h>
5 #include <console/uart.h>
6 #include <drivers/uart/pl011.h>
8 void uart_init(unsigned int idx
)
12 void uart_tx_byte(unsigned int idx
, unsigned char data
)
14 struct pl011_uart
*regs
= uart_platform_baseptr(idx
);
16 write8(®s
->dr
, data
);
20 void uart_tx_flush(unsigned int idx
)
22 struct pl011_uart
*regs
= uart_platform_baseptr(idx
);
24 /* FIXME: add a timeout */
25 while (!(read32(®s
->fr
) & PL011_UARTFR_TXFE
))
29 unsigned char uart_rx_byte(unsigned int idx
)
31 struct pl011_uart
*regs
= uart_platform_baseptr(idx
);
33 while (read32(®s
->fr
) & PL011_UARTFR_RXFE
)
35 return read8(®s
->dr
);
38 enum cb_err
fill_lb_serial(struct lb_serial
*serial
)
40 serial
->type
= LB_SERIAL_TYPE_MEMORY_MAPPED
;
41 serial
->baseaddr
= uart_platform_base(CONFIG_UART_FOR_CONSOLE
);
42 serial
->baud
= get_uart_baudrate();
44 serial
->input_hertz
= uart_platform_refclk();