mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] Pass reset and boot sources via /chosen node
@ 2018-05-08 21:21 Andrey Smirnov
  2018-05-08 21:21 ` [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel Andrey Smirnov
  2018-05-08 21:21 ` [PATCH 2/2] common: oftree: Pass reset source and reset source " Andrey Smirnov
  0 siblings, 2 replies; 5+ messages in thread
From: Andrey Smirnov @ 2018-05-08 21:21 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Everyone:

The following two patches are really usefull for Linux userspace
applications that need to know the details about reset and boot
sources.

Feedback is welcome!

Thanks,
Andrey Smirnov

Andrey Smirnov (2):
  common: oftree: Pass bootsource and bootsource instance to kernel
  common: oftree: Pass reset source and reset source instance to kernel

 common/oftree.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

-- 
2.17.0


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel
  2018-05-08 21:21 [PATCH 0/2] Pass reset and boot sources via /chosen node Andrey Smirnov
@ 2018-05-08 21:21 ` Andrey Smirnov
  2018-05-14  7:48   ` Sascha Hauer
  2018-05-08 21:21 ` [PATCH 2/2] common: oftree: Pass reset source and reset source " Andrey Smirnov
  1 sibling, 1 reply; 5+ messages in thread
From: Andrey Smirnov @ 2018-05-08 21:21 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Pass barebox-detected bootsource and bootsource instance 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/bootsource

and

/sys/firmware/devicetree/base/chosen/bootsource-instance.

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

diff --git a/common/oftree.c b/common/oftree.c
index 8a2ede4c6..9c94ca116 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -11,6 +11,7 @@
 #include <getopt.h>
 #include <init.h>
 #include <boot.h>
+#include <bootsource.h>
 #include <i2c/i2c.h>
 
 #define MAX_LEVEL	32		/* how deeply nested we will go */
@@ -118,6 +119,7 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
 {
 	struct device_node *node;
 	const char *str;
+	int instance;
 	int err;
 
 	str = linux_bootargs_get();
@@ -130,6 +132,12 @@ 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, "bootsource", getenv("bootsource"));
+	instance = bootsource_get_instance();
+	of_property_write_u32(node, "bootsource-instance",
+			      (instance == BOOTSOURCE_INSTANCE_UNKNOWN) ?
+			      0 : instance);
+
 	err = of_property_write_string(node, "bootargs", str);
 
 	return err;
-- 
2.17.0


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] common: oftree: Pass reset source and reset source instance to kernel
  2018-05-08 21:21 [PATCH 0/2] Pass reset and boot sources via /chosen node Andrey Smirnov
  2018-05-08 21:21 ` [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel Andrey Smirnov
@ 2018-05-08 21:21 ` Andrey Smirnov
  1 sibling, 0 replies; 5+ messages in thread
From: Andrey Smirnov @ 2018-05-08 21:21 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

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@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


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel
  2018-05-08 21:21 ` [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel Andrey Smirnov
@ 2018-05-14  7:48   ` Sascha Hauer
  2018-05-15  5:40     ` Andrey Smirnov
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2018-05-14  7:48 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

Hi Andrey,

On Tue, May 08, 2018 at 02:21:24PM -0700, Andrey Smirnov wrote:
> Pass barebox-detected bootsource and bootsource instance 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/bootsource

I like the idea of having the bootsource available in Linux and more
than once thought about implementing it. However, I don't think it's
good to put the rather adhoc strings from barebox into the devicetree.

I'd rather have a phandle pointing to the actual device providing the
bootsource. Something like converting bootsource/bootsource_instance
into an alias name, lookup that alias in the device tree and create a
phandle pointing to the node the alias points to aswell. This may be
more complicated, but this way we do not have to think up any mapping.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel
  2018-05-14  7:48   ` Sascha Hauer
@ 2018-05-15  5:40     ` Andrey Smirnov
  0 siblings, 0 replies; 5+ messages in thread
From: Andrey Smirnov @ 2018-05-15  5:40 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On Mon, May 14, 2018 at 12:48 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Hi Andrey,
>
> On Tue, May 08, 2018 at 02:21:24PM -0700, Andrey Smirnov wrote:
>> Pass barebox-detected bootsource and bootsource instance 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/bootsource
>
> I like the idea of having the bootsource available in Linux and more
> than once thought about implementing it. However, I don't think it's
> good to put the rather adhoc strings from barebox into the devicetree.
>
> I'd rather have a phandle pointing to the actual device providing the
> bootsource. Something like converting bootsource/bootsource_instance
> into an alias name, lookup that alias in the device tree and create a
> phandle pointing to the node the alias points to aswell. This may be
> more complicated, but this way we do not have to think up any mapping.
>

OK, that does sound like a better idea. I'll give it a try and submit
results in v2.

Thanks,
Andrey Smirnov

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-15  5:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 21:21 [PATCH 0/2] Pass reset and boot sources via /chosen node Andrey Smirnov
2018-05-08 21:21 ` [PATCH 1/2] common: oftree: Pass bootsource and bootsource instance to kernel Andrey Smirnov
2018-05-14  7:48   ` Sascha Hauer
2018-05-15  5:40     ` Andrey Smirnov
2018-05-08 21:21 ` [PATCH 2/2] common: oftree: Pass reset source and reset source " Andrey Smirnov

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