devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Pantelis Antoniou
	<panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] dtc: Dynamic symbols & fixup support (v2)
Date: Mon, 4 Nov 2013 15:53:42 +0100	[thread overview]
Message-ID: <20131104145342.GW24559@pengutronix.de> (raw)
In-Reply-To: <1383575773-7296-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>

Hi Pantelis,

Thank you for working on this again. I would really appreciate seeing
this upstream.

On Mon, Nov 04, 2013 at 04:36:13PM +0200, Pantelis Antoniou wrote:
> +Notice that all the nodes that had a label have been recorded, and that
> +phandles have been generated for them.
> +
> +This blob can be used to boot the board normally, the __symbols__ node will
> +be safely ignored both by the bootloader and the kernel (the only loss will
> +be a few bytes of memory and disk space).
> +
> +3.b) The Device Tree fragments must be compiled with the same option but they
> +must also have a tag (/plugin/) that allows undefined references to labels
> +that are not present at compilation time to be recorded so that the runtime
> +loader can fix them.
> +
> +So the bar peripheral's DTS format would be of the form:
> +
> +/plugin/;	/* allow undefined label references and record them */
> +/ {
> +	....	/* various properties for loader use; i.e. part id etc. */
> +	fragment@0 {
> +		target = <&ocp>;
> +		__overlay__ {
> +			/* bar peripheral */
> +			bar {
> +				compatible = "corp,bar";
> +				... /* various properties and child nodes */
> +			}
> +		};
> +	};
> +};

When last looking at this patch I created the attached follow up. What
I didn't like about this patch is that we currently have to write dts
files explicitely as overlays. With the attached patch the above could
be written as:

&ocp: {
	compatible = "corp,bar";
};

This is easier to write and more important a dts snippet could be either
compiled into a dtb or used as an overlay.

Sascha

8<-------------------------------------------------------------------

>From bf78934e2bfe5c220d97d52e4effdd95164e071f Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Date: Thu, 8 Aug 2013 23:08:31 +0200
Subject: [PATCH] dtc: convert unresolved labels into overlay nodes

Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 dtc-parser.y | 10 +++++++---
 dtc.h        |  3 ++-
 livetree.c   | 23 +++++++++++++++++++++++
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/dtc-parser.y b/dtc-parser.y
index e444acf..db1e9f8 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -166,10 +166,14 @@ devicetree:
 		{
 			struct node *target = get_node_by_ref($1, $2);
 
-			if (target)
+			if (target) {
 				merge_nodes(target, $3);
-			else
-				print_error("label or path, '%s', not found", $2);
+			} else {
+				if (symbol_fixup_support)
+					add_orphan_node($1, $3, $2);
+				else
+					print_error("label or path, '%s', not found", $2);
+			}
 			$$ = $1;
 		}
 	| devicetree DT_DEL_NODE DT_REF ';'
diff --git a/dtc.h b/dtc.h
index 8c9059b..147ab35 100644
--- a/dtc.h
+++ b/dtc.h
@@ -20,7 +20,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *                                                                   USA
  */
-
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -232,6 +232,7 @@ struct node *build_node_delete(void);
 struct node *name_node(struct node *node, char *name);
 struct node *chain_node(struct node *first, struct node *list);
 struct node *merge_nodes(struct node *old_node, struct node *new_node);
+void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
 
 void add_property(struct node *node, struct property *prop);
 void delete_property_by_name(struct node *node, char *name);
diff --git a/livetree.c b/livetree.c
index b61465f..cc26fe1 100644
--- a/livetree.c
+++ b/livetree.c
@@ -216,6 +216,29 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
 	return old_node;
 }
 
+void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
+{
+	struct node *ovl = xmalloc(sizeof(*ovl));
+	struct property *p;
+	struct data d = empty_data;
+	char *name;
+
+	memset(ovl, 0, sizeof(*ovl));
+
+	d = data_add_marker(d, REF_PHANDLE, ref);
+	d = data_append_integer(d, 0xdeadbeef, 32);
+
+	p = build_property("target", d);
+	add_property(ovl, p);
+
+	asprintf(&name, "fragment@%s", ref);
+	name_node(ovl, name);
+	name_node(new_node, "__overlay__");
+
+	add_child(dt, ovl);
+	add_child(ovl, new_node);
+}
+
 struct node *chain_node(struct node *first, struct node *list)
 {
 	assert(first->next_sibling == NULL);
-- 
1.8.4.rc3

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-11-04 14:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04 14:36 [PATCH] dtc: Dynamic symbols & fixup support (v2) Pantelis Antoniou
     [not found] ` <1383575773-7296-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-04 14:53   ` Sascha Hauer [this message]
     [not found]     ` <20131104145342.GW24559-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-11-04 14:58       ` Pantelis Antoniou
     [not found]         ` <53AA440E-7F33-4AC1-9323-7D109D4B5852-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-05  8:02           ` Sascha Hauer
2013-11-04 21:17   ` Dinh Nguyen
2013-11-05  7:46     ` Sascha Hauer
     [not found]     ` <CADhT+wcgs2cQv23+K7EooZaA0KK7Lk8zY-KAPc50xUdm5BFRZw@mail.gmail.com>
     [not found]       ` <CADhT+wcgs2cQv23+K7EooZaA0KK7Lk8zY-KAPc50xUdm5BFRZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-05  7:49         ` Pantelis Antoniou
     [not found] ` <CADhT+wdJfrRMDjm+jb_+_uuy8sPRd1B0F5mNVgOL2DmyHTMrYw@mail.gmail.com>
     [not found]   ` <CADhT+wdJfrRMDjm+jb_+_uuy8sPRd1B0F5mNVgOL2DmyHTMrYw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-08  7:03     ` Pantelis Antoniou
     [not found] <1383073266-12017-1-git-send-email-panto@antoniou-consulting.com>
     [not found] ` <1383073266-12017-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-11 17:56   ` Grant Likely
     [not found]     ` <20131111175604.ECF33C4233A-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-12 10:20       ` Pantelis Antoniou
     [not found]     ` < DABC2A65-BC07-4481-B80C-A62777BD8732@antoniou-consulting.com>
     [not found]       ` <DABC2A65-BC07-4481-B80C-A62777BD8732-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-15  7:01         ` Grant Likely
     [not found]           ` <20131115070131.78139C40785-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-16 17:47             ` Pantelis Antoniou
     [not found]       ` < 20131115070131.78139C40785@trevor.secretlab.ca>
     [not found]         ` < 972758FF-44EC-4C32-BE13-4E3E8361D063@antoniou-consulting.com>
     [not found]           ` <972758FF-44EC-4C32-BE13-4E3E8361D063-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-17 22:16             ` Grant Likely

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=20131104145342.GW24559@pengutronix.de \
    --to=s.hauer-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.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;
as well as URLs for NNTP newsgroup(s).