dev/serial: Simplify zynq_uart_reset_tx_flush()

Load the status register only once.  Use _IO_Relax() to reduce bus
traffic while waiting and simplify testing.
This commit is contained in:
Sebastian Huber
2024-08-30 09:29:00 +02:00
parent 6757607199
commit 5d8d55a1cd

View File

@@ -131,11 +131,7 @@ void zynq_uart_initialize(volatile zynq_uart *regs)
uint32_t bauddiv = 0x6;
uint32_t mode_clks = regs->mode & ZYNQ_UART_MODE_CLKS;
while ((regs->channel_sts & ZYNQ_UART_CHANNEL_STS_TEMPTY) == 0 ||
(regs->channel_sts & ZYNQ_UART_CHANNEL_STS_TACTIVE) != 0) {
/* Wait */
}
zynq_uart_reset_tx_flush(regs);
zynq_cal_baud_rate(ZYNQ_UART_DEFAULT_BAUD, &brgr, &bauddiv, mode_clks);
regs->control = 0;
@@ -174,9 +170,10 @@ void zynq_uart_write_char_polled(volatile zynq_uart *regs, char c)
void zynq_uart_reset_tx_flush(volatile zynq_uart *regs)
{
while ((regs->channel_sts & ZYNQ_UART_CHANNEL_STS_TEMPTY) == 0 ||
(regs->channel_sts & ZYNQ_UART_CHANNEL_STS_TACTIVE) != 0) {
/* Wait */
while (
(regs->channel_sts &
(ZYNQ_UART_CHANNEL_STS_TEMPTY | ZYNQ_UART_CHANNEL_STS_TACTIVE)) !=
ZYNQ_UART_CHANNEL_STS_TEMPTY) {
_IO_Relax();
}
}