mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 7/8] ARM: i.MX7: describe USB serial download boot mode
Date: Mon, 17 Oct 2022 09:09:59 +0200	[thread overview]
Message-ID: <20221017071000.1458292-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221017071000.1458292-1-a.fatoum@pengutronix.de>

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@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




  parent reply	other threads:[~2022-10-17  7:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17  7:09 [PATCH 0/8] ARM: i.MX7: add serial download reboot mode Ahmad Fatoum
2022-10-17  7:09 ` [PATCH 1/8] restart: make restart.h header self-contained Ahmad Fatoum
2022-10-17  7:09 ` [PATCH 2/8] restart: do restart-priority OF parsing in restart_handler_register Ahmad Fatoum
2022-10-17  7:09 ` [PATCH 3/8] restart: add reset -w for warm bootrom reset Ahmad Fatoum
2022-10-17  7:09 ` [PATCH 4/8] watchdog: imxwd: don't register broken imxwd-warm for i.MX7 Ahmad Fatoum
2022-10-17  7:09 ` [PATCH 5/8] watchdog: imxwd: set imxwd-warm as reboot mode default handler Ahmad Fatoum
2022-10-17  7:09 ` [PATCH 6/8] Documentations: devicetree: bindings: document watchdog-priority Ahmad Fatoum
2022-10-17  7:09 ` Ahmad Fatoum [this message]
2022-10-17  7:10 ` [PATCH 8/8] ARM: stm32mp: mark iwdg2 with barebox,restart-warm-bootrom Ahmad Fatoum
2022-10-18  9:13 ` [PATCH 0/8] ARM: i.MX7: add serial download reboot mode Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221017071000.1458292-8-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox