platform_external_dtc/tests/test_tree1_label_noderef.dts
Nikhil Devshatwar 3346e065aa dtc: parser: Add label while overriding nodes
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>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-02-23 12:29:36 +11:00

55 lines
873 B
Text

/dts-v1/;
/memreserve/ 0xdeadbeef00000000 0x100000;
/memreserve/ 123456789 010000;
/ {
compatible = "test_tree1";
prop-int = <0xdeadbeef>;
prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
prop-str = "hello world";
#address-cells = <1>;
#size-cells = <0>;
subnode@1 {
compatible = "subnode1";
reg = <1>;
prop-int = [deadbeef];
subsubnode {
compatible = "subsubnode1", "subsubnode";
prop-int = <0xdeadbeef>;
};
ss1 {
};
};
subnode@2 {
reg = <2>;
linux,phandle = <0x2000>;
prop-int = <123456789>;
#address-cells = <1>;
#size-cells = <0>;
ssn0: subsubnode@0 {
phandle = <0x2001>;
prop-int = <0xbad>;
};
ss2 {
};
};
};
/* Add label to a noderef */
ssn1: &ssn0 {
reg = <0>;
prop-int = <123456789>;
};
/* Use the new label for merging */
&ssn1 {
prop-int = <0726746425>;
compatible = "subsubnode2", "subsubnode";
};