arm/zynq: Wait for the UART TX FIFO to empty on reset.

This commit is contained in:
Chris Johns
2016-11-25 09:45:35 +11:00
parent 6a1b9e4152
commit 8fd465e67e
3 changed files with 24 additions and 0 deletions

View File

@@ -226,3 +226,16 @@ const console_fns zynq_uart_fns = {
.deviceSetAttributes = zynq_uart_set_attribues,
.deviceOutputUsesInterrupts = false
};
void zynq_uart_reset_tx_flush(int minor)
{
volatile zynq_uart *regs = zynq_uart_get_regs(minor);
int c = 4;
while (c-- > 0)
zynq_uart_write_polled(minor, '\r');
while ((regs->channel_sts & ZYNQ_UART_CHANNEL_STS_TEMPTY) == 0) {
/* Wait */
}
}

View File

@@ -35,6 +35,11 @@ extern "C" {
extern const console_fns zynq_uart_fns;
/**
* Flush TX FIFO and wait until it is empty. Used in bsp_reset.
*/
void zynq_uart_reset_tx_flush(int minor);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -12,13 +12,19 @@
* http://www.rtems.org/license/LICENSE.
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <bsp/zynq-uart.h>
void bsp_reset(void)
{
volatile uint32_t *slcr_unlock = (volatile uint32_t *) 0xf8000008;
volatile uint32_t *pss_rst_ctrl = (volatile uint32_t *) 0xf8000200;
if (Console_Port_Tbl != NULL) {
zynq_uart_reset_tx_flush((int) Console_Port_Minor);
}
while (true) {
*slcr_unlock = 0xdf0d;
*pss_rst_ctrl = 0x1;