Skip to contentSkip to conversation

ARM: imx: Add bmode support for iMX7

PATCH New Marek Vasut 2 participants 15 messages Aug 5, 2020 – Aug 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ARM: imx: Add bmode support for iMX7

Add the basic differentiation between i.MX6 and i.MX7 into the bmode command, the mechanism really works almost the same on both platforms.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/include/asm/mach-imx/sys_proto.h |  6 +++++-
 arch/arm/mach-imx/Kconfig                 |  2 +-
 arch/arm/mach-imx/init.c                  | 12 +++++++++---
 arch/arm/mach-imx/mx7/soc.c               |  8 ++++++++
 4 files changed, 23 insertions(+), 5 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +5 -1
index ab94024c9b..2d18b1f56b 100644
@@ -78,7 +78,7 @@ struct bd_info;
 #define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
 
 #ifdef CONFIG_MX6
-#define IMX6_SRC_GPR10_BMODE		BIT(28)
+#define IMX6_SRC_GPR10_BMODE			BIT(28)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4
@@ -126,6 +126,10 @@ void gpr_init(void);
 
 #endif /* CONFIG_MX6 */
 
+#ifdef CONFIG_MX7
+#define IMX7_SRC_GPR10_BMODE			BIT(28)
+#endif
+
 /* address translation table */
 struct rproc_att {
 	u32 da; /* device address (From Cortex M4 view) */
arch/arm/mach-imx/Kconfig +1 -1
index 1531d09f3b..8f64e23195 100644
@@ -62,7 +62,7 @@ config CSF_SIZE
 config CMD_BMODE
 	bool "Support the 'bmode' command"
 	default y
-	depends on ARCH_MX6 || ARCH_MX5
+	depends on ARCH_MX7 || ARCH_MX6 || ARCH_MX5
 	help
 	  This enables the 'bmode' (bootmode) command for forcing
 	  a boot from specific media.
arch/arm/mach-imx/init.c +9 -3
index 693b724429..e30d63b896 100644
@@ -103,14 +103,20 @@ void init_src(void)
 #ifdef CONFIG_CMD_BMODE
 void boot_mode_apply(unsigned cfg_val)
 {
-	unsigned reg;
+#ifdef CONFIG_MX6
+	const u32 bmode = IMX6_SRC_GPR10_BMODE;
+#elif CONFIG_MX7
+	const u32 bmode = IMX7_SRC_GPR10_BMODE;
+#endif
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
+	unsigned reg;
+
 	writel(cfg_val, &psrc->gpr9);
 	reg = readl(&psrc->gpr10);
 	if (cfg_val)
-		reg |= IMX6_SRC_GPR10_BMODE;
+		reg |= bmode;
 	else
-		reg &= ~IMX6_SRC_GPR10_BMODE;
+		reg &= ~bmode;
 	writel(reg, &psrc->gpr10);
 }
 #endif
arch/arm/mach-imx/mx7/soc.c +8 -0
index 8db672fb05..2698ae623e 100644
@@ -13,6 +13,7 @@
 #include <asm/mach-imx/hab.h>
 #include <asm/mach-imx/rdc-sema.h>
 #include <asm/arch/imx-rdc.h>
+#include <asm/mach-imx/boot_mode.h>
 #include <asm/arch/crm_regs.h>
 #include <dm.h>
 #include <env.h>
@@ -411,6 +412,13 @@ void s_init(void)
 	return;
 }
 
+#ifndef CONFIG_SPL_BUILD
+const struct boot_mode soc_boot_modes[] = {
+	{"normal",	MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
+	{NULL,		0},
+};
+#endif
+
 void reset_misc(void)
 {
 #ifndef CONFIG_SPL_BUILD
Signature · 1 line
2.27.0
#1 lore raw

PATCH 2/4 ARM: imx: Add support for switching primary/secondary boot mode to bmode

The i.MX6/i.MX7 is capable of booting a secondary "redundant" system image in case the primary one is corrupted. The user can force this boot mode as well by explicitly setting SRC GPR10 bit 30. This can be potentially useful when upgrading the bootloader itself. Expose this functionality to the user.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/include/asm/mach-imx/boot_mode.h |  2 ++
 arch/arm/include/asm/mach-imx/sys_proto.h |  2 ++
 arch/arm/mach-imx/init.c                  | 22 +++++++++++++++-------
 arch/arm/mach-imx/mx7/soc.c               |  2 ++
 4 files changed, 21 insertions(+), 7 deletions(-)
arch/arm/include/asm/mach-imx/boot_mode.h +2 -0
index 3a483b6afa..6dc5855968 100644
@@ -7,6 +7,8 @@
 #define _ASM_BOOT_MODE_H
 #define MAKE_CFGVAL(cfg1, cfg2, cfg3, cfg4) \
 	((cfg4) << 24) | ((cfg3) << 16) | ((cfg2) << 8) | (cfg1)
+#define MAKE_CFGVAL_PRIMARY_BOOT	0xfffffff0
+#define MAKE_CFGVAL_SECONDARY_BOOT	0xffffffff
 
 enum boot_device {
 	WEIM_NOR_BOOT,
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
index 2d18b1f56b..15d1cba8e7 100644
@@ -79,6 +79,7 @@ struct bd_info;
 
 #ifdef CONFIG_MX6
 #define IMX6_SRC_GPR10_BMODE			BIT(28)
+#define IMX6_SRC_GPR10_PERSIST_SECONDARY_BOOT	BIT(30)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4
@@ -128,6 +129,7 @@ void gpr_init(void);
 
 #ifdef CONFIG_MX7
 #define IMX7_SRC_GPR10_BMODE			BIT(28)
+#define IMX7_SRC_GPR10_PERSIST_SECONDARY_BOOT	BIT(30)
 #endif
 
 /* address translation table */
arch/arm/mach-imx/init.c +15 -7
index e30d63b896..ce3eb4b0b8 100644
@@ -104,20 +104,28 @@ void init_src(void)
 void boot_mode_apply(unsigned cfg_val)
 {
 #ifdef CONFIG_MX6
+	const u32 persist_sec = IMX6_SRC_GPR10_PERSIST_SECONDARY_BOOT;
 	const u32 bmode = IMX6_SRC_GPR10_BMODE;
 #elif CONFIG_MX7
+	const u32 persist_sec = IMX7_SRC_GPR10_PERSIST_SECONDARY_BOOT;
 	const u32 bmode = IMX7_SRC_GPR10_BMODE;
 #endif
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
 	unsigned reg;
 
-	writel(cfg_val, &psrc->gpr9);
-	reg = readl(&psrc->gpr10);
-	if (cfg_val)
-		reg |= bmode;
-	else
-		reg &= ~bmode;
-	writel(reg, &psrc->gpr10);
+	if (cfg_val == MAKE_CFGVAL_PRIMARY_BOOT)
+		clrbits_le32(&psrc->gpr10, persist_sec);
+	else if (cfg_val == MAKE_CFGVAL_SECONDARY_BOOT)
+		setbits_le32(&psrc->gpr10, persist_sec);
+	else {
+		writel(cfg_val, &psrc->gpr9);
+		reg = readl(&psrc->gpr10);
+		if (cfg_val)
+			reg |= bmode;
+		else
+			reg &= ~bmode;
+		writel(reg, &psrc->gpr10);
+	}
 }
 #endif
 
arch/arm/mach-imx/mx7/soc.c +2 -0
index 2698ae623e..b6fd25a991 100644
@@ -415,6 +415,8 @@ void s_init(void)
 #ifndef CONFIG_SPL_BUILD
 const struct boot_mode soc_boot_modes[] = {
 	{"normal",	MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
+	{"primary",	MAKE_CFGVAL_PRIMARY_BOOT},
+	{"secondary",	MAKE_CFGVAL_SECONDARY_BOOT},
 	{NULL,		0},
 };
 #endif
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/4 ARM: imx: Add support for switching primary/secondary boot mode to bmode

Quoted 97 lines · Marek Vasut

The i.MX6/i.MX7 is capable of booting a secondary "redundant" system image in case the primary one is corrupted. The user can force this boot mode as well by explicitly setting SRC GPR10 bit 30. This can be potentially useful when upgrading the bootloader itself. Expose this functionality to the user.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/include/asm/mach-imx/boot_mode.h |  2 ++
 arch/arm/include/asm/mach-imx/sys_proto.h |  2 ++
 arch/arm/mach-imx/init.c                  | 22 +++++++++++++++-------
 arch/arm/mach-imx/mx7/soc.c               |  2 ++
 4 files changed, 21 insertions(+), 7 deletions(-)
arch/arm/include/asm/mach-imx/boot_mode.h +2 -0
index 3a483b6afa..6dc5855968 100644
@@ -7,6 +7,8 @@
 #define _ASM_BOOT_MODE_H
 #define MAKE_CFGVAL(cfg1, cfg2, cfg3, cfg4) \
 	((cfg4) << 24) | ((cfg3) << 16) | ((cfg2) << 8) | (cfg1)
+#define MAKE_CFGVAL_PRIMARY_BOOT	0xfffffff0
+#define MAKE_CFGVAL_SECONDARY_BOOT	0xffffffff
 
 enum boot_device {
 	WEIM_NOR_BOOT,
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
index 2d18b1f56b..15d1cba8e7 100644
@@ -79,6 +79,7 @@ struct bd_info;
 
 #ifdef CONFIG_MX6
 #define IMX6_SRC_GPR10_BMODE			BIT(28)
+#define IMX6_SRC_GPR10_PERSIST_SECONDARY_BOOT	BIT(30)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4
@@ -128,6 +129,7 @@ void gpr_init(void);
 
 #ifdef CONFIG_MX7
 #define IMX7_SRC_GPR10_BMODE			BIT(28)
+#define IMX7_SRC_GPR10_PERSIST_SECONDARY_BOOT	BIT(30)
 #endif
 
 /* address translation table */
arch/arm/mach-imx/init.c +15 -7
index e30d63b896..ce3eb4b0b8 100644
@@ -104,20 +104,28 @@ void init_src(void)
 void boot_mode_apply(unsigned cfg_val)
 {
 #ifdef CONFIG_MX6
+	const u32 persist_sec = IMX6_SRC_GPR10_PERSIST_SECONDARY_BOOT;
 	const u32 bmode = IMX6_SRC_GPR10_BMODE;
 #elif CONFIG_MX7
+	const u32 persist_sec = IMX7_SRC_GPR10_PERSIST_SECONDARY_BOOT;
 	const u32 bmode = IMX7_SRC_GPR10_BMODE;
 #endif
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
 	unsigned reg;
 
-	writel(cfg_val, &psrc->gpr9);
-	reg = readl(&psrc->gpr10);
-	if (cfg_val)
-		reg |= bmode;
-	else
-		reg &= ~bmode;
-	writel(reg, &psrc->gpr10);
+	if (cfg_val == MAKE_CFGVAL_PRIMARY_BOOT)
+		clrbits_le32(&psrc->gpr10, persist_sec);
+	else if (cfg_val == MAKE_CFGVAL_SECONDARY_BOOT)
+		setbits_le32(&psrc->gpr10, persist_sec);
+	else {
+		writel(cfg_val, &psrc->gpr9);
+		reg = readl(&psrc->gpr10);
+		if (cfg_val)
+			reg |= bmode;
+		else
+			reg &= ~bmode;
+		writel(reg, &psrc->gpr10);
+	}
 }
 #endif
 
arch/arm/mach-imx/mx7/soc.c +0 -0
index 2698ae623e..b6fd25a991 100644

arch/arm/mach-imx/mx7/soc.c void s_init(void) · line 422

Quoted 8 lines
arch/arm/mach-imx/mx7/soc.c +2 -0
@@ -415,6 +415,8 @@ void s_init(void)
 #ifndef CONFIG_SPL_BUILD
 const struct boot_mode soc_boot_modes[] = {
 	{"normal",	MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
+	{"primary",	MAKE_CFGVAL_PRIMARY_BOOT},
+	{"secondary",	MAKE_CFGVAL_SECONDARY_BOOT},
 	{NULL,		0},
 };
 #endif

Regards,
Stefano

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
=====================================================================
#3 lore raw

PATCH 2/4 ARM: imx: Add support for switching primary/secondary boot mode to bmode

In reply to Marek Vasut
Quoted 11 lines

The i.MX6/i.MX7 is capable of booting a secondary "redundant" system image in case the primary one is corrupted. The user can force this boot mode as well by explicitly setting SRC GPR10 bit 30. This can be potentially useful when upgrading the bootloader itself. Expose this functionality to the user.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>

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
=====================================================================
#4 lore raw

PATCH 3/4 ARM: imx: Add support for reading out the primary/secondary bmode

In reply to Marek Vasut

Add new 'getprisec' subcommand to 'bmode' command, which sets the return value of the 'bmode' command to either 0 if the system booted from primary copy or to 1 if the system booted from secondary copy. This can be used e.g. in 'test' command to determine which copy of the system is running.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/mach-imx/cmd_bmode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-imx/cmd_bmode.c +12 -0
index 19bfd9f9a0..cb317499d5 100644
@@ -51,9 +51,19 @@ static int create_usage(char *dest)
 	if (dest)
 		memcpy(dest - 1, " [noreset]", 11);	/* include trailing 0 */
 	size += 10;
+
+	if (dest)
+		memcpy(dest - 1, "\nbmode - getprisec", 19);
+	size += 18;
+
 	return size;
 }
 
+__weak int boot_mode_getprisec(void)
+{
+	return 0;
+}
+
 static int do_boot_mode(struct cmd_tbl *cmdtp, int flag, int argc,
 			char *const argv[])
 {
@@ -62,6 +72,8 @@ static int do_boot_mode(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
+	if (!strcmp(argv[1], "getprisec"))
+		return boot_mode_getprisec();
 	p = search_modes(argv[1]);
 	if (!p)
 		return CMD_RET_USAGE;
Signature · 1 line
2.27.0
#5 lore raw

PATCH 3/4 ARM: imx: Add support for reading out the primary/secondary bmode

Quoted 40 lines · Marek Vasut

Add new 'getprisec' subcommand to 'bmode' command, which sets the return value of the 'bmode' command to either 0 if the system booted from primary copy or to 1 if the system booted from secondary copy. This can be used e.g. in 'test' command to determine which copy of the system is running.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/mach-imx/cmd_bmode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-imx/cmd_bmode.c +10 -0
index 19bfd9f9a0..cb317499d5 100644
@@ -51,9 +51,19 @@ static int create_usage(char *dest)
 	if (dest)
 		memcpy(dest - 1, " [noreset]", 11);	/* include trailing 0 */
 	size += 10;
+
+	if (dest)
+		memcpy(dest - 1, "\nbmode - getprisec", 19);
+	size += 18;
+
 	return size;
 }
 
+__weak int boot_mode_getprisec(void)
+{
+	return 0;
+}
+
 static int do_boot_mode(struct cmd_tbl *cmdtp, int flag, int argc,
 			char *const argv[])
 {

arch/arm/mach-imx/cmd_bmode.c static int do_boot_mode(struct cmd_tbl *cmdtp, int flag, int argc, · line 79

Quoted 8 lines
arch/arm/mach-imx/cmd_bmode.c +2 -0
@@ -62,6 +72,8 @@ static int do_boot_mode(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
+	if (!strcmp(argv[1], "getprisec"))
+		return boot_mode_getprisec();
 	p = search_modes(argv[1]);
 	if (!p)
 		return CMD_RET_USAGE;

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
=====================================================================
#6 lore raw

PATCH 3/4 ARM: imx: Add support for reading out the primary/secondary bmode

In reply to Marek Vasut
Quoted 10 lines

Add new 'getprisec' subcommand to 'bmode' command, which sets the return value of the 'bmode' command to either 0 if the system booted from primary copy or to 1 if the system booted from secondary copy. This can be used e.g. in 'test' command to determine which copy of the system is running.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>

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
=====================================================================
#7 lore raw

PATCH 4/4 ARM: imx: Add support for reading out the primary/secondary bmode to MX7

In reply to Marek Vasut

Implement the 'getprisec' subcommand of 'bmode' command for i.MX7 by reading out the SRC GPR10 bit 30. This bit is either set by the BootROM if it switched to the secondary copy due to primary copy being corrupted OR it can be overridden by the user.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/mach-imx/mx7/soc.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mach-imx/mx7/soc.c +7 -0
index b6fd25a991..c90f7354ea 100644
@@ -419,6 +419,13 @@ const struct boot_mode soc_boot_modes[] = {
 	{"secondary",	MAKE_CFGVAL_SECONDARY_BOOT},
 	{NULL,		0},
 };
+
+int boot_mode_getprisec(void)
+{
+	struct src *psrc = (struct src *)SRC_BASE_ADDR;
+
+	return !!(readl(&psrc->gpr10) & IMX7_SRC_GPR10_PERSIST_SECONDARY_BOOT);
+}
 #endif
 
 void reset_misc(void)
Signature · 1 line
2.27.0
#8 lore raw

PATCH 4/4 ARM: imx: Add support for reading out the primary/secondary bmode to MX7

Quoted 23 lines · Marek Vasut

Implement the 'getprisec' subcommand of 'bmode' command for i.MX7 by reading out the SRC GPR10 bit 30. This bit is either set by the BootROM if it switched to the secondary copy due to primary copy being corrupted OR it can be overridden by the user.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/mach-imx/mx7/soc.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mach-imx/mx7/soc.c +0 -0
index b6fd25a991..c90f7354ea 100644
@@ -419,6 +419,13 @@ const struct boot_mode soc_boot_modes[] = {
 	{"secondary",	MAKE_CFGVAL_SECONDARY_BOOT},
 	{NULL,		0},
 };

arch/arm/mach-imx/mx7/soc.c const struct boot_mode soc_boot_modes[] = { · line 431

Quoted 10 lines
arch/arm/mach-imx/mx7/soc.c +7 -0
+
+int boot_mode_getprisec(void)
+{
+	struct src *psrc = (struct src *)SRC_BASE_ADDR;
+
+	return !!(readl(&psrc->gpr10) & IMX7_SRC_GPR10_PERSIST_SECONDARY_BOOT);
+}
 #endif
 
 void reset_misc(void)

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
=====================================================================
#9 lore raw

PATCH 4/4 ARM: imx: Add support for reading out the primary/secondary bmode to MX7

In reply to Marek Vasut
Quoted 10 lines

Implement the 'getprisec' subcommand of 'bmode' command for i.MX7 by reading out the SRC GPR10 bit 30. This bit is either set by the BootROM if it switched to the secondary copy due to primary copy being corrupted OR it can be overridden by the user.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>

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
=====================================================================
#10 lore raw

PATCH 1/4 ARM: imx: Add bmode support for iMX7

In reply to Marek Vasut

Hi Marek,

Quoted 29 lines · Marek Vasut

Add the basic differentiation between i.MX6 and i.MX7 into the bmode command, the mechanism really works almost the same on both platforms.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/include/asm/mach-imx/sys_proto.h |  6 +++++-
 arch/arm/mach-imx/Kconfig                 |  2 +-
 arch/arm/mach-imx/init.c                  | 12 +++++++++---
 arch/arm/mach-imx/mx7/soc.c               |  8 ++++++++
 4 files changed, 23 insertions(+), 5 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index ab94024c9b..2d18b1f56b 100644
@@ -78,7 +78,7 @@ struct bd_info;
 #define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
 
 #ifdef CONFIG_MX6
-#define IMX6_SRC_GPR10_BMODE		BIT(28)
+#define IMX6_SRC_GPR10_BMODE			BIT(28)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4

arch/arm/include/asm/mach-imx/sys_proto.h void gpr_init(void); · line 132

Quoted 7 lines
arch/arm/include/asm/mach-imx/sys_proto.h +4 -0
@@ -126,6 +126,10 @@ void gpr_init(void);
 
 #endif /* CONFIG_MX6 */
 
+#ifdef CONFIG_MX7
+#define IMX7_SRC_GPR10_BMODE			BIT(28)
+#endif
+

It is questionable why we need two different defines, that also have exactly the same definition. Do we really need to differentiate and to use #ifdef ?

Quoted 21 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
 /* address translation table */
 struct rproc_att {
 	u32 da; /* device address (From Cortex M4 view) */
arch/arm/mach-imx/Kconfig +1 -1
index 1531d09f3b..8f64e23195 100644
@@ -62,7 +62,7 @@ config CSF_SIZE
 config CMD_BMODE
 	bool "Support the 'bmode' command"
 	default y
-	depends on ARCH_MX6 || ARCH_MX5
+	depends on ARCH_MX7 || ARCH_MX6 || ARCH_MX5
 	help
 	  This enables the 'bmode' (bootmode) command for forcing
 	  a boot from specific media.
arch/arm/mach-imx/init.c +0 -0
index 693b724429..e30d63b896 100644

arch/arm/mach-imx/init.c void init_src(void) · line 110

Quoted 9 lines
arch/arm/mach-imx/init.c +5 -1
@@ -103,14 +103,20 @@ void init_src(void)
 #ifdef CONFIG_CMD_BMODE
 void boot_mode_apply(unsigned cfg_val)
 {
-	unsigned reg;
+#ifdef CONFIG_MX6
+	const u32 bmode = IMX6_SRC_GPR10_BMODE;
+#elif CONFIG_MX7
+	const u32 bmode = IMX7_SRC_GPR10_BMODE;
+#endif

Ditto.

Quoted 31 lines
arch/arm/mach-imx/init.c +4 -2
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
+	unsigned reg;
+
 	writel(cfg_val, &psrc->gpr9);
 	reg = readl(&psrc->gpr10);
 	if (cfg_val)
-		reg |= IMX6_SRC_GPR10_BMODE;
+		reg |= bmode;
 	else
-		reg &= ~IMX6_SRC_GPR10_BMODE;
+		reg &= ~bmode;
 	writel(reg, &psrc->gpr10);
 }
 #endif
arch/arm/mach-imx/mx7/soc.c +1 -0
index 8db672fb05..2698ae623e 100644
@@ -13,6 +13,7 @@
 #include <asm/mach-imx/hab.h>
 #include <asm/mach-imx/rdc-sema.h>
 #include <asm/arch/imx-rdc.h>
+#include <asm/mach-imx/boot_mode.h>
 #include <asm/arch/crm_regs.h>
 #include <dm.h>
 #include <env.h>
@@ -411,6 +412,13 @@ void s_init(void)
 	return;
 }
 

arch/arm/mach-imx/mx7/soc.c void s_init(void) · line 424

Quoted 10 lines
arch/arm/mach-imx/mx7/soc.c +7 -0
+#ifndef CONFIG_SPL_BUILD
+const struct boot_mode soc_boot_modes[] = {
+	{"normal",	MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
+	{NULL,		0},
+};
+#endif
+
 void reset_misc(void)
 {
 #ifndef CONFIG_SPL_BUILD

Regards,
Stefano

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
=====================================================================
#11 lore raw

PATCH 1/4 ARM: imx: Add bmode support for iMX7

Quoted 1 line · Stefano Babic

Hi Marek,

Hi,

Quoted 33 lines · Marek Vasut
Quoted 32 lines

Add the basic differentiation between i.MX6 and i.MX7 into the bmode command, the mechanism really works almost the same on both platforms.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/include/asm/mach-imx/sys_proto.h |  6 +++++-
 arch/arm/mach-imx/Kconfig                 |  2 +-
 arch/arm/mach-imx/init.c                  | 12 +++++++++---
 arch/arm/mach-imx/mx7/soc.c               |  8 ++++++++
 4 files changed, 23 insertions(+), 5 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index ab94024c9b..2d18b1f56b 100644
@@ -78,7 +78,7 @@ struct bd_info;
 #define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
 
 #ifdef CONFIG_MX6
-#define IMX6_SRC_GPR10_BMODE		BIT(28)
+#define IMX6_SRC_GPR10_BMODE			BIT(28)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4
@@ -126,6 +126,10 @@ void gpr_init(void);
 
 #endif /* CONFIG_MX6 */
 
Quoted 8 lines

arch/arm/include/asm/mach-imx/sys_proto.h void gpr_init(void); · line 132

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +4 -0
+#ifdef CONFIG_MX7
+#define IMX7_SRC_GPR10_BMODE			BIT(28)
+#endif
+

It is questionable why we need two different defines, that also have exactly the same definition. Do we really need to differentiate and to use #ifdef ?

Yes, because this file is also used by iMXes which are not 6/7 .

#12 lore raw

PATCH 1/4 ARM: imx: Add bmode support for iMX7

Quoted 47 lines · Marek Vasut
Quoted 1 line · Stefano Babic

Hi Marek,

Hi,

Quoted 33 lines · Marek Vasut
Quoted 32 lines

Add the basic differentiation between i.MX6 and i.MX7 into the bmode command, the mechanism really works almost the same on both platforms.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/include/asm/mach-imx/sys_proto.h |  6 +++++-
 arch/arm/mach-imx/Kconfig                 |  2 +-
 arch/arm/mach-imx/init.c                  | 12 +++++++++---
 arch/arm/mach-imx/mx7/soc.c               |  8 ++++++++
 4 files changed, 23 insertions(+), 5 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index ab94024c9b..2d18b1f56b 100644
@@ -78,7 +78,7 @@ struct bd_info;
 #define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
 
 #ifdef CONFIG_MX6
-#define IMX6_SRC_GPR10_BMODE		BIT(28)
+#define IMX6_SRC_GPR10_BMODE			BIT(28)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4
@@ -126,6 +126,10 @@ void gpr_init(void);
 
 #endif /* CONFIG_MX6 */
 
Quoted 8 lines

arch/arm/include/asm/mach-imx/sys_proto.h void gpr_init(void); · line 132

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +4 -0
+#ifdef CONFIG_MX7
+#define IMX7_SRC_GPR10_BMODE			BIT(28)
+#endif
+

It is questionable why we need two different defines, that also have exactly the same definition. Do we really need to differentiate and to use #ifdef ?

Quoted 1 line

Yes, because this file is also used by iMXes which are not 6/7 .

Yes, but does it disturb ? There should be a define SRC_GPR10_BMODE that is not used at all if we build for mx3/mx5. I just prefer to reduce the number of #ifdef, when they are not strictly required.

Regards,
Stefano

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
=====================================================================
#13 lore raw

PATCH 1/4 ARM: imx: Add bmode support for iMX7

On 8/5/20 4:54 PM, Stefano Babic wrote:
[...]

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

#define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))

#ifdef CONFIG_MX6

arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
-#define IMX6_SRC_GPR10_BMODE		BIT(28)
+#define IMX6_SRC_GPR10_BMODE			BIT(28)
 
 #define IMX6_BMODE_MASK			GENMASK(7, 0)
 #define	IMX6_BMODE_SHIFT		4

arch/arm/include/asm/mach-imx/sys_proto.h void gpr_init(void); · line 132

Quoted 7 lines
arch/arm/include/asm/mach-imx/sys_proto.h +4 -0
@@ -126,6 +126,10 @@ void gpr_init(void);
 
 #endif /* CONFIG_MX6 */
 
+#ifdef CONFIG_MX7
+#define IMX7_SRC_GPR10_BMODE			BIT(28)
+#endif
+

It is questionable why we need two different defines, that also have exactly the same definition. Do we really need to differentiate and to use #ifdef ?

Quoted 5 lines
Quoted 1 line

Yes, because this file is also used by iMXes which are not 6/7 .

Yes, but does it disturb ? There should be a define SRC_GPR10_BMODE that is not used at all if we build for mx3/mx5. I just prefer to reduce the number of #ifdef, when they are not strictly required.

Its putting macros into the preprocessor which don't need to be there. Otherwise, it is inline with the style in the rest of the file.

#14 lore raw

PATCH 1/4 ARM: imx: Add bmode support for iMX7

In reply to Marek Vasut
Quoted 7 lines

Add the basic differentiation between i.MX6 and i.MX7 into the bmode command, the mechanism really works almost the same on both platforms.

Cc Fabio Estevam <[email protected]>
Cc NXP i.MX U-Boot Team <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>

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
=====================================================================