[U-Boot] [PATCH] sparc: Fix redefinition of macros in serial driver

Marek Vasut marex at denx.de
Wed Oct 31 17:29:12 CET 2012


The serial driver for both LEON2 and LEON3 redefined IO access macros
and caused compile errors. Fix this by using the common IO access
macros and removing the duplicates from the serial driver.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Tom Rini <trini at ti.com>
Cc: Daniel Hellstrom <daniel at gaisler.com>
---
 arch/sparc/cpu/leon2/serial.c |   21 +++++++--------------
 arch/sparc/cpu/leon3/serial.c |   21 +++++++--------------
 2 files changed, 14 insertions(+), 28 deletions(-)

btw. Dan, do you still have one sparc board too much ? ;-)

diff --git a/arch/sparc/cpu/leon2/serial.c b/arch/sparc/cpu/leon2/serial.c
index 40d5b01..94a9fcd 100644
--- a/arch/sparc/cpu/leon2/serial.c
+++ b/arch/sparc/cpu/leon2/serial.c
@@ -32,14 +32,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Force cache miss each time a serial controller reg is read */
-#define CACHE_BYPASS 1
-
-#ifdef CACHE_BYPASS
-#define READ_BYTE(var)  SPARC_NOCACHE_READ_BYTE((unsigned int)&(var))
-#define READ_HWORD(var) SPARC_NOCACHE_READ_HWORD((unsigned int)&(var))
-#define READ_WORD(var)  SPARC_NOCACHE_READ((unsigned int)&(var))
-#define READ_DWORD(var) SPARC_NOCACHE_READ_DWORD((unsigned int)&(var))
-#endif
+#undef CONFIG_SYS_HAS_NO_CACHE
 
 static int leon2_serial_init(void)
 {
@@ -62,7 +55,7 @@ static int leon2_serial_init(void)
 	regs->UART_Scaler = CONFIG_SYS_LEON2_UART1_SCALER;
 
 	/* Let bit 11 be unchanged (debug bit for GRMON) */
-	tmp = READ_WORD(regs->UART_Control);
+	tmp = READ_WORD(&regs->UART_Control);
 
 	regs->UART_Control = ((tmp & LEON2_UART_CTRL_DBG) |
 			      (LEON2_UART1_LOOPBACK_ENABLE << 7) |
@@ -86,14 +79,14 @@ static void leon2_serial_putc_raw(const char c)
 #endif
 
 	/* Wait for last character to go. */
-	while (!(READ_WORD(regs->UART_Status) & LEON2_UART_STAT_THE)) ;
+	while (!(READ_WORD(&regs->UART_Status) & LEON2_UART_STAT_THE)) ;
 
 	/* Send data */
 	regs->UART_Channel = c;
 
 #ifdef LEON_DEBUG
 	/* Wait for data to be sent */
-	while (!(READ_WORD(regs->UART_Status) & LEON2_UART_STAT_TSE)) ;
+	while (!(READ_WORD(&regs->UART_Status) & LEON2_UART_STAT_TSE)) ;
 #endif
 }
 
@@ -117,10 +110,10 @@ static int leon2_serial_getc(void)
 #endif
 
 	/* Wait for a character to arrive. */
-	while (!(READ_WORD(regs->UART_Status) & LEON2_UART_STAT_DR)) ;
+	while (!(READ_WORD(&regs->UART_Status) & LEON2_UART_STAT_DR)) ;
 
 	/* read data */
-	return READ_WORD(regs->UART_Channel);
+	return READ_WORD(&regs->UART_Channel);
 }
 
 static int leon2_serial_tstc(void)
@@ -134,7 +127,7 @@ static int leon2_serial_tstc(void)
 	regs = (LEON2_Uart_regs *) & leon2->UART_Channel_2;
 #endif
 
-	return (READ_WORD(regs->UART_Status) & LEON2_UART_STAT_DR);
+	return (READ_WORD(&regs->UART_Status) & LEON2_UART_STAT_DR);
 }
 
 /* set baud rate for uart */
diff --git a/arch/sparc/cpu/leon3/serial.c b/arch/sparc/cpu/leon3/serial.c
index 838d451..dcd0ac1 100644
--- a/arch/sparc/cpu/leon3/serial.c
+++ b/arch/sparc/cpu/leon3/serial.c
@@ -33,14 +33,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Force cache miss each time a serial controller reg is read */
-#define CACHE_BYPASS 1
-
-#ifdef CACHE_BYPASS
-#define READ_BYTE(var)  SPARC_NOCACHE_READ_BYTE((unsigned int)&(var))
-#define READ_HWORD(var) SPARC_NOCACHE_READ_HWORD((unsigned int)&(var))
-#define READ_WORD(var)  SPARC_NOCACHE_READ((unsigned int)&(var))
-#define READ_DWORD(var) SPARC_NOCACHE_READ_DWORD((unsigned int)&(var))
-#endif
+#undef CONFIG_SYS_HAS_NO_CACHE
 
 ambapp_dev_apbuart *leon3_apbuart = NULL;
 
@@ -63,7 +56,7 @@ static int leon3_serial_init(void)
 		leon3_apbuart->scaler = CONFIG_SYS_GRLIB_APBUART_SCALER;
 
 		/* Let bit 11 be unchanged (debug bit for GRMON) */
-		tmp = READ_WORD(leon3_apbuart->ctrl);
+		tmp = READ_WORD(&leon3_apbuart->ctrl);
 
 		leon3_apbuart->ctrl = ((tmp & LEON_REG_UART_CTRL_DBG) |
 				       LEON_REG_UART_CTRL_RE |
@@ -80,14 +73,14 @@ static void leon3_serial_putc_raw(const char c)
 		return;
 
 	/* Wait for last character to go. */
-	while (!(READ_WORD(leon3_apbuart->status) & LEON_REG_UART_STATUS_THE)) ;
+	while (!(READ_WORD(&leon3_apbuart->status) & LEON_REG_UART_STATUS_THE)) ;
 
 	/* Send data */
 	leon3_apbuart->data = c;
 
 #ifdef LEON_DEBUG
 	/* Wait for data to be sent */
-	while (!(READ_WORD(leon3_apbuart->status) & LEON_REG_UART_STATUS_TSE)) ;
+	while (!(READ_WORD(&leon3_apbuart->status) & LEON_REG_UART_STATUS_TSE)) ;
 #endif
 }
 
@@ -105,16 +98,16 @@ static int leon3_serial_getc(void)
 		return 0;
 
 	/* Wait for a character to arrive. */
-	while (!(READ_WORD(leon3_apbuart->status) & LEON_REG_UART_STATUS_DR)) ;
+	while (!(READ_WORD(&leon3_apbuart->status) & LEON_REG_UART_STATUS_DR)) ;
 
 	/* read data */
-	return READ_WORD(leon3_apbuart->data);
+	return READ_WORD(&leon3_apbuart->data);
 }
 
 static int leon3_serial_tstc(void)
 {
 	if (leon3_apbuart)
-		return (READ_WORD(leon3_apbuart->status) &
+		return (READ_WORD(&leon3_apbuart->status) &
 			LEON_REG_UART_STATUS_DR);
 	return 0;
 }
-- 
1.7.10.4



More information about the U-Boot mailing list