[U-Boot] [PATCH 16/45] serial: Allow serial to be absent in TPL

Simon Glass sjg at chromium.org
Mon Oct 1 18:22:20 UTC 2018


At present this option applies to SPL, but it should be available in TPL
also, and separately. Change to using CONFIG_IS_ENABLED(), add a new
Kconfig option and fix up hang().

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/serial/Kconfig         | 10 ++++++++++
 drivers/serial/serial-uclass.c |  4 ++++
 lib/hang.c                     |  5 +++--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 83f8c94d028..597db4b9cbb 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -53,6 +53,16 @@ config SPL_SERIAL_PRESENT
 	  This option enables the full UART in SPL, so if is it disabled,
 	  the full UART driver will be omitted, thus saving space.
 
+config TPL_SERIAL_PRESENT
+	bool "Provide a serial driver in TPL"
+	depends on DM_SERIAL
+	default y
+	help
+	  In very space-constrained devices even the full UART driver is too
+	  large. In this case the debug UART can still be used in some cases.
+	  This option enables the full UART in TPL, so if is it disabled,
+	  the full UART driver will be omitted, thus saving space.
+
 # Logic to allow us to use the imply keyword to set what the default port
 # should be.  The default is otherwise 1.
 config CONS_INDEX_0
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index ffdcae09318..e50f0aa8510 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -26,6 +26,7 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
 #error "Serial is required before relocation - define CONFIG_$(SPL_)SYS_MALLOC_F_LEN to make this work"
 #endif
 
+#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
 static int serial_check_stdout(const void *blob, struct udevice **devp)
 {
 	int node;
@@ -150,12 +151,15 @@ static void serial_find_console_or_panic(void)
 	panic_str("No serial driver found");
 #endif
 }
+#endif /* CONFIG_SERIAL_PRESENT */
 
 /* Called prior to relocation */
 int serial_init(void)
 {
+#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
 	serial_find_console_or_panic();
 	gd->flags |= GD_FLG_SERIAL_READY;
+#endif
 
 	return 0;
 }
diff --git a/lib/hang.c b/lib/hang.c
index bf56f4c662a..c5a78694be6 100644
--- a/lib/hang.c
+++ b/lib/hang.c
@@ -20,8 +20,9 @@
  */
 void hang(void)
 {
-#if !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && \
-		defined(CONFIG_SPL_SERIAL_SUPPORT))
+#if !defined(CONFIG_SPL_BUILD) || \
+		(CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT) && \
+		 CONFIG_IS_ENABLED(SERIAL_SUPPORT))
 	puts("### ERROR ### Please RESET the board ###\n");
 #endif
 	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
-- 
2.19.0.605.g01d371f741-goog



More information about the U-Boot mailing list