From: Marek Vasut Date: Wed, 5 Aug 2020 15:34:07 +0200 Subject: [PATCH 4/4] ARM: imx: Add support for reading out the primary/secondary bmode to MX7 In-Reply-To: <20200805133407.101338-1-marex@denx.de> References: <20200805133407.101338-1-marex@denx.de> Message-ID: <20200805133407.101338-4-marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Cc: Fabio Estevam Cc: NXP i.MX U-Boot Team Cc: Peng Fan Cc: Stefano Babic --- 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) -- 2.27.0