[PATCH 8/8] ARM: stm32mp: mark iwdg2 with barebox,restart-warm-bootrom

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


All STM32MP1 DTs already include their respective barebox SoC header, so
set barebox,restart-warm-bootrom there, so users can portably run:

  tamp.reboot_mode.next=serial reset -w

To get into DFU mode.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 Documentation/boards/stm32mp.rst   | 6 +++++-
 arch/arm/dts/stm32mp131.dtsi       | 4 ++++
 arch/arm/dts/stm32mp151.dtsi       | 4 ++++
 drivers/clk/clk-stm32mp1.c         | 2 +-
 drivers/power/reset/stm32-reboot.c | 6 ++++--
 include/soc/stm32/reboot.h         | 6 ++++--
 6 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/Documentation/boards/stm32mp.rst b/Documentation/boards/stm32mp.rst
index 4cdd281a9e14..813117a04f22 100644
--- a/Documentation/boards/stm32mp.rst
+++ b/Documentation/boards/stm32mp.rst
@@ -164,9 +164,13 @@ normal barebox functionality like creating a DFU-gadget in barebox,
 Fastboot/USB mass storage ... etc.
 
 The FIP image containing barebox can be generated as described in
-137::ref:`stm32mp_fip`. Upstream TF-A doesn't support DFU for
+:ref:`stm32mp_fip`. Upstream TF-A doesn't support DFU for
 SSBLs using the legacy stm32image format.
 
+DFU mode can be forced via :ref:`reboot_mode` from a booted system with::
+
+  tamp.reboot_mode.next=serial reset -w
+
 Boot source selection
 ---------------------
 
diff --git a/arch/arm/dts/stm32mp131.dtsi b/arch/arm/dts/stm32mp131.dtsi
index 2ecad85f086e..89a7ffcb814f 100644
--- a/arch/arm/dts/stm32mp131.dtsi
+++ b/arch/arm/dts/stm32mp131.dtsi
@@ -12,3 +12,7 @@
 		reg = <0x5a003000 0x1000>;
 	};
 };
+
+&iwdg2 {
+	barebox,restart-warm-bootrom;
+};
diff --git a/arch/arm/dts/stm32mp151.dtsi b/arch/arm/dts/stm32mp151.dtsi
index ac6536a556a9..d3e924dc0072 100644
--- a/arch/arm/dts/stm32mp151.dtsi
+++ b/arch/arm/dts/stm32mp151.dtsi
@@ -37,6 +37,10 @@
 	barebox,provide-mac-address = <&ethernet0 0x39>;
 };
 
+&iwdg2 {
+	barebox,restart-warm-bootrom;
+};
+
 &tamp {
 	reboot_mode_tamp: reboot-mode {
 		compatible = "syscon-reboot-mode";
diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c
index c4b03e9f6d74..6753a3689085 100644
--- a/drivers/clk/clk-stm32mp1.c
+++ b/drivers/clk/clk-stm32mp1.c
@@ -2280,7 +2280,7 @@ static int stm32mp1_rcc_init(struct device_d *dev)
 	if (ret)
 		return ret;
 
-	stm32mp_system_restart_init(base);
+	stm32mp_system_restart_init(dev);
 	return 0;
 }
 
diff --git a/drivers/power/reset/stm32-reboot.c b/drivers/power/reset/stm32-reboot.c
index 809531e71396..147b4d9d8164 100644
--- a/drivers/power/reset/stm32-reboot.c
+++ b/drivers/power/reset/stm32-reboot.c
@@ -108,17 +108,19 @@ static void stm32_set_reset_reason(struct stm32_reset *priv,
 		reset_source_to_string(type), reg);
 }
 
-void stm32mp_system_restart_init(void __iomem *base)
+void stm32mp_system_restart_init(struct device_d *dev)
 {
 	struct stm32_reset *priv;
+	struct device_node *np = dev_of_node(dev);
 
 	priv = xzalloc(sizeof(*priv));
 
-	priv->base = base;
+	priv->base = of_iomap(np, 0);
 
 	priv->restart.name = "stm32-rcc";
 	priv->restart.restart = stm32mp_rcc_restart_handler;
 	priv->restart.priority = 200;
+	priv->restart.of_node = np;
 
 	restart_handler_register(&priv->restart);
 
diff --git a/include/soc/stm32/reboot.h b/include/soc/stm32/reboot.h
index d6c731f59f74..cf0d0286e753 100644
--- a/include/soc/stm32/reboot.h
+++ b/include/soc/stm32/reboot.h
@@ -5,10 +5,12 @@
 
 #include <linux/compiler.h>
 
+struct device_d;
+
 #ifdef CONFIG_RESET_STM32
-void stm32mp_system_restart_init(void __iomem *rcc);
+void stm32mp_system_restart_init(struct device_d *rcc);
 #else
-static inline void stm32mp_system_restart_init(void __iomem *rcc)
+static inline void stm32mp_system_restart_init(struct device_d *rcc)
 {
 }
 #endif
-- 
2.30.2




More information about the barebox mailing list