[PATCH 047/111] APBUART: debug bit was cleared incorrectly

Daniel Hellstrom daniel at gaisler.com
Thu Feb 26 16:38:49 UTC 2015


---
 c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c |   32 ++++++++++----------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index 64d1b15..e0fa64e 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -197,29 +197,29 @@ int apbuart_init1(struct drvmgr_dev *dev)
 
 	/* Clear HW regs, leave baudrate register as it is */
 	priv->regs->status = 0;
-	/* leave debug bit, and Transmitter/receiver if this is the debug UART.
-	 * With old APBUARTs debug is enabled by setting LB and FL, since LB is
-	 * not reset we can not trust is, however since FL is reset we guess
-	 * that we are debugging old UART if both FL and LB is already set.
+
+	/* leave Transmitter/receiver if this is the RTEMS debug UART (assume
+	 * it has been setup by boot loader).
 	 */
+	db = 0;
 #ifdef LEON3
 	if (priv->regs == dbg_uart) {
-		db = priv->regs->ctrl & (LEON_REG_UART_CTRL_DB |
-					LEON_REG_UART_CTRL_RE |
+		db = priv->regs->ctrl & (LEON_REG_UART_CTRL_RE |
 					LEON_REG_UART_CTRL_TE |
-					LEON_REG_UART_CTRL_FL |
-					LEON_REG_UART_CTRL_LB |
 					LEON_REG_UART_CTRL_PE |
 					LEON_REG_UART_CTRL_PS);
-	} else
+	}
 #endif
-	{
-		if (priv->regs->ctrl & (LEON_REG_UART_CTRL_FL |
-					LEON_REG_UART_CTRL_LB))
-			db = priv->regs->ctrl & (LEON_REG_UART_CTRL_FL |
-					LEON_REG_UART_CTRL_LB);
-		else					
-			db = priv->regs->ctrl & LEON_REG_UART_CTRL_DB;
+	/* Let UART debug tunnelling be untouched if Flow-control is set.
+	 *
+	 * With old APBUARTs debug is enabled by setting LB and FL, since LB or
+	 * DB are not reset we can not trust them. However since FL is reset we
+	 * guess that we are debugging if FL is already set, the debugger set
+	 * either LB or DB depending on UART capabilities.
+	 */
+	if (priv->regs->ctrl & LEON_REG_UART_CTRL_FL) {
+		db |= priv->regs->ctrl & (LEON_REG_UART_CTRL_DB |
+		      LEON_REG_UART_CTRL_LB | LEON_REG_UART_CTRL_FL);
 	}
 
 	priv->regs->ctrl = db;
-- 
1.7.0.4




More information about the devel mailing list