From ba89878d702954d5f438df29ff1b0e0e90519db9 Mon Sep 17 00:00:00 2001
From: Mario Kicherer <dev@kicherer.org>
Date: Wed, 1 Feb 2023 14:16:22 +0800
Subject: [PATCH] armv7: ls102xa: make QSPI clock selection optional during SoC
 init

To improve startup times when booting from QSPI flash, the QSPI frequency
can be configured very early in the boot process [1] to reduce loading
times of U-Boot itself. This patch adds an option to disable setting the
frequency to a default value during SoC initialization.

[1] https://www.nxp.com/docs/en/application-note/AN12279.pdf

Signed-off-by: Mario Kicherer <dev@kicherer.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/cpu/armv7/ls102xa/Kconfig | 9 +++++++++
 arch/arm/cpu/armv7/ls102xa/soc.c   | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/Kconfig b/arch/arm/cpu/armv7/ls102xa/Kconfig
index 0edcf4c5ee..3e292bf70e 100644
--- a/arch/arm/cpu/armv7/ls102xa/Kconfig
+++ b/arch/arm/cpu/armv7/ls102xa/Kconfig
@@ -96,4 +96,13 @@ config SYS_FSL_HAS_CCI400
 config SYS_FSL_ERRATUM_A008407
 	bool
 
+config SYS_FSL_QSPI_SKIP_CLKSEL
+	bool "Skip setting QSPI clock during SoC init"
+	default 0
+	help
+	   To improve startup times when booting from QSPI flash, the QSPI
+	   frequency can be set very early in the boot process. If this option
+	   is enabled, the QSPI frequency will not be changed by U-Boot during
+	   SoC initialization.
+
 endmenu
diff --git a/arch/arm/cpu/armv7/ls102xa/soc.c b/arch/arm/cpu/armv7/ls102xa/soc.c
index 1dafa3c1b4..84d4ea3a8f 100644
--- a/arch/arm/cpu/armv7/ls102xa/soc.c
+++ b/arch/arm/cpu/armv7/ls102xa/soc.c
@@ -170,7 +170,7 @@ int arch_soc_init(void)
 	enable_layerscape_ns_access();
 #endif
 
-#ifdef CONFIG_FSL_QSPI
+#if defined(CONFIG_FSL_QSPI) && !defined(CONFIG_SYS_FSL_QSPI_SKIP_CLKSEL)
 	out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
 #endif
 
-- 
2.39.5