diff mbox

dtc: parser: Add label while overriding nodes

Message ID 1420726362-22555-1-git-send-email-nikhil.nd@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nikhil Devshatwar Jan. 8, 2015, 2:12 p.m. UTC
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(+)

Comments

Nikhil Devshatwar Jan. 27, 2015, 3:11 p.m. UTC | #1
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

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rob Herring Jan. 27, 2015, 11:34 p.m. UTC | #2
On Thu, Jan 8, 2015 at 8:12 AM, Nikhil Devshatwar <nikhil.nd@ti.com> 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@ti.com>
> ---
>  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@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nikhil Devshatwar Jan. 28, 2015, 6:38 a.m. UTC | #3
> -----Original Message-----

> From: Rob Herring [mailto:robherring2@gmail.com]

> Sent: Wednesday, January 28, 2015 5:05 AM

> To: Devshatwar, Nikhil

> Cc: devicetree-compiler@vger.kernel.org; devicetree@vger.kernel.org;

> devicetree-spec@vger.kernel.org; linux-omap

> Subject: Re: [PATCH] dtc: parser: Add label while overriding nodes

> 

> On Thu, Jan 8, 2015 at 8:12 AM, Nikhil Devshatwar <nikhil.nd@ti.com>

> 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@ti.com>

> > ---

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

> 


OK, no problem

Thanks,
Nikhil D

> > 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@vger.kernel.org More majordomo

> > info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);