* [PATCH] dtc: parser: Add label while overriding nodes
@ 2015-01-08 14:12 Nikhil Devshatwar
2015-01-27 15:11 ` Devshatwar, Nikhil
[not found] ` <1420726362-22555-1-git-send-email-nikhil.nd-l0cyMroinI0@public.gmane.org>
0 siblings, 2 replies; 7+ messages in thread
From: Nikhil Devshatwar @ 2015-01-08 14:12 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
devicetree-spec-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA
Cc: Nikhil Devshatwar
Current device tree compiler allows to define multiple labels when defining
the device node the first time. Typically device nodes are defined in
DTSI files. Now these nodes can be overriden for updating some of the
properties. Typically, device nodes are overridden in DTS files.
When working with adapter boards, most of the time adapter board can fit to
multiple base boards. But depending on which base board it is connected to,
the devices on the adapter board would be children of different devices.
e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas
on dra72-evm.dts, i2c5 is exported for expansion connector.
This causes a problem when writing a generic device tree file for
the adapter board. Because, you cannot know wheather all the devices on
adpter board are present on i2c or i2c5.
The problem can be solved by adding a common label (e.g. i2cexp) in both
of the DTS files when overriding the device nodes for i2c2 or i2c5.
This way, generic adapter board file would override the i2cexp. And
depending on which base board you use the adpter board, all the devices
are automatically added for correct device nodes.
Change-Id: I3ad7247a79baed7268a91fc691360aece73d6d1b
Signed-off-by: Nikhil Devshatwar <nikhil.nd-l0cyMroinI0@public.gmane.org>
---
scripts/dtc/dtc-parser.y | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
index f412460..d9ed3b7 100644
--- a/scripts/dtc/dtc-parser.y
+++ b/scripts/dtc/dtc-parser.y
@@ -145,6 +145,18 @@ devicetree:
{
$$ = merge_nodes($1, $3);
}
+
+ | devicetree DT_LABEL DT_REF nodedef
+ {
+ struct node *target = get_node_by_ref($1, $3);
+
+ add_label(&target->labels, $2);
+ if (target)
+ merge_nodes(target, $4);
+ else
+ print_error("label or path, '%s', not found", $2);
+ $$ = $1;
+ }
| devicetree DT_REF nodedef
{
struct node *target = get_node_by_ref($1, $2);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe devicetree-spec" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH] dtc: parser: Add label while overriding nodes
2015-01-08 14:12 [PATCH] dtc: parser: Add label while overriding nodes Nikhil Devshatwar
@ 2015-01-27 15:11 ` Devshatwar, Nikhil
[not found] ` <1420726362-22555-1-git-send-email-nikhil.nd-l0cyMroinI0@public.gmane.org>
1 sibling, 0 replies; 7+ messages in thread
From: Devshatwar, Nikhil @ 2015-01-27 15:11 UTC (permalink / raw)
To: Devshatwar, Nikhil, devicetree-compiler@vger.kernel.org,
devicetree@vger.kernel.org, devicetree-spec@vger.kernel.org,
linux-omap@vger.kernel.org
Cc: grant.likely@linaro.org, robh+dt@kernel.org
Hi all,
Does this patch make sense?
> -----Original Message-----
> From: Devshatwar, Nikhil
> Sent: Thursday, January 08, 2015 7:43 PM
> To: devicetree-compiler@vger.kernel.org; devicetree@vger.kernel.org;
> devicetree-spec@vger.kernel.org; linux-omap@vger.kernel.org
> Cc: Devshatwar, Nikhil
> Subject: [PATCH] dtc: parser: Add label while overriding nodes
>
> Current device tree compiler allows to define multiple labels when
> defining the device node the first time. Typically device nodes are
> defined in DTSI files. Now these nodes can be overriden for updating
> some of the properties. Typically, device nodes are overridden in DTS
> files.
>
> When working with adapter boards, most of the time adapter board can
> fit to multiple base boards. But depending on which base board it is
> connected to, the devices on the adapter board would be children of
> different devices.
>
> e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas
> on dra72-evm.dts, i2c5 is exported for expansion connector.
> This causes a problem when writing a generic device tree file for the
> adapter board. Because, you cannot know wheather all the devices on
> adpter board are present on i2c or i2c5.
>
> The problem can be solved by adding a common label (e.g. i2cexp) in
> both of the DTS files when overriding the device nodes for i2c2 or
> i2c5.
> This way, generic adapter board file would override the i2cexp. And
> depending on which base board you use the adpter board, all the devices
> are automatically added for correct device nodes.
>
> Change-Id: I3ad7247a79baed7268a91fc691360aece73d6d1b
> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
> ---
> scripts/dtc/dtc-parser.y | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index
> f412460..d9ed3b7 100644
> --- a/scripts/dtc/dtc-parser.y
> +++ b/scripts/dtc/dtc-parser.y
> @@ -145,6 +145,18 @@ devicetree:
> {
> $$ = merge_nodes($1, $3);
> }
> +
> + | devicetree DT_LABEL DT_REF nodedef
> + {
> + struct node *target = get_node_by_ref($1, $3);
> +
> + add_label(&target->labels, $2);
> + if (target)
> + merge_nodes(target, $4);
> + else
> + print_error("label or path, '%s', not found",
> $2);
> + $$ = $1;
> + }
> | devicetree DT_REF nodedef
> {
> struct node *target = get_node_by_ref($1, $2);
> --
> 1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1420726362-22555-1-git-send-email-nikhil.nd-l0cyMroinI0@public.gmane.org>]
* Re: [PATCH] dtc: parser: Add label while overriding nodes
[not found] ` <1420726362-22555-1-git-send-email-nikhil.nd-l0cyMroinI0@public.gmane.org>
@ 2015-01-27 23:34 ` Rob Herring
[not found] ` <CAL_Jsq+w7R=99qPc+YG_Bh1L-nMs1Gptjwo=KYTK5OX2HVVNpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2015-01-27 23:34 UTC (permalink / raw)
To: Nikhil Devshatwar
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-spec-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap
On Thu, Jan 8, 2015 at 8:12 AM, Nikhil Devshatwar <nikhil.nd-l0cyMroinI0@public.gmane.org> wrote:
> Current device tree compiler allows to define multiple labels when defining
> the device node the first time. Typically device nodes are defined in
> DTSI files. Now these nodes can be overriden for updating some of the
> properties. Typically, device nodes are overridden in DTS files.
>
> When working with adapter boards, most of the time adapter board can fit to
> multiple base boards. But depending on which base board it is connected to,
> the devices on the adapter board would be children of different devices.
>
> e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas
> on dra72-evm.dts, i2c5 is exported for expansion connector.
> This causes a problem when writing a generic device tree file for
> the adapter board. Because, you cannot know wheather all the devices on
s/wheather/whether/
> adpter board are present on i2c or i2c5.
s/adpter/adapter/
> The problem can be solved by adding a common label (e.g. i2cexp) in both
> of the DTS files when overriding the device nodes for i2c2 or i2c5.
> This way, generic adapter board file would override the i2cexp. And
> depending on which base board you use the adpter board, all the devices
s/adpter/adapter/
> are automatically added for correct device nodes.
>
> Change-Id: I3ad7247a79baed7268a91fc691360aece73d6d1b
Get rid of this Gerrit nonsense.
> Signed-off-by: Nikhil Devshatwar <nikhil.nd-l0cyMroinI0@public.gmane.org>
> ---
> scripts/dtc/dtc-parser.y | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
You need to send this against upstream dtc, not the copy in the kernel.
Seems like a reasonable change, but I'm not too familar with dtc source.
> diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
> index f412460..d9ed3b7 100644
> --- a/scripts/dtc/dtc-parser.y
> +++ b/scripts/dtc/dtc-parser.y
> @@ -145,6 +145,18 @@ devicetree:
> {
> $$ = merge_nodes($1, $3);
> }
> +
> + | devicetree DT_LABEL DT_REF nodedef
> + {
> + struct node *target = get_node_by_ref($1, $3);
> +
> + add_label(&target->labels, $2);
> + if (target)
> + merge_nodes(target, $4);
> + else
> + print_error("label or path, '%s', not found", $2);
> + $$ = $1;
> + }
> | devicetree DT_REF nodedef
> {
> struct node *target = get_node_by_ref($1, $2);
> --
> 1.7.9.5
>
> --
> 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
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] dtc: parser: Add label while overriding nodes
@ 2015-01-28 14:50 Nikhil Devshatwar
2015-01-29 10:07 ` David Gibson
0 siblings, 1 reply; 7+ messages in thread
From: Nikhil Devshatwar @ 2015-01-28 14:50 UTC (permalink / raw)
To: david, jdl; +Cc: devicetree-compiler, linux-omap, Nikhil Devshatwar
This patch changes the dtc grammar to allow following syntax
i2cexp: &i2c2 {
...
};
Current device tree compiler allows to define multiple labels when defining
the device node the first time. Typically device nodes are defined in
DTSI files. Now these nodes can be overwritten for updating some of the
properties. Typically, device nodes are overridden in DTS files.
When working with adapter boards, most of the time adapter board can fit to
multiple base boards. But depending on which base board it is connected to,
the devices on the adapter board would be children of different devices.
e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas
on dra72-evm.dts, i2c5 is exported for expansion connector.
This causes a problem when writing a generic device tree file for
the adapter board. Because, you cannot know whether all the devices on
adapter board are present on i2c or i2c5.
The problem can be solved by adding a common label (e.g. i2cexp) in both
of the DTS files when overriding the device nodes for i2c2 or i2c5.
This way, generic adapter board file would override the i2cexp. And
depending on which base board you use the adapter board, all the devices
are automatically added for correct device nodes.
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
---
dtc-parser.y | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/dtc-parser.y b/dtc-parser.y
index ea57e0a..5a897e3 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -140,6 +140,18 @@ devicetree:
{
$$ = merge_nodes($1, $3);
}
+
+ | devicetree DT_LABEL DT_REF nodedef
+ {
+ struct node *target = get_node_by_ref($1, $3);
+
+ add_label(&target->labels, $2);
+ if (target)
+ merge_nodes(target, $4);
+ else
+ ERROR(&@3, "Label or path %s not found", $3);
+ $$ = $1;
+ }
| devicetree DT_REF nodedef
{
struct node *target = get_node_by_ref($1, $2);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] dtc: parser: Add label while overriding nodes
2015-01-28 14:50 Nikhil Devshatwar
@ 2015-01-29 10:07 ` David Gibson
[not found] ` <20150129100731.GC10150-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: David Gibson @ 2015-01-29 10:07 UTC (permalink / raw)
To: Nikhil Devshatwar; +Cc: jdl, devicetree-compiler, linux-omap
[-- Attachment #1: Type: text/plain, Size: 1966 bytes --]
On Wed, Jan 28, 2015 at 08:20:11PM +0530, Nikhil Devshatwar wrote:
> This patch changes the dtc grammar to allow following syntax
>
> i2cexp: &i2c2 {
> ...
> };
>
> Current device tree compiler allows to define multiple labels when defining
> the device node the first time. Typically device nodes are defined in
> DTSI files. Now these nodes can be overwritten for updating some of the
> properties. Typically, device nodes are overridden in DTS files.
>
> When working with adapter boards, most of the time adapter board can fit to
> multiple base boards. But depending on which base board it is connected to,
> the devices on the adapter board would be children of different devices.
>
> e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas
> on dra72-evm.dts, i2c5 is exported for expansion connector.
> This causes a problem when writing a generic device tree file for
> the adapter board. Because, you cannot know whether all the devices on
> adapter board are present on i2c or i2c5.
>
> The problem can be solved by adding a common label (e.g. i2cexp) in both
> of the DTS files when overriding the device nodes for i2c2 or i2c5.
> This way, generic adapter board file would override the i2cexp. And
> depending on which base board you use the adapter board, all the devices
> are automatically added for correct device nodes.
>
> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Hi, sorry I didn't get around to responding to your earlier posting of
this.
The concept is good, and the implementation looks fine.
Only 2 things before I'm ready to merge:
1) It wants a testcase
2) I need to stare at the syntax for a while and convince myself
it's as good as we can reasonably do.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-01-29 10:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 14:12 [PATCH] dtc: parser: Add label while overriding nodes Nikhil Devshatwar
2015-01-27 15:11 ` Devshatwar, Nikhil
[not found] ` <1420726362-22555-1-git-send-email-nikhil.nd-l0cyMroinI0@public.gmane.org>
2015-01-27 23:34 ` Rob Herring
[not found] ` <CAL_Jsq+w7R=99qPc+YG_Bh1L-nMs1Gptjwo=KYTK5OX2HVVNpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-28 6:38 ` Devshatwar, Nikhil
-- strict thread matches above, loose matches on Subject: below --
2015-01-28 14:50 Nikhil Devshatwar
2015-01-29 10:07 ` David Gibson
[not found] ` <20150129100731.GC10150-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-01-29 10:13 ` David Gibson
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).