diff mbox series

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

Message ID 20200805133407.101338-4-marex@denx.de
State Accepted
Commit 4b44bea701a67e3b83cb82f44fa40485b111d394
Delegated to: Stefano Babic
Headers show
Series [1/4] ARM: imx: Add bmode support for iMX7 | expand

Commit Message

Marek Vasut Aug. 5, 2020, 1:34 p.m. UTC
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.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 arch/arm/mach-imx/mx7/soc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefano Babic Aug. 5, 2020, 4:01 p.m. UTC | #1
On 05.08.20 15:34, Marek Vasut wrote:
> 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.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/mach-imx/mx7/soc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
> index b6fd25a991..c90f7354ea 100644
> --- a/arch/arm/mach-imx/mx7/soc.c
> +++ b/arch/arm/mach-imx/mx7/soc.c
> @@ -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)
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Stefano Babic Aug. 18, 2020, 12:33 p.m. UTC | #2
> 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.
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Reviewed-by: Stefano Babic <sbabic@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index b6fd25a991..c90f7354ea 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -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)