From: Philipp Zabel <p.zabel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] reset-source: pass reset reason to kernel via device tree
Date: Mon, 19 Mar 2018 12:57:14 +0100 [thread overview]
Message-ID: <20180319115714.1238-1-p.zabel@pengutronix.de> (raw)
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
reply other threads:[~2018-03-19 11:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20180319115714.1238-1-p.zabel@pengutronix.de \
--to=p.zabel@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