[U-Boot] [PATCH] enable debug uart

Andes uboot at andestech.com
Wed Nov 15 02:48:22 UTC 2017


From: rick <rick at andestech.com>

---
 common/board_f.c            |    2 ++
 configs/adp-ae3xx_defconfig |    5 +++++
 drivers/serial/Kconfig      |    8 ++++++++
 drivers/serial/ns16550.c    |    5 +++--
 include/debug_uart.h        |    2 ++
 lib/display_options.c       |    2 ++
 6 files changed, 22 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 common/board_f.c
 mode change 100644 => 100755 common/init/board_init.c
 mode change 100644 => 100755 configs/adp-ae3xx_defconfig
 mode change 100644 => 100755 drivers/serial/Kconfig
 mode change 100644 => 100755 drivers/serial/ns16550.c
 mode change 100644 => 100755 include/debug_uart.h
 mode change 100644 => 100755 lib/display_options.c

diff --git a/common/board_f.c b/common/board_f.c
old mode 100644
new mode 100755
index 104d144..1024987
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -902,6 +902,8 @@ static const init_fnc_t init_sequence_f[] = {
 
 void board_init_f(ulong boot_flags)
 {
+//printf("board_init_f\n");
+//while(1);
 	gd->flags = boot_flags;
 	gd->have_console = 0;
 
diff --git a/common/init/board_init.c b/common/init/board_init.c
old mode 100644
new mode 100755
diff --git a/configs/adp-ae3xx_defconfig b/configs/adp-ae3xx_defconfig
old mode 100644
new mode 100755
index db9ee61..02386d6
--- a/configs/adp-ae3xx_defconfig
+++ b/configs/adp-ae3xx_defconfig
@@ -38,3 +38,8 @@ CONFIG_DM_SPI=y
 CONFIG_NDS_AE3XX_SPI=y
 CONFIG_TIMER=y
 CONFIG_AE3XX_TIMER=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_BASE=0xf0300000
+CONFIG_DEBUG_UART_CLOCK=14745600
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_DEBUG_UART_OFFSET=32
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
old mode 100644
new mode 100755
index aeed538..34d49be
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -319,6 +319,14 @@ config DEBUG_UART_SHIFT
 	  value. Use this value to specify the shift to use, where 0=byte
 	  registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_OFFSET
+	int "UART register offset"
+	depends on DEBUG_UART
+	default 0 if DEBUG_UART
+	help
+	  Offset to apply to the mapbase from the start of the registers.
+
+
 config DEBUG_UART_BOARD_INIT
 	bool "Enable board-specific debug UART init"
 	depends on DEBUG_UART
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
old mode 100644
new mode 100755
index c702304..b67af3d
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -31,8 +31,9 @@ DECLARE_GLOBAL_DATA_PTR;
 #define serial_out(x, y)	out_le32(y, x)
 #define serial_in(y)		in_le32(y)
 #else
-#define serial_out(x, y)	writeb(x, y)
-#define serial_in(y)		readb(y)
+@
+#define serial_out(x, y)	writeb(x, y+CONFIG_SYS_NS16550_REG_OFFSET)
+#define serial_in(y)		readb(y+CONFIG_SYS_NS16550_REG_OFFSET)
 #endif
 #endif /* !CONFIG_DM_SERIAL */
 
diff --git a/include/debug_uart.h b/include/debug_uart.h
old mode 100644
new mode 100755
index 6f0b0c5..a369fb2
--- a/include/debug_uart.h
+++ b/include/debug_uart.h
@@ -113,11 +113,13 @@ void printhex8(uint value);
 
 #define serial_dout(reg, value)	\
 	serial_out_shift((char *)com_port + \
+		CONFIG_DEBUG_UART_OFFSET + \
 		((char *)reg - (char *)com_port) * \
 			(1 << CONFIG_DEBUG_UART_SHIFT), \
 		CONFIG_DEBUG_UART_SHIFT, value)
 #define serial_din(reg) \
 	serial_in_shift((char *)com_port + \
+		CONFIG_DEBUG_UART_OFFSET + \
 		((char *)reg - (char *)com_port) * \
 			(1 << CONFIG_DEBUG_UART_SHIFT), \
 		CONFIG_DEBUG_UART_SHIFT)
diff --git a/lib/display_options.c b/lib/display_options.c
old mode 100644
new mode 100755
index 4ea27ca..8ee63ce
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -41,6 +41,8 @@ char *display_options_get_banner(bool newlines, char *buf, int size)
 
 int display_options(void)
 {
+printf("display_options\n");
+//while(1);
 	char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
 
 	display_options_get_banner(true, buf, sizeof(buf));
-- 
1.7.9.5



More information about the U-Boot mailing list