[PATCH 2/2] common: oftree: Pass reset source and reset source instance to kernel

Andrey Smirnov andrew.smirnov at gmail.com
Tue May 8 14:21:25 PDT 2018


Detecting reset reason is, in some cases, a destructive operation and
in such cases it is impossible to obtain that information in the
kernel without some help from barebox.

Pass reset source and reset source instance to kernel to Linux to
make it availible to Linux userspace. We use put the version under
/chosen/bootsource and it can be read under Linux in

/sys/firmware/devicetree/base/chosen/reset-source.

and

/sys/firmware/devicetree/base/chosen/reset-source-instance.

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 common/oftree.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/oftree.c b/common/oftree.c
index 9c94ca116..a6633c453 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -13,6 +13,7 @@
 #include <boot.h>
 #include <bootsource.h>
 #include <i2c/i2c.h>
+#include <reset_source.h>
 
 #define MAX_LEVEL	32		/* how deeply nested we will go */
 
@@ -132,6 +133,10 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
 
 	of_property_write_string(node, "barebox-version", release_string);
 
+	of_property_write_string(node, "reset-source", reset_source_name());
+	of_property_write_u32(node, "reset-source-instance",
+			      reset_source_get_instance());
+
 	of_property_write_string(node, "bootsource", getenv("bootsource"));
 	instance = bootsource_get_instance();
 	of_property_write_u32(node, "bootsource-instance",
-- 
2.17.0




More information about the barebox mailing list