6

This code snippet comes from the device tree for the RIoTBoard (/arch/arm/boot/dts/imx6dl-riotboard.dts)

&hdmi {
         ddc-i2c-bus = <&i2c2>;
         status = "okay";
};

I have gone through the device tree documentation both on devicetree.org and in the documentation/devicetree folder of the linux kernel, but I am not able to find any description of the meaning of a phandle when used as node name.

Irr
  • 656
  • 1
  • 9
  • 19

3 Answers3

9

You can understand phandle as some kind of pointer for the node which points to the definition of that node which is either kept in the same file or the other file. I can explain phandle concept taking example from the below link for AM33xx SoC clocks file:

http://lxr.free-electrons.com/source/arch/arm/boot/dts/am33xx-clocks.dtsi

Below is the functional clock for watchdog:

wdt1_fck: wdt1_fck {
             #clock-cells = <0>;
             compatible = "ti,mux-clock";
             clocks = <&clk_rc32k_ck>, <&clkdiv32k_ick>;
             reg = <0x0538>;
};

Now wdt1_fck has two parent clocks sources: clk_rc32k_ck and clkdiv32k_ick

These are phandles or you can say pointers to their clock definitions:

clk_rc32k_ck: clk_rc32k_ck {
             #clock-cells = <0>;
             compatible = "fixed-clock";
             clock-frequency = <32000>;
};

clkdiv32k_ick: clkdiv32k_ick {
             #clock-cells = <0>;
             compatible = "ti,gate-clock";
             clocks = <&clkdiv32k_ck>;
             ti,bit-shift = <1>;
             reg = <0x014c>;
};

So basically phandle enables to use the definitions of nodes across the files.

Quokka
  • 174
  • 1
  • 3
  • 10
a.saurabh
  • 1,163
  • 10
  • 15
6

I'll answer with a example:

label:node {
  #address-cell = <1>;
  #size-cells = <0>;
}

&label {
  proporties = <2>;
};

Means:

label:node {
  #address-cell = <1>;
  #size-cells = <0>;
  proporties = <2>;
}
A Clemotte
  • 61
  • 1
  • 1
3

I think the question is more about the &hdmi part of the example, using an & reference for a node name in particular. The & in device tree files has two meanings: one for items in an array, and another for items outside an array.

  • In an array, the & reference will expand to a phandle.

  • Outside an arry, the & reference will expand to the path of the node you're referring to.

More information is available here:

https://elinux.org/Device_Tree_Mysteries#Labels

https://elinux.org/Device_Tree_Mysteries#Label_as_a_phandle_vs_Label_as_a_path

remcycles
  • 1,246
  • 13
  • 14