[PATCH 10/17] ARM: i.MX: boot: Share code to detect NAND as a boot source

Andrey Smirnov andrew.smirnov at gmail.com
Sat Apr 14 10:50:56 PDT 2018


Share code to detect NAND as a boot source between i.MX53 and i.MX6
which behave the same in that aspect.

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 arch/arm/mach-imx/boot.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 66e1a9254..c092dc827 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -175,6 +175,8 @@ static unsigned int sbmr(uint32_t r, unsigned int msb, unsigned int lsb)
 	return (r & GENMASK(msb, lsb)) >> lsb;
 }
 
+#define BOOT_CFG1(r, n)	sbmr(r, n, n)
+
 static unsigned int imx53_get_bmod(uint32_t r)
 {
 	return sbmr(r, 25, 24);
@@ -185,6 +187,11 @@ static int imx53_bootsource_internal(uint32_t r)
 	return sbmr(r, 7, 4);	/* BOOT_CFG1[7:4] */
 }
 
+static bool imx53_bootsource_nand(uint32_t r)
+{
+	return BOOT_CFG1(r, 7);
+}
+
 void imx53_get_boot_source(enum bootsource *src, int *instance)
 {
 	void __iomem *src_base = IOMEM(MX53_SRC_BASE_ADDR);
@@ -216,7 +223,7 @@ void imx53_get_boot_source(enum bootsource *src, int *instance)
 		break;
 	}
 
-	if (cfg1 & (1 << 7))
+	if (imx53_bootsource_nand(cfg1))
 		*src = BOOTSOURCE_NAND;
 
 
@@ -300,8 +307,7 @@ void imx6_get_boot_source(enum bootsource *src, int *instance)
 		break;
 	}
 
-	/* BOOT_CFG1[7:0] */
-	if (sbmr1 & (1 << 7))
+	if (imx53_bootsource_nand(sbmr1))
 		*src = BOOTSOURCE_NAND;
 }
 
-- 
2.14.3




More information about the barebox mailing list