Skip to contentSkip to conversation

imx: imx8qm/qxp update

PATCH New Peng Fan 2 participants 21 messages May 5, 2020 – May 11, 2020

Subsystems (3)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

cover imx: imx8qm/qxp update

This patchset is various update for i.MX8 from NXP downstream

Support reserve ddr memory for M4
Add get board serial
power down resources when SPL jump to u-boot
recover SPL data
check m4 partition boot
Fix get_effective_memsize
select boot device dynamically

Peng Fan (8):
imx: imx8qm/qxp: reserving DDR memory for M4
imx: imx8qm/qxp: add get_board_serial
imx: imx8qm/imx8qxp: Power down the resources before SPL jump to
u-boot
imx: imx8qm/qxp: Recover SPL data section for partition reboot
imx: imx8qm/qxp: check whether m4 partition booted
imx: imx8qm: update fdt_file according to m4 state
imx: imx8qxp: update fdt_file according to m4 state
imx8: cpu: check resource owned after sid fail

Ye Li (2):
imx: imx8qm/qxp: Fix issue in get_effective_memsize
imx8: Select boot device dynamically

 arch/arm/cpu/armv8/Kconfig                      |  6 ++
 arch/arm/cpu/armv8/Makefile                     |  4 ++
 arch/arm/cpu/armv8/spl_data.c                   | 29 +++++++++
 arch/arm/cpu/armv8/u-boot-spl.lds               |  8 +++
 arch/arm/include/asm/arch-imx8/sys_proto.h      |  2 +
 arch/arm/mach-imx/imx8/Kconfig                  | 10 +++
 arch/arm/mach-imx/imx8/cpu.c                    | 85 ++++++++++++++++++++++++-
 arch/arm/mach-imx/imx8/fdt.c                    | 18 ++++--
 board/freescale/imx8qm_mek/imx8qm_mek.c         | 13 ++++
 board/freescale/imx8qm_mek/spl.c                |  6 ++
 board/freescale/imx8qxp_mek/imx8qxp_mek.c       | 13 ++++
 board/freescale/imx8qxp_mek/spl.c               |  6 ++
 drivers/power/domain/imx8-power-domain-legacy.c | 35 ++++++++++
 include/configs/imx8qm_mek.h                    |  2 +-
 include/configs/imx8qxp_mek.h                   |  2 +-
 include/spl.h                                   |  1 +
 16 files changed, 231 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/spl_data.c
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 1/10 imx: imx8qm/qxp: reserving DDR memory for M4

The DDR memory from 0x88000000 to 0x8FFFFFFF is assigned to M4 on QM and QXP. The M4 can allocate this memory by two ways, in SCD or u-boot.

In this patch, u-boot addes the memory reserve node to DTB to pass the info to kernel, no matter the M4 memory is reserved in SCD or u-boot. So kernel won't access M4 reserved memory.

---
 arch/arm/mach-imx/imx8/Kconfig |  8 ++++++++
 arch/arm/mach-imx/imx8/fdt.c   | 10 ++++++++++
 2 files changed, 18 insertions(+)
arch/arm/mach-imx/imx8/Kconfig +8 -0
index 1f8add015f..69149d3cd5 100644
@@ -41,6 +41,14 @@ config IMX_CONTAINER_CFG
 	  This is to specific the cfg file for generating container
 	  image which will be loaded by SPL.
 
+config BOOTAUX_RESERVED_MEM_BASE
+	hex "i.MX auxiliary core dram memory base"
+	default 0
+
+config BOOTAUX_RESERVED_MEM_SIZE
+	hex "i.MX auxiliary core dram memory size"
+	default 0
+
 choice
 	prompt "i.MX8 board select"
 	optional
arch/arm/mach-imx/imx8/fdt.c +10 -0
index 65c8ac1a7e..5993645378 100644
@@ -8,6 +8,7 @@
 #include <asm/arch/sys_proto.h>
 #include <dm/ofnode.h>
 #include <fdt_support.h>
+#include <linux/libfdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -279,6 +280,15 @@ static int ft_add_optee_node(void *fdt, bd_t *bd)
 int ft_system_setup(void *blob, bd_t *bd)
 {
 	int ret;
+	int off;
+
+	if (CONFIG_BOOTAUX_RESERVED_MEM_BASE) {
+		off = fdt_add_mem_rsv(blob, CONFIG_BOOTAUX_RESERVED_MEM_BASE,
+				      CONFIG_BOOTAUX_RESERVED_MEM_SIZE);
+		if (off < 0)
+			printf("Failed	to reserve memory for bootaux: %s\n",
+			       fdt_strerror(off));
+	}
 
 	update_fdt_with_owned_resources(blob);
 
Signature · 1 line
2.16.4
#2 lore raw

PATCH 1/10 imx: imx8qm/qxp: reserving DDR memory for M4

Quoted 7 lines

The DDR memory from 0x88000000 to 0x8FFFFFFF is assigned to M4 on QM and QXP. The M4 can allocate this memory by two ways, in SCD or u-boot.
In this patch, u-boot addes the memory reserve node to DTB to pass the info to kernel, no matter the M4 memory is reserved in SCD or u-boot. So kernel won't access M4 reserved memory.

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: sbabic at denx.de
=====================================================================
author
#3 lore raw

PATCH 2/10 imx: imx8qm/qxp: Fix issue in get_effective_memsize

In reply to Peng Fan

From: Ye Li <[email protected]>

When Trusty OS allocates the mem region from 0xfe0000000-0xffffffff, the get_effective_memsize does not return correct memory size. There is a check in get_effective_memsize to find the memreg where the u-boot is running, and return the size of that memreg as the result of get_effective_memsize. When using aligned start, the value is 0x80200000 since it is 2MB aligned. Thus the finding of memreg will fail and return the PHYS_SDRAM_1_SIZE because u-boot text base is 0x80020000. This cause u-boot is relocated to the high memory where has been occupied by Trusty OS.

---
 arch/arm/mach-imx/imx8/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-imx/imx8/cpu.c +3 -3
index f87276e8ea..2c79bd0091 100644
@@ -223,7 +223,7 @@ static int get_owned_memreg(sc_rm_mr_t mr, sc_faddr_t *addr_start,
 phys_size_t get_effective_memsize(void)
 {
 	sc_rm_mr_t mr;
-	sc_faddr_t start, end, end1;
+	sc_faddr_t start, end, end1, start_aligned;
 	int err;
 
 	end1 = (sc_faddr_t)PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE;
@@ -231,9 +231,9 @@ phys_size_t get_effective_memsize(void)
 	for (mr = 0; mr < 64; mr++) {
 		err = get_owned_memreg(mr, &start, &end);
 		if (!err) {
-			start = roundup(start, MEMSTART_ALIGNMENT);
+			start_aligned = roundup(start, MEMSTART_ALIGNMENT);
 			/* Too small memory region, not use it */
-			if (start > end)
+			if (start_aligned > end)
 				continue;
 
 			/* Find the memory region runs the U-Boot */
Signature · 1 line
2.16.4
#4 lore raw

PATCH 2/10 imx: imx8qm/qxp: Fix issue in get_effective_memsize

Quoted 10 lines

From: Ye Li <[email protected]>
When Trusty OS allocates the mem region from 0xfe0000000-0xffffffff, the get_effective_memsize does not return correct memory size. There is a check in get_effective_memsize to find the memreg where the u-boot is running, and return the size of that memreg as the result of get_effective_memsize. When using aligned start, the value is 0x80200000 since it is 2MB aligned. Thus the finding of memreg will fail and return the PHYS_SDRAM_1_SIZE because u-boot text base is 0x80020000. This cause u-boot is relocated to the high memory where has been occupied by Trusty OS.

Quoted 3 lines

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: sbabic at denx.de
=====================================================================
author
#5 lore raw

PATCH 3/10 imx: imx8qm/qxp: add get_board_serial

In reply to Peng Fan

Add get_board_serial support, the info could be got from fuse.

---
 arch/arm/mach-imx/imx8/cpu.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/mach-imx/imx8/cpu.c +32 -0
index 2c79bd0091..3bd0dee025 100644
@@ -19,6 +19,7 @@
 #include <asm/arch-imx/cpu.h>
 #include <asm/armv8/cpu.h>
 #include <asm/armv8/mmu.h>
+#include <asm/setup.h>
 #include <asm/mach-imx/boot_mode.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -162,6 +163,37 @@ enum boot_device get_boot_device(void)
 	return boot_dev;
 }
 
+#ifdef CONFIG_SERIAL_TAG
+#define FUSE_UNIQUE_ID_WORD0 16
+#define FUSE_UNIQUE_ID_WORD1 17
+void get_board_serial(struct tag_serialnr *serialnr)
+{
+	sc_err_t err;
+	u32 val1 = 0, val2 = 0;
+	u32 word1, word2;
+
+	if (!serialnr)
+		return;
+
+	word1 = FUSE_UNIQUE_ID_WORD0;
+	word2 = FUSE_UNIQUE_ID_WORD1;
+
+	err = sc_misc_otp_fuse_read(-1, word1, &val1);
+	if (err != SC_ERR_NONE) {
+		printf("%s fuse %d read error: %d\n", __func__, word1, err);
+		return;
+	}
+
+	err = sc_misc_otp_fuse_read(-1, word2, &val2);
+	if (err != SC_ERR_NONE) {
+		printf("%s fuse %d read error: %d\n", __func__, word2, err);
+		return;
+	}
+	serialnr->low = val1;
+	serialnr->high = val2;
+}
+#endif /*CONFIG_SERIAL_TAG*/
+
 #ifdef CONFIG_ENV_IS_IN_MMC
 __weak int board_mmc_get_env_dev(int devno)
 {
Signature · 1 line
2.16.4
#6 lore raw

PATCH 3/10 imx: imx8qm/qxp: add get_board_serial

Quoted 2 lines

Add get_board_serial support, the info could be got from fuse.

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: sbabic at denx.de
=====================================================================
author
#7 lore raw

PATCH 4/10 imx: imx8qm/imx8qxp: Power down the resources before SPL jump to u-boot

In reply to Peng Fan

Make sure that all devices that are powered up by SPL are powered down before entering into the u-boot. Otherwise the subsystem/device will never be powered down by SCFW, due to SPL and u-boot are in different partitions.

Benefiting from power domain driver, this patch implements the function "imx8_power_off_pd_devices" to power off all active devices.

---
 arch/arm/include/asm/arch-imx8/sys_proto.h      |  1 +
 board/freescale/imx8qm_mek/spl.c                |  6 +++++
 board/freescale/imx8qxp_mek/spl.c               |  6 +++++
 drivers/power/domain/imx8-power-domain-legacy.c | 35 +++++++++++++++++++++++++
 4 files changed, 48 insertions(+)
arch/arm/include/asm/arch-imx8/sys_proto.h +1 -0
index fc33e6ed18..2a08ef939d 100644
@@ -28,3 +28,4 @@ int print_bootinfo(void);
 int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate);
 int imx8_power_domain_lookup_name(const char *name,
 				  struct power_domain *power_domain);
+void imx8_power_off_pd_devices(const char *permanent_on_devices[], int size);
board/freescale/imx8qm_mek/spl.c +6 -0
index cb4006eb2a..ba99002cf2 100644
@@ -12,6 +12,7 @@
 #include <dm/uclass-internal.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -37,6 +38,11 @@ void spl_board_init(void)
 	puts("Normal Boot\n");
 }
 
+void spl_board_prepare_for_boot(void)
+{
+	imx8_power_off_pd_devices(NULL, 0);
+}
+
 #ifdef CONFIG_SPL_LOAD_FIT
 int board_fit_config_name_match(const char *name)
 {
board/freescale/imx8qxp_mek/spl.c +6 -0
index e4e4cbe716..32b61095b0 100644
@@ -17,6 +17,7 @@
 #include <asm/arch/sci/sci.h>
 #include <asm/arch/imx8-pins.h>
 #include <asm/arch/iomux.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -55,6 +56,11 @@ void spl_board_init(void)
 	puts("Normal Boot\n");
 }
 
+void spl_board_prepare_for_boot(void)
+{
+	imx_power_off_pd_devices(NULL, 0);
+}
+
 #ifdef CONFIG_SPL_LOAD_FIT
 int board_fit_config_name_match(const char *name)
 {
drivers/power/domain/imx8-power-domain-legacy.c +35 -0
index f679df9e5d..7ba4056e2d 100644
@@ -11,6 +11,7 @@
 #include <asm/arch/power-domain.h>
 #include <dm/device-internal.h>
 #include <dm/device.h>
+#include <dm/uclass-internal.h>
 #include <asm/arch/sci/sci.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -19,6 +20,40 @@ struct imx8_power_domain_priv {
 	bool state_on;
 };
 
+static bool check_device_power_off(struct udevice *dev,
+				   const char *permanent_on_devices[],
+				   int size)
+{
+	int i;
+
+	for (i = 0; i < size; i++) {
+		if (!strcmp(dev->name, permanent_on_devices[i]))
+			return false;
+	}
+
+	return true;
+}
+
+void imx8_power_off_pd_devices(const char *permanent_on_devices[], int size)
+{
+	struct udevice *dev;
+	struct power_domain pd;
+
+	for (uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev); dev;
+	     uclass_find_next_device(&dev)) {
+		if (!device_active(dev))
+			continue;
+		/*
+		 * Power off active pd devices except the permanent
+		 * power on devices
+		 */
+		if (check_device_power_off(dev, permanent_on_devices, size)) {
+			pd.dev = dev;
+			power_domain_off(&pd);
+		}
+	}
+}
+
 int imx8_power_domain_lookup_name(const char *name,
 				  struct power_domain *power_domain)
 {
Signature · 1 line
2.16.4
#8 lore raw

PATCH 4/10 imx: imx8qm/imx8qxp: Power down the resources before SPL jump to u-boot

Quoted 7 lines

Make sure that all devices that are powered up by SPL are powered down before entering into the u-boot. Otherwise the subsystem/device will never be powered down by SCFW, due to SPL and u-boot are in different partitions.
Benefiting from power domain driver, this patch implements the function "imx8_power_off_pd_devices" to power off all active devices.

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: sbabic at denx.de
=====================================================================
author
#9 lore raw

PATCH 5/10 imx: imx8qm/qxp: Recover SPL data section for partition reboot

In reply to Peng Fan

When doing partition reboot, the boot image won't be reloaded by ROM, it is just CPU reset to boot entry. The SW has to keep the boot image inside the RAM unchanged. It includes both the TEXT section and DATA section.

For SPL, the problem is DATA section will be updated at runtime, so in next partition reboot the data is not same as the initial value from cold boot. If any code depends on the initial value, then it will have problem.

This patch introduces a mechanism to recover the data section for partition reboot. It adds a new section in image for saving data section. When from cold boot, the data section will be saved to that new section at SPL early phase. When from partition reboot, the data section will be restored from the new section.

---
 arch/arm/cpu/armv8/Kconfig        |  6 ++++++
 arch/arm/cpu/armv8/Makefile       |  4 ++++
 arch/arm/cpu/armv8/spl_data.c     | 29 +++++++++++++++++++++++++++++
 arch/arm/cpu/armv8/u-boot-spl.lds |  8 ++++++++
 arch/arm/mach-imx/imx8/Kconfig    |  2 ++
 arch/arm/mach-imx/imx8/cpu.c      |  5 +++++
 include/spl.h                     |  1 +
 7 files changed, 55 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/spl_data.c
arch/arm/cpu/armv8/Kconfig +6 -0
index 16c83e8614..3655990772 100644
@@ -76,6 +76,12 @@ config SPL_ARMV8_SEC_FIRMWARE_SUPPORT
 	help
 	  Say Y here to support this framework in SPL phase.
 
+config SPL_RECOVER_DATA_SECTION
+	bool "save/restore SPL data section"
+	help
+	  Say Y here to save SPL data section for cold boot, and restore
+	  at warm boot in SPL phase.
+
 config SEC_FIRMWARE_ARMV8_PSCI
 	bool "PSCI implementation in secure monitor firmware"
 	depends on ARMV8_SEC_FIRMWARE_SUPPORT || SPL_ARMV8_SEC_FIRMWARE_SUPPORT
arch/arm/cpu/armv8/Makefile +4 -0
index b349b13f49..2e48df0eb9 100644
@@ -30,6 +30,10 @@ obj-$(CONFIG_ARMV8_SPIN_TABLE) += spin_table.o spin_table_v8.o
 endif
 obj-$(CONFIG_$(SPL_)ARMV8_SEC_FIRMWARE_SUPPORT) += sec_firmware.o sec_firmware_asm.o
 
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_RECOVER_DATA_SECTION) += spl_data.o
+endif
+
 obj-$(CONFIG_FSL_LAYERSCAPE) += fsl-layerscape/
 obj-$(CONFIG_S32V234) += s32v234/
 obj-$(CONFIG_TARGET_HIKEY) += hisilicon/
arch/arm/cpu/armv8/spl_data.c new file +29 -0
new file mode 100644
index 0000000000..8fd986a67a
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 NXP
+ */
+
+#include <common.h>
+#include <spl.h>
+
+char __data_save_start[0] __section(.__data_save_start);
+char __data_save_end[0] __section(.__data_save_end);
+
+u32 cold_reboot_flag = 1;
+
+void spl_save_restore_data(void)
+{
+	u32 data_size = __data_save_end - __data_save_start;
+
+	if (cold_reboot_flag == 1) {
+		/* Save data section to data_save section */
+		memcpy(__data_save_start, __data_save_start - data_size,
+		       data_size);
+	} else {
+		/* Restore the data_save section to data section */
+		memcpy(__data_save_start - data_size, __data_save_start,
+		       data_size);
+	}
+
+	cold_reboot_flag++;
+}
arch/arm/cpu/armv8/u-boot-spl.lds +8 -0
index ccbf359bd1..0e67ab09d7 100644
@@ -38,6 +38,14 @@ SECTIONS
 		*(.data*)
 	} >.sram
 
+#ifdef CONFIG_SPL_RECOVER_DATA_SECTION
+	.data_save : {
+		*(.__data_save_start)
+		. = SIZEOF(.data);
+		*(.__data_save_end)
+	} >.sram
+#endif
+
 	.u_boot_list : {
 		. = ALIGN(8);
 		KEEP(*(SORT(.u_boot_list*)));
arch/arm/mach-imx/imx8/Kconfig +2 -0
index 69149d3cd5..9d1f73dfc7 100644
@@ -18,11 +18,13 @@ config MU_BASE_SPL
 config IMX8QM
 	select IMX8
 	select SUPPORT_SPL
+	select SPL_RECOVER_DATA_SECTION
 	bool
 
 config IMX8QXP
 	select IMX8
 	select SUPPORT_SPL
+	select SPL_RECOVER_DATA_SECTION
 	bool
 
 config SYS_SOC
arch/arm/mach-imx/imx8/cpu.c +5 -0
index 3bd0dee025..e03193cb4c 100644
@@ -13,6 +13,7 @@
 #include <dm/lists.h>
 #include <dm/uclass.h>
 #include <errno.h>
+#include <spl.h>
 #include <thermal.h>
 #include <asm/arch/sci/sci.h>
 #include <asm/arch/sys_proto.h>
@@ -39,6 +40,10 @@ struct pass_over_info_t *get_pass_over_info(void)
 
 int arch_cpu_init(void)
 {
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RECOVER_DATA_SECTION)
+	spl_save_restore_data();
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 	struct pass_over_info_t *pass_over;
 
include/spl.h +1 -0
index 6bf9fd8beb..90395fedb0 100644
@@ -582,4 +582,5 @@ void spl_perform_fixups(struct spl_image_info *spl_image);
  */
 struct image_header *spl_get_load_buffer(ssize_t offset, size_t size);
 
+void spl_save_restore_data(void);
 #endif
Signature · 1 line
2.16.4
#10 lore raw

PATCH 5/10 imx: imx8qm/qxp: Recover SPL data section for partition reboot

Quoted 13 lines

When doing partition reboot, the boot image won't be reloaded by ROM, it is just CPU reset to boot entry. The SW has to keep the boot image inside the RAM unchanged. It includes both the TEXT section and DATA section.
For SPL, the problem is DATA section will be updated at runtime, so in next partition reboot the data is not same as the initial value from cold boot. If any code depends on the initial value, then it will have problem.
This patch introduces a mechanism to recover the data section for partition reboot. It adds a new section in image for saving data section. When from cold boot, the data section will be saved to that new section at SPL early phase. When from partition reboot, the data section will be restored from the new section.

Quoted 2 lines

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: sbabic at denx.de
=====================================================================
author
#11 lore raw

PATCH 6/10 imx8: Select boot device dynamically

In reply to Peng Fan

From: Ye Li <[email protected]>

For fspi build, we will enable both SPL NOR support and SPL SPI support. SPL will dynamically check the resource owner then select corresponding boot device.

---
 arch/arm/mach-imx/imx8/cpu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-imx/imx8/cpu.c +12 -0
index e03193cb4c..103a29746a 100644
@@ -22,6 +22,7 @@
 #include <asm/armv8/mmu.h>
 #include <asm/setup.h>
 #include <asm/mach-imx/boot_mode.h>
+#include <spl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -573,3 +574,14 @@ u32 get_cpu_rev(void)
 
 	return (id << 12) | rev;
 }
+
+void board_boot_order(u32 *spl_boot_list)
+{
+	spl_boot_list[0] = spl_boot_device();
+
+	if (spl_boot_list[0] == BOOT_DEVICE_SPI) {
+		/* Check whether we own the flexspi0, if not, use NOR boot */
+		if (!sc_rm_is_resource_owned(-1, SC_R_FSPI_0))
+			spl_boot_list[0] = BOOT_DEVICE_NOR;
+	}
+}
Signature · 1 line
2.16.4
#12 lore raw

PATCH 6/10 imx8: Select boot device dynamically

Quoted 6 lines

From: Ye Li <[email protected]>
For fspi build, we will enable both SPL NOR support and SPL SPI support. SPL will dynamically check the resource owner then select corresponding boot device.

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: sbabic at denx.de
=====================================================================
author
#13 lore raw

PATCH 7/10 imx: imx8qm/qxp: check whether m4 partition booted

In reply to Peng Fan

Add code to check m4 partition booted or not, we will use this to runtime set device tree file that passed to Linux Kernel.

---
 arch/arm/include/asm/arch-imx8/sys_proto.h |  1 +
 arch/arm/mach-imx/imx8/cpu.c               | 30 ++++++++++++++++++++++++++++++
 board/freescale/imx8qxp_mek/spl.c          |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-imx8/sys_proto.h +1 -0
index 2a08ef939d..6f1fc8f999 100644
@@ -29,3 +29,4 @@ int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate);
 int imx8_power_domain_lookup_name(const char *name,
 				  struct power_domain *power_domain);
 void imx8_power_off_pd_devices(const char *permanent_on_devices[], int size);
+bool m4_parts_booted(void);
arch/arm/mach-imx/imx8/cpu.c +30 -0
index 103a29746a..6d7b17b464 100644
@@ -585,3 +585,33 @@ void board_boot_order(u32 *spl_boot_list)
 			spl_boot_list[0] = BOOT_DEVICE_NOR;
 	}
 }
+
+bool m4_parts_booted(void)
+{
+	sc_rm_pt_t m4_parts[2];
+	int err;
+
+	err = sc_rm_get_resource_owner(-1, SC_R_M4_0_PID0, &m4_parts[0]);
+	if (err) {
+		printf("%s get resource [%d] owner error: %d\n", __func__,
+		       SC_R_M4_0_PID0, err);
+		return false;
+	}
+
+	if (sc_pm_is_partition_started(-1, m4_parts[0]))
+		return true;
+
+	if (is_imx8qm()) {
+		err = sc_rm_get_resource_owner(-1, SC_R_M4_1_PID0, &m4_parts[1]);
+		if (err) {
+			printf("%s get resource [%d] owner error: %d\n",
+			       __func__, SC_R_M4_1_PID0, err);
+			return false;
+		}
+
+		if (sc_pm_is_partition_started(-1, m4_parts[1]))
+			return true;
+	}
+
+	return false;
+}
board/freescale/imx8qxp_mek/spl.c +1 -1
index 32b61095b0..eefee64ab1 100644
@@ -58,7 +58,7 @@ void spl_board_init(void)
 
 void spl_board_prepare_for_boot(void)
 {
-	imx_power_off_pd_devices(NULL, 0);
+	imx8_power_off_pd_devices(NULL, 0);
 }
 
 #ifdef CONFIG_SPL_LOAD_FIT
Signature · 1 line
2.16.4
#14 lore raw

PATCH 7/10 imx: imx8qm/qxp: check whether m4 partition booted

Quoted 3 lines

Add code to check m4 partition booted or not, we will use this to runtime set device tree file that passed to Linux Kernel.

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: sbabic at denx.de
=====================================================================
author
#15 lore raw

PATCH 8/10 imx: imx8qm: update fdt_file according to m4 state

In reply to Peng Fan

Update fdt_file according to m4 parts state

---
 board/freescale/imx8qm_mek/imx8qm_mek.c | 13 +++++++++++++
 include/configs/imx8qm_mek.h            |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
board/freescale/imx8qm_mek/imx8qm_mek.c +13 -0
index c9b9b2547e..c0cae3540f 100644
@@ -123,10 +123,23 @@ int board_mmc_get_env_dev(int devno)
 
 int board_late_init(void)
 {
+	char *fdt_file;
+	bool m4_booted;
+
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	env_set("board_name", "MEK");
 	env_set("board_rev", "iMX8QM");
 #endif
 
+	fdt_file = env_get("fdt_file");
+	m4_booted = m4_parts_booted();
+
+	if (fdt_file && !strcmp(fdt_file, "undefined")) {
+		if (m4_booted)
+			env_set("fdt_file", "imx8qm-mek-rpmsg.dtb");
+		else
+			env_set("fdt_file", "imx8qm-mek.dtb");
+	}
+
 	return 0;
 }
include/configs/imx8qm_mek.h +1 -1
index 97170dc949..22d80f1747 100644
@@ -70,7 +70,7 @@
 	"fdt_addr=0x83000000\0"			\
 	"fdt_high=0xffffffffffffffff\0"		\
 	"boot_fdt=try\0" \
-	"fdt_file=imx8qm-mek.dtb\0" \
+	"fdt_file=undefined\0" \
 	"initrd_addr=0x83800000\0"		\
 	"initrd_high=0xffffffffffffffff\0" \
 	"mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
Signature · 1 line
2.16.4
#16 lore raw

PATCH 8/10 imx: imx8qm: update fdt_file according to m4 state

Quoted 2 lines

Update fdt_file according to m4 parts state

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: sbabic at denx.de
=====================================================================
author
#17 lore raw

PATCH 9/10 imx: imx8qxp: update fdt_file according to m4 state

In reply to Peng Fan

Update fdt_file according to m4 parts state

---
 board/freescale/imx8qxp_mek/imx8qxp_mek.c | 13 +++++++++++++
 include/configs/imx8qxp_mek.h             |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
board/freescale/imx8qxp_mek/imx8qxp_mek.c +13 -0
index 93f0cd827c..dc9ffaabf2 100644
@@ -146,10 +146,23 @@ int board_mmc_get_env_dev(int devno)
 
 int board_late_init(void)
 {
+	char *fdt_file;
+	bool m4_booted;
+
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	env_set("board_name", "MEK");
 	env_set("board_rev", "iMX8QXP");
 #endif
 
+	fdt_file = env_get("fdt_file");
+	m4_booted = m4_parts_booted();
+
+	if (fdt_file && !strcmp(fdt_file, "undefined")) {
+		if (m4_booted)
+			env_set("fdt_file", "imx8qxp-mek-rpmsg.dtb");
+		else
+			env_set("fdt_file", "imx8qxp-mek.dtb");
+	}
+
 	return 0;
 }
include/configs/imx8qxp_mek.h +1 -1
index 0aaca3325b..341e93e61e 100644
@@ -69,7 +69,7 @@
 	"fdt_addr=0x83000000\0"			\
 	"fdt_high=0xffffffffffffffff\0"		\
 	"boot_fdt=try\0" \
-	"fdt_file=imx8qxp-mek.dtb\0" \
+	"fdt_file=undefined\0" \
 	"initrd_addr=0x83800000\0"		\
 	"initrd_high=0xffffffffffffffff\0" \
 	"mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
Signature · 1 line
2.16.4
#18 lore raw

PATCH 9/10 imx: imx8qxp: update fdt_file according to m4 state

Quoted 2 lines

Update fdt_file according to m4 parts state

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: sbabic at denx.de
=====================================================================
author
#19 lore raw

PATCH 10/10 imx8: cpu: check resource owned after sid fail

In reply to Peng Fan

When we create software partition, we still need let parent partition to configure sid, so move the check after sid failed.

---
 arch/arm/mach-imx/imx8/fdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx8/fdt.c +4 -4
index 5993645378..9a6822a929 100644
@@ -106,13 +106,13 @@ static int config_smmu_resource_sid(int rsrc, int sid)
 {
 	int err;
 
-	if (!check_owned_resource(rsrc)) {
-		printf("%s rsrc[%d] not owned\n", __func__, rsrc);
-		return -1;
-	}
 	err = sc_rm_set_master_sid(-1, rsrc, sid);
 	debug("set_master_sid rsrc=%d sid=0x%x err=%d\n", rsrc, sid, err);
 	if (err != SC_ERR_NONE) {
+		if (!check_owned_resource(rsrc)) {
+			printf("%s rsrc[%d] not owned\n", __func__, rsrc);
+			return -1;
+		}
 		pr_err("fail set_master_sid rsrc=%d sid=0x%x err=%d\n", rsrc, sid, err);
 		return -EINVAL;
 	}
Signature · 1 line
2.16.4
#20 lore raw

PATCH 10/10 imx8: cpu: check resource owned after sid fail

Quoted 4 lines

When we create software partition, we still need let parent partition to configure sid, so move the check after sid failed.

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: sbabic at denx.de
=====================================================================