[PATCH 7/8] ARM: i.MX7: describe USB serial download boot mode

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Oct 17 00:09:59 PDT 2022


Due to i.MX7 erratum e10574: "Watchdog: A watchdog timeout or software
trigger will not reset the SOC", we can't do warm reset via imxwd-warm
for BootROM reboot mode as we do on other i.MX SoCs.

What we can do instead though, is use the SoC's reset controller to
toggle the Cortex-A7's reset. This will have us reenter BootROM with
GPR registers intact. Forcing serial download on the i.MX7 now possible
with:

  gpr.reboot_mode.next=serial reset -w

Note that the new restart handler is not fit for general purpose.
Depending on boot medium, it may hang, because the BootROM may not
reinitialize the peripheral properly.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/configs/imx_v7_defconfig   |  2 ++
 arch/arm/dts/imx7.dtsi              | 37 +++++++++++++++++++++++++++++
 drivers/power/reset/syscon-reboot.c |  1 +
 3 files changed, 40 insertions(+)
 create mode 100644 arch/arm/dts/imx7.dtsi

diff --git a/arch/arm/configs/imx_v7_defconfig b/arch/arm/configs/imx_v7_defconfig
index d07abe28aeac..3cbec267fc87 100644
--- a/arch/arm/configs/imx_v7_defconfig
+++ b/arch/arm/configs/imx_v7_defconfig
@@ -208,6 +208,8 @@ CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED=y
 CONFIG_GENERIC_PHY=y
 CONFIG_USB_NOP_XCEIV=y
+CONFIG_SYSCON_REBOOT_MODE=y
+CONFIG_POWER_RESET_SYSCON=y
 CONFIG_FS_EXT4=y
 CONFIG_FS_TFTP=y
 CONFIG_FS_TFTP_MAX_WINDOW_SIZE=8
diff --git a/arch/arm/dts/imx7.dtsi b/arch/arm/dts/imx7.dtsi
new file mode 100644
index 000000000000..1c67bdc54620
--- /dev/null
+++ b/arch/arm/dts/imx7.dtsi
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
+
+#include "imx7d-ddrc.dtsi"
+
+/ {
+	aliases {
+		gpr.reboot_mode = &reboot_mode_gpr;
+	};
+};
+
+&src {
+	compatible = "fsl,imx7d-src", "syscon", "simple-mfd";
+
+	reboot_mode_gpr: reboot-mode {
+		compatible = "barebox,syscon-reboot-mode";
+		offset = <0x94>, <0x98>; /* SRC_GPR{9,10} */
+		mask = <0xffffffff>, <0x40000000>;
+		mode-normal = <0>, <0>;
+		mode-serial = <0x00000010>, <0x40000000>;
+	};
+
+	ca7_reset: cortex-a7-reboot {
+		compatible = "syscon-reboot";
+		regmap = <&src>;
+		offset = <0x4>;
+		mask = <1>;
+		value = <1>;
+		/* This is not fit for use as general purpose reset */
+		restart-priority = <5>;
+		/*
+		 * Can't use imxwd-warm due to errata e10574:
+		 * Watchdog: A watchdog timeout or software trigger will
+		 * not reset the SOC
+		 */
+		barebox,restart-warm-bootrom;
+	};
+};
diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index 2dbb6c1ddcb8..b6b8db75caba 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -71,6 +71,7 @@ static int syscon_reboot_probe(struct device_d *dev)
 	ctx->restart_handler.name = "syscon-reboot";
 	ctx->restart_handler.restart = syscon_restart_handle;
 	ctx->restart_handler.priority = 192;
+	ctx->restart_handler.of_node = dev->device_node;
 
 	err = restart_handler_register(&ctx->restart_handler);
 	if (err)
-- 
2.30.2




More information about the barebox mailing list