public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Dannenberg <dannenberg@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/7] arm: K3: common: Allow for early console functionality
Date: Thu, 15 Aug 2019 15:55:28 -0500	[thread overview]
Message-ID: <20190815205532.16545-4-dannenberg@ti.com> (raw)
In-Reply-To: <20190815205532.16545-1-dannenberg@ti.com>

Implement an early console functionality in SPL that can be used before
the main console is being brought up. This helps in situations where the
main console is dependent on System Firmware (SYSFW) being up and running,
which is usually not the case during the very early stages of boot. Using
this early console functionality will allow for an alternate serial port
to be used to support things like UART-based boot and early diagnostic
messages until the main console is ready to get activated.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
---
 arch/arm/mach-k3/Kconfig  | 21 +++++++++++++++++++++
 arch/arm/mach-k3/common.c | 26 ++++++++++++++++++++++++++
 arch/arm/mach-k3/common.h |  1 +
 3 files changed, 48 insertions(+)

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index 9652c96a78..a878277e39 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -66,6 +66,27 @@ config SYS_K3_BOOT_CORE_ID
 	int
 	default 16
 
+config K3_EARLY_CONS
+	bool "Activate to allow for an early console during SPL"
+	depends on SPL
+	help
+	  Turn this option on to enable an early console functionality in SPL
+	  before the main console is being brought up. This can be useful in
+	  situations where the main console is dependent on System Firmware
+	  (SYSFW) being up and running, which is usually not the case during
+	  the very early stages of boot. Using this early console functionality
+	  will allow for an alternate serial port to be used to support things
+	  like UART-based boot and early diagnostic messages until the main
+	  console is ready to get activated.
+
+config K3_EARLY_CONS_IDX
+	depends on K3_EARLY_CONS
+	int "Index of serial device to use for SPL early console"
+	default 1
+	help
+	  Use this option to set the index of the serial device to be used
+	  for the early console during SPL execution.
+
 config K3_LOAD_SYSFW
 	bool
 	depends on SPL
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index bab5ffdf40..279bd96467 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -27,6 +27,32 @@ struct ti_sci_handle *get_ti_sci_handle(void)
 	return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw(dev);
 }
 
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_K3_EARLY_CONS
+int early_console_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	gd->baudrate = CONFIG_BAUDRATE;
+
+	ret = uclass_get_device_by_seq(UCLASS_SERIAL, CONFIG_K3_EARLY_CONS_IDX,
+				       &dev);
+	if (ret) {
+		printf("Error getting serial dev for early console! (%d)\n",
+		       ret);
+		return ret;
+	}
+
+	gd->cur_serial_dev = dev;
+	gd->flags |= GD_FLG_SERIAL_READY;
+	gd->have_console = 1;
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_SYS_K3_SPL_ATF
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h
index ac7e80d9af..ab68e14de8 100644
--- a/arch/arm/mach-k3/common.h
+++ b/arch/arm/mach-k3/common.h
@@ -9,3 +9,4 @@
 #include <asm/armv7_mpu.h>
 
 void setup_k3_mpu_regions(void);
+int early_console_init(void);
-- 
2.17.1

  parent reply	other threads:[~2019-08-15 20:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 20:55 [U-Boot] [PATCH 0/7] Implement UART-based boot of TI K3 AM65x SoCs Andreas Dannenberg
2019-08-15 20:55 ` [U-Boot] [PATCH 1/7] spl: ymodem: Fix FIT loading termination handling Andreas Dannenberg
2019-10-12 20:23   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 2/7] spl: ymodem: Make SPL Y-Modem loader framework accessible Andreas Dannenberg
2019-10-12 20:23   ` Tom Rini
2019-08-15 20:55 ` Andreas Dannenberg [this message]
2019-10-12 20:23   ` [U-Boot] [PATCH 3/7] arm: K3: common: Allow for early console functionality Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 4/7] arm: K3: sysfw-loader: Allow loading SYSFW via Y-Modem Andreas Dannenberg
2019-10-12 20:23   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 5/7] armv7R: dts: k3: am654: Add MCU_UART0 related definitions Andreas Dannenberg
2019-10-12 20:24   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 6/7] configs: am65x_evm_r5: Activate early console functionality Andreas Dannenberg
2019-10-12 20:24   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 7/7] board: ti: am65x: Add UART boot procedure in README Andreas Dannenberg
2019-10-12 20:24   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190815205532.16545-4-dannenberg@ti.com \
    --to=dannenberg@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox