rcar_gen3: drivers: scif: Use TEND flag for transmission end detection

Use the SCIF SCFSR:TEND bit to check that all data were transmitted by
the SCIF and that there are no more valid data to transmit in the FIFO.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
diff --git a/drivers/renesas/rcar/scif/scif.S b/drivers/renesas/rcar/scif/scif.S
index 1cc0d59..09dc90b 100644
--- a/drivers/renesas/rcar/scif/scif.S
+++ b/drivers/renesas/rcar/scif/scif.S
@@ -75,6 +75,8 @@
 #if SCIF_CLK == SCIF_EXTARNAL_CLK
 #define	SCSCR_CKE_INT_CLK	(SCSCR_CKE_BRG)
 #else
+#define	SCFSR_TEND_MASK		(1 << 6)
+#define	SCFSR_TEND_TRANS_END	(0x0040)
 #define	SCSCR_CKE_INT_CLK	(SCSCR_CKE_INT)
 #endif
 #define	SCFSR_INIT_DATA		(0x0000)
@@ -281,6 +283,11 @@
 	bcs	2b
 	strb	w0, [x1, #SCIF_SCFTDR]
 
+	/* Clear TEND flag */
+	ldrh	w2, [x1, #SCIF_SCFSR]
+	and	w2, w2, #~SCFSR_TEND_MASK
+	strh	w2, [x1, #SCIF_SCFSR]
+
 	ret
 endfunc console_core_putc
 
@@ -309,16 +316,12 @@
 func console_flush
 	ldr	x0, =SCIF2_BASE
 1:
-	ldrh	w1, [x0, #SCIF_SCFDR]
-	ubfx	w1, w1, #8, #5
-	cmp	w1, #0
+	/* Check TEND flag */
+	ldrh	w1, [x0, #SCIF_SCFSR]
+	and	w1, w1, #SCFSR_TEND_MASK
+	cmp	w1, #SCFSR_TEND_TRANS_END
 	bne	1b
 
-	mov x0, #100
-	mov x3, x30
-	bl rcar_micro_delay
-	mov x30, x3
-
 	ldr	x0, =SCIF2_BASE
 	ldrh	w1, [x0, #SCIF_SCSCR]
 	and	w1, w1, #~(SCSCR_TE_EN + SCSCR_RE_EN)