mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] reset-source: pass reset reason to kernel via device tree
@ 2018-03-19 11:57 Philipp Zabel
  0 siblings, 0 replies; only message in thread
From: Philipp Zabel @ 2018-03-19 11:57 UTC (permalink / raw)
  To: barebox

Add a device tree fixup that adds a /chosen/barebox-reset-reason string
property to the device tree chosen node. It can be read under Linux in
/sys/firmware/devicetree/base/chosen/barebox-reset-reason.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 Documentation/user/reset-reason.rst |  3 +++
 common/reset_source.c               | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/user/reset-reason.rst b/Documentation/user/reset-reason.rst
index 26d37f86dd..26022ba6d7 100644
--- a/Documentation/user/reset-reason.rst
+++ b/Documentation/user/reset-reason.rst
@@ -45,3 +45,6 @@ The following values can help to detect the reason why the bootloader runs:
 It depends on your board/SoC and its features if the hardware is able to detect
 these reset reasons. Most of the time only ``POR`` and ``RST`` are supported
 but often ``WDG`` as well.
+
+The reset reason is passed to the kernel via the device tree property string
+``/chosen/barebox-reset-reason``.
diff --git a/common/reset_source.c b/common/reset_source.c
index 06e2ca85f5..e14ba3fc16 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -77,3 +77,25 @@ unsigned int of_get_reset_source_priority(struct device_node *node)
 
 	return priority;
 }
+
+#ifdef CONFIG_OFTREE
+static int reset_source_of_fixup(struct device_node *root, void *context)
+{
+	struct device_node *node;
+
+	node = of_create_node(root, "/chosen");
+	if (!node)
+		return -ENOMEM;
+
+	return of_property_write_string(node, "barebox-reset-reason",
+			reset_src_names[reset_source]);
+}
+
+static int reset_source_register_of_fixup(void)
+{
+	of_register_fixup(reset_source_of_fixup, NULL);
+
+	return 0;
+}
+late_initcall(reset_source_register_of_fixup);
+#endif
-- 
2.16.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-19 11:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 11:57 [PATCH] reset-source: pass reset reason to kernel via device tree Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox