Linux – Meaning of an ampersand prefix in a device tree

armboot-loaderdevice-treedriverslinux-kernel

I am looking at a DTS file which tries to specify different nodes, but interestingly I find a few nodes having different style of nomenclature.

/ {
    model = "TI AM335x BeagleBone Black";
    compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
};

&ldo3_reg {
    regulator-min-microvolt = <1800000>;
    regulator-max-microvolt = <1800000>;
    regulator-always-on;
};

&mmc1 {
    vmmc-supply = <&vmmcsd_fixed>;
};

&mmc2 {
    vmmc-supply = <&vmmcsd_fixed>;
    pinctrl-names = "default";
    pinctrl-0 = <&emmc_pins>;
    bus-width = <8>;
    status = "okay";
};

/ {
    hdmi {
        compatible = "ti,tilcdc,slave";
        i2c = <&i2c0>;
        pinctrl-names = "default", "off";
        pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
        pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
        status = "okay";
    };
};

What does it convey if a node has & as its prefix? What is the necessity of separating them from root node, while they can be present in the root node itself? Interestingly, the above example also has two root nodes, how is that possible?

Best Answer

From: http://developer.toradex.com/device-tree-customization

Nodes can be referenced using the ampersand (&) character and the label.

Overwriting properties

To overwrite a property, the node needs to be referenced using the ampersand character and the label. Later device tree entries overwrite earlier entries (the sequence order of entries is what matters, hence the include order matters). Typically the higher layers (e.g. carrier board device tree) overwrite the lower layers (e.g. SoC device tree) since the higher layers include the lower layers at the very beginning.

E.g. for USB controllers which are capable to be device or host (dual-role), one can overwrite the default mode explicitly using the dr_mode property:

&usbdev0 {
    dr_mode = "host";
};
Related Question