summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-10-20 09:58:26 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-27 11:13:29 +0200
commitede287e8b0e37526c2d944aac3dec957f22f300b (patch)
tree7d73ba1b1b7ca4069d3ba1a284538e7b5bec8388 /arch
parent8fbeaa3b30d68d39add6b0fb1e2ae6b01af950b7 (diff)
downloadbarebox-ede287e8b0e37526c2d944aac3dec957f22f300b.tar.gz
barebox-ede287e8b0e37526c2d944aac3dec957f22f300b.tar.xz
ARM: i.MX bootsource: adapt boot device detection for imx8mp
imx8mp uses sbmr2[27..24] for encoding the bootmode while existing code reads only sbmr2[25..24]. This can detect BOOTSOURCE_SERIAL for the wrong mode. Based on: https://lore.barebox.org/barebox/20221014115354.4072202-1-enrico.scholz@sigma-chemnitz.de/T/#u Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20221020075826.3385137-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-imx/boot.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 7b3334d5e2..c0193cfa43 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -202,7 +202,8 @@ void imx51_boot_save_loc(void)
}
#define IMX53_SRC_SBMR 0x4
-#define SRC_SBMR_BMOD GENMASK(25, 24)
+#define IMX53_SRC_SBMR_BMOD GENMASK(25, 24)
+#define IMX8MP_SRC_SBMR_BMOD GENMASK(27, 24)
#define IMX53_BMOD_SERIAL 0b11
#define __BOOT_CFG(n, m, l) GENMASK((m) + ((n) - 1) * 8, \
@@ -234,7 +235,12 @@ __MAKE_BOOT_CFG_BITS(4)
static unsigned int imx53_get_bmod(uint32_t r)
{
- return FIELD_GET(SRC_SBMR_BMOD, r);
+ return FIELD_GET(IMX53_SRC_SBMR_BMOD, r);
+}
+
+static unsigned int imx8mp_get_bmod(uint32_t r)
+{
+ return FIELD_GET(IMX8MP_SRC_SBMR_BMOD, r);
}
static int imx53_bootsource_internal(uint32_t r)
@@ -317,6 +323,8 @@ void imx53_boot_save_loc(void)
#define IMX6_SRC_GPR10 0x44
#define IMX6_BMOD_SERIAL 0b01
#define IMX6_BMOD_RESERVED 0b11
+#define IMX8MP_BMOD_FUSES 0b0000
+#define IMX8MP_BMOD_SERIAL 0b0001
#define IMX6_BMOD_FUSES 0b00
#define BT_FUSE_SEL BIT(4)
#define GPR10_BOOT_FROM_GPR9 BIT(28)
@@ -338,6 +346,18 @@ static bool imx6_bootsource_serial(uint32_t sbmr2)
!(sbmr2 & BT_FUSE_SEL));
}
+static bool imx8mp_bootsource_serial(uint32_t sbmr2)
+{
+ return imx8mp_get_bmod(sbmr2) == IMX8MP_BMOD_SERIAL ||
+ /*
+ * If boot from fuses is selected and fuses are not
+ * programmed by setting BT_FUSE_SEL, ROM code will
+ * fallback to serial mode
+ */
+ (imx8mp_get_bmod(sbmr2) == IMX8MP_BMOD_FUSES &&
+ !(sbmr2 & BT_FUSE_SEL));
+}
+
static bool imx6_bootsource_serial_forced(uint32_t bootmode)
{
if (cpu_mx6_is_mx6ul() || cpu_mx6_is_mx6ull())
@@ -694,7 +714,7 @@ void imx8mp_get_boot_source(enum bootsource *src, int *instance)
void __iomem *src_base = IOMEM(MX8MP_SRC_BASE_ADDR);
uint32_t sbmr2 = readl(src_base + 0x70);
- if (imx6_bootsource_serial(sbmr2)) {
+ if (imx8mp_bootsource_serial(sbmr2)) {
*src = BOOTSOURCE_SERIAL;
return;
}