Skip to contentSkip to conversation

Support SPL for i.MX7ULP

PATCH Superseded Oleksandr Suvorov 5 participants 13 messages Sep 12, 2021 – Feb 5, 2022

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Support SPL for i.MX7ULP

This patchset adds SPL support for mx7ulp-based boards.

Changes in v2:
- add a patch with SPL support for mx7ulp_com board.

Oleksandr Suvorov (1):
mx7ulp: select soc features

Ricardo Salveti (2):
mx7ulp: add base SPL support for mx7ulp
mx7ulp_com: add support for SPL

 arch/arm/Makefile                    |  2 +-
 arch/arm/dts/imx7ulp-com-u-boot.dtsi | 37 +++++++++++++++++++++
 arch/arm/dts/imx7ulp-com.dts         |  1 +
 arch/arm/mach-imx/Makefile           |  2 +-
 arch/arm/mach-imx/mx7ulp/Kconfig     | 15 +++++++++
 arch/arm/mach-imx/mx7ulp/soc.c       |  2 +-
 arch/arm/mach-imx/spl.c              | 12 +++++--
 board/ea/mx7ulp_com/mx7ulp_com.c     | 26 +++++++++++++++
 include/configs/imx7ulp_spl.h        | 48 ++++++++++++++++++++++++++++
 include/configs/mx7ulp_com.h         |  6 ++++
 10 files changed, 145 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/imx7ulp-com-u-boot.dtsi
 create mode 100644 include/configs/imx7ulp_spl.h
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/3 mx7ulp: select soc features

Force selecting features present in SoC i.MX7ULP.

---

(no changes since v1)

 arch/arm/mach-imx/mx7ulp/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-imx/mx7ulp/Kconfig +3 -0
index 2ffac9cf7c..56a3efd7b9 100644
@@ -9,6 +9,9 @@ config LDO_ENABLED_MODE
 	  Select this option to enable the PMC1 LDO.
 
 config MX7ULP
+	select ARCH_SUPPORT_PSCI
+	select CPU_V7_HAS_NONSEC
+	select CPU_V7_HAS_VIRT
 	select HAS_CAAM
 	bool
 
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 2/3 mx7ulp: add base SPL support for mx7ulp

From: Ricardo Salveti <[email protected]>

Add a base implementation of mx7ulp SPL config header and soc, and changes in makefiles in order to allow building SPL on mx7ulp based devices.

---

Changes in v2:
- fix typo in comments

 arch/arm/Makefile              |  2 +-
 arch/arm/mach-imx/Makefile     |  2 +-
 arch/arm/mach-imx/mx7ulp/soc.c |  2 +-
 arch/arm/mach-imx/spl.c        | 12 ++++++---
 include/configs/imx7ulp_spl.h  | 48 ++++++++++++++++++++++++++++++++++
 5 files changed, 60 insertions(+), 6 deletions(-)
 create mode 100644 include/configs/imx7ulp_spl.h
arch/arm/Makefile +1 -1
index c68e598a67..03582af414 100644
@@ -107,7 +107,7 @@ libs-y += arch/arm/cpu/
 libs-y += arch/arm/lib/
 
 ifeq ($(CONFIG_SPL_BUILD),y)
-ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter $(SOC), mx25 mx5 mx6 mx7 mx35 imx8m imx8 imx8ulp imxrt))
+ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter $(SOC), mx25 mx5 mx6 mx7 mx7ulp mx35 imx8m imx8 imx8ulp imxrt))
 libs-y += arch/arm/mach-imx/
 endif
 else
arch/arm/mach-imx/Makefile +1 -1
index 0ef269563d..2ecd1280d4 100644
@@ -28,7 +28,7 @@ endif
 obj-$(CONFIG_GPT_TIMER) += timer.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
 endif
-ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs imx8m imx8 imxrt))
+ifeq ($(SOC),$(filter $(SOC),mx7 mx7ulp mx6 mxs imx8m imx8 imxrt))
 obj-y	+= misc.o
 obj-$(CONFIG_CMD_PRIBLOB) += priblob.o
 obj-$(CONFIG_SPL_BUILD)	+= spl.o
arch/arm/mach-imx/mx7ulp/soc.c +1 -1
index 320f24dd29..6815d73ca6 100644
@@ -196,7 +196,7 @@ void s_init(void)
 }
 #endif
 
-#ifndef CONFIG_ULP_WATCHDOG
+#if !CONFIG_IS_ENABLED(ULP_WATCHDOG) || CONFIG_IS_ENABLED(SPL_BUILD)
 void reset_cpu(void)
 {
 	setbits_le32(SIM0_RBASE, SIM_SOPT1_A7_SW_RESET);
arch/arm/mach-imx/spl.c +9 -3
index 36033d611c..2c5ab67154 100644
@@ -111,8 +111,12 @@ u32 spl_boot_device(void)
 	return BOOT_DEVICE_NONE;
 }
 
-#elif defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8)
-/* Translate iMX7/i.MX8M boot device to the SPL boot device enumeration */
+#elif defined(CONFIG_MX7) || defined(CONFIG_MX7ULP) || \
+	defined(CONFIG_IMX8M) || defined(CONFIG_IMX8)
+/*
+ * Translate iMX7/i.MX7ULP/i.MX8M/i.MX8 boot device to the SPL boot
+ * device enumeration
+ */
 u32 spl_boot_device(void)
 {
 #if defined(CONFIG_MX7)
@@ -124,7 +128,9 @@ u32 spl_boot_device(void)
 	 */
 	if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
 		return BOOT_DEVICE_BOARD;
+#endif
 
+#if defined(CONFIG_MX7) || defined(CONFIG_MX7ULP)
 	/*
 	 * The above method does not detect that the boot ROM used
 	 * serial downloader in case the boot ROM decided to use the
@@ -182,7 +188,7 @@ u32 spl_boot_device(void)
 		return BOOT_DEVICE_NONE;
 	}
 }
-#endif /* CONFIG_MX7 || CONFIG_IMX8M || CONFIG_IMX8 */
+#endif /* CONFIG_MX7 || CONFIG_MX7ULP || CONFIG_IMX8M || CONFIG_IMX8 */
 
 #ifdef CONFIG_SPL_USB_GADGET
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
include/configs/imx7ulp_spl.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.31.1
#3 lore raw

PATCH v2 3/3 mx7ulp_com: add support for SPL

From: Ricardo Salveti <[email protected]>

Add EA iMX7ULP COM board support for building SPL.

---

Changes in v2:
- add a patch with SPL support for mx7ulp_com board.

 arch/arm/dts/imx7ulp-com-u-boot.dtsi | 37 ++++++++++++++++++++++++++++
 arch/arm/dts/imx7ulp-com.dts         |  1 +
 arch/arm/mach-imx/mx7ulp/Kconfig     | 12 +++++++++
 board/ea/mx7ulp_com/mx7ulp_com.c     | 26 +++++++++++++++++++
 include/configs/mx7ulp_com.h         |  6 +++++
 5 files changed, 82 insertions(+)
 create mode 100644 arch/arm/dts/imx7ulp-com-u-boot.dtsi
arch/arm/dts/imx7ulp-com-u-boot.dtsi new file +37 -0
new file mode 100644
index 0000000000..d73bfbf7a0
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0+ OR X11
+/*
+ * Copyright 2019 Foundries.io
+ */
+
+&iomuxc1 {
+	u-boot,dm-spl;
+};
+
+&ahbbridge0 {
+	u-boot,dm-spl;
+};
+
+&ahbbridge1 {
+	u-boot,dm-spl;
+};
+
+&lpuart4 {
+	u-boot,dm-spl;
+};
+
+&usbotg1 {
+	extcon = <&usbphy1>;
+	u-boot,dm-spl;
+};
+
+&usbphy1 {
+	u-boot,dm-spl;
+};
+
+&usdhc0 {
+	u-boot,dm-spl;
+};
+
+&gpio0 {
+	u-boot,dm-spl;
+};
arch/arm/dts/imx7ulp-com.dts +1 -0
index c01e03dd06..dcfa37441f 100644
@@ -6,6 +6,7 @@
 /dts-v1/;
 
 #include "imx7ulp.dtsi"
+#include "imx7ulp-com-u-boot.dtsi"
 
 / {
 	model = "Embedded Artists i.MX7ULP COM";
arch/arm/mach-imx/mx7ulp/Kconfig +12 -0
index 56a3efd7b9..15c3ab6dae 100644
@@ -23,6 +23,18 @@ config TARGET_MX7ULP_COM
 	bool "Support MX7ULP COM board"
 	select MX7ULP
 	select SYS_ARCH_TIMER
+	select SPL_DM if SPL
+	select SPL_GPIO_SUPPORT if SPL
+	select SPL_LIBCOMMON_SUPPORT if SPL
+	select SPL_LIBDISK_SUPPORT if SPL
+	select SPL_LIBGENERIC_SUPPORT if SPL
+	select SPL_MMC_SUPPORT if SPL
+	select SPL_OF_CONTROL if SPL
+	select SPL_OF_LIBFDT if SPL
+	select SPL_PINCTRL if SPL
+	select SPL_SEPARATE_BSS if SPL
+	select SPL_SERIAL_SUPPORT if SPL
+	select SUPPORT_SPL
 
 config TARGET_MX7ULP_EVK
 	bool "Support mx7ulp EVK board"
board/ea/mx7ulp_com/mx7ulp_com.c +26 -0
index 5b2d444366..fd9cc5b914 100644
@@ -48,3 +48,29 @@ int board_init(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_SPL_BUILD
+#include <spl.h>
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+	if (!strcmp(name, "imx7ulp-com"))
+		return 0;
+
+	return -1;
+}
+#endif
+
+void spl_board_init(void)
+{
+	preloader_console_init();
+}
+
+void board_init_f(ulong dummy)
+{
+	arch_cpu_init();
+
+	board_early_init_f();
+}
+#endif
include/configs/mx7ulp_com.h +6 -0
index 28672c4f94..ad1fdef1f9 100644
@@ -11,6 +11,10 @@
 #include <linux/sizes.h>
 #include <asm/arch/imx-regs.h>
 
+#ifdef CONFIG_SPL
+#include "imx7ulp_spl.h"
+#endif
+
 #define CONFIG_BOARD_POSTCLK_INIT
 #define CONFIG_SYS_BOOTM_LEN		0x1000000
 
@@ -84,5 +88,7 @@
 #define CONFIG_SYS_INIT_SP_ADDR \
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
+#define CONFIG_ARMV7_SECURE_BASE	0x2F000000
+
 #define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
 #endif	/* __CONFIG_H */
Signature · 1 line
2.31.1
reviewer
#4 lore raw

Re: [PATCH v2 3/3] mx7ulp_com: add support for SPL

Hi Oleksandr,

Quoted 12 lines · Oleksandr Suvorov

From: Ricardo Salveti <[email protected]>

Add EA iMX7ULP COM board support for building SPL.

---

Changes in v2:
- add a patch with SPL support for mx7ulp_com board.

Quoted 7 lines
 arch/arm/dts/imx7ulp-com-u-boot.dtsi | 37 ++++++++++++++++++++++++++++
 arch/arm/dts/imx7ulp-com.dts         |  1 +
 arch/arm/mach-imx/mx7ulp/Kconfig     | 12 +++++++++
 board/ea/mx7ulp_com/mx7ulp_com.c     | 26 +++++++++++++++++++
 include/configs/mx7ulp_com.h         |  6 +++++
 5 files changed, 82 insertions(+)
 create mode 100644 arch/arm/dts/imx7ulp-com-u-boot.dtsi

I don't see DRAM initialization in the newly added SPL code.

Am I missing something?

#5 lore raw

Re: [PATCH v2 3/3] mx7ulp_com: add support for SPL

Hi Fabio,

Quoted 25 lines · Fabio Estevam

Hi Oleksandr,

Quoted 12 lines · Oleksandr Suvorov

From: Ricardo Salveti <[email protected]>

Add EA iMX7ULP COM board support for building SPL.

---

Changes in v2:
- add a patch with SPL support for mx7ulp_com board.

Quoted 7 lines
 arch/arm/dts/imx7ulp-com-u-boot.dtsi | 37 ++++++++++++++++++++++++++++
 arch/arm/dts/imx7ulp-com.dts         |  1 +
 arch/arm/mach-imx/mx7ulp/Kconfig     | 12 +++++++++
 board/ea/mx7ulp_com/mx7ulp_com.c     | 26 +++++++++++++++++++
 include/configs/mx7ulp_com.h         |  6 +++++
 5 files changed, 82 insertions(+)
 create mode 100644 arch/arm/dts/imx7ulp-com-u-boot.dtsi
Quoted 3 lines

I don't see DRAM initialization in the newly added SPL code.

Am I missing something?

Maybe I misunderstood your question,
but it's already in board/ea/mx7ulp_com/mx7ulp_com.c, no?

int dram_init(void)

{
        gd->ram_size = imx_ddr_size();
#ifdef CONFIG_OPTEE_TZDRAM_SIZE
       gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;

#endif

        return 0;
}

which is in init_sequence_f (common/board_f.c), which is supposed to be called in spl when CONFIG_SPL=y.

Or what exactly do you mean?

Regards,
Igor

Signature · 7 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk
Embedded Software Engineer
T:  +380 938364067
E: [email protected]
W: www.foundries.io
reviewer
#6 lore raw

Re: [PATCH v2 3/3] mx7ulp_com: add support for SPL

Hi Igor,

Quoted 2 lines · Igor Opaniuk

Maybe I misunderstood your question,
but it's already in board/ea/mx7ulp_com/mx7ulp_com.c, no?

The DDR initialization is currently at board/ea/mx7ulp_com/imximage.cfg.

If the board supports SPL, I was expecting to see the DDR initialization happen in C code instead.

Regards,

Fabio Estevam

#7 lore raw

Re: [PATCH v2 3/3] mx7ulp_com: add support for SPL

Hi Fabio,

Quoted 5 lines · Fabio Estevam

Hi Igor,

On Wed, Sep 15, 2021 at 1:04 PM Igor Opaniuk <[email protected]> wrote:

Quoted 7 lines
Quoted 2 lines

Maybe I misunderstood your question,
but it's already in board/ea/mx7ulp_com/mx7ulp_com.c, no?

The DDR initialization is currently at board/ea/mx7ulp_com/imximage.cfg.

If the board supports SPL, I was expecting to see the DDR initialization happen in C code instead.

The SPL for this board is built with prepended DCD which includes DDR training data (defined in imximage.cfg). So that the bootrom initializes DDR using DCD before jumping to SPL.
Is it mandatory to move DDR init in C code for SPL-enabled setups? We wouldn't be changing it for now :(

Quoted 3 lines

Regards,

Fabio Estevam

--
Best regards
Oleksandr

Oleksandr Suvorov
[email protected]

reviewer
#8 lore raw

Re: [PATCH v2 3/3] mx7ulp_com: add support for SPL

Hi Oleksandr,

Quoted 5 lines · Oleksandr Suvorov

The SPL for this board is built with prepended DCD which includes DDR training data (defined in imximage.cfg). So that the bootrom initializes DDR using DCD before jumping to SPL.
Is it mandatory to move DDR init in C code for SPL-enabled setups? We wouldn't be changing it for now :(

If the SPL is currently not doing its minimum task of configuring DDR, why do we need SPL in the first place?

#9 lore raw

Re: [PATCH v2 3/3] mx7ulp_com: add support for SPL

Hi Fabio,

Quoted 5 lines · Fabio Estevam

Hi Oleksandr,

On Thu, Sep 16, 2021 at 3:50 PM Oleksandr Suvorov <[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

The SPL for this board is built with prepended DCD which includes DDR training data (defined in imximage.cfg). So that the bootrom initializes DDR using DCD before jumping to SPL.
Is it mandatory to move DDR init in C code for SPL-enabled setups? We wouldn't be changing it for now :(

If the SPL is currently not doing its minimum task of configuring DDR, why do we need SPL in the first place?

It's for a secure boot process, for running op-tee before u-boot. You could refer to the model we use
https://docs.foundries.io/latest/reference-manual/security/secure-boot-imx.html#our-implementation
In that model, u-boot runs in a normal world.
Separating SPL is only the beginning of changes, so I'm trying to go prepare changes to mainline step-by-step.

Signature · 7 lines
Best regards,

Oleksandr Suvorov
Software Engineer
T: +380 63 8489656
E: [email protected]
W: www.foundries.io
#10 lore raw

PATCH v2 3/3 mx7ulp_com: add support for SPL

In reply to Oleksandr Suvorov
Quoted 4 lines

From: Ricardo Salveti <[email protected]> Add EA iMX7ULP COM board support for building SPL.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
Reviewed-by on v2 1/3
#11 lore raw

Re: [PATCH v2 1/3] mx7ulp: select soc features

In reply to Oleksandr Suvorov

Hi Oleksandr,

Quoted 26 lines · Oleksandr Suvorov

Force selecting features present in SoC i.MX7ULP.

---

(no changes since v1)

 arch/arm/mach-imx/mx7ulp/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-imx/mx7ulp/Kconfig +3 -1
index 2ffac9cf7c..56a3efd7b9 100644
@@ -9,6 +9,9 @@ config LDO_ENABLED_MODE
          Select this option to enable the PMC1 LDO.
 
 config MX7ULP
+       select ARCH_SUPPORT_PSCI
+       select CPU_V7_HAS_NONSEC
+       select CPU_V7_HAS_VIRT
        select HAS_CAAM
        bool
 
--
Quoted 2 lines

2.31.1

Signature · 7 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk
Embedded Software Engineer
T:  +380 938364067
E: [email protected]
W: www.foundries.io
#12 lore raw

PATCH v2 1/3 mx7ulp: select soc features

In reply to Oleksandr Suvorov
Quoted 3 lines

Force selecting features present in SoC i.MX7ULP.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================