Skip to content

Commit

Permalink
common: oftree: Pass reset source and reset source instance to kernel
Browse files Browse the repository at this point in the history
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. This info is placeed 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 <[email protected]>
Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
ndreys authored and saschahauer committed May 18, 2018
1 parent 89677d1 commit 58243d9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/oftree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -158,6 +159,10 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
if (err)
return err;

of_property_write_string(node, "reset-source", reset_source_name());
of_property_write_u32(node, "reset-source-instance",
reset_source_get_instance());

return of_fixup_bootargs_bootsource(root, node);
}

Expand Down

0 comments on commit 58243d9

Please sign in to comment.