Search code examples
linux-kernelraspberry-pi4device-tree

Device tree phandle hex to reference node


Is it possible to derive the reference node from a phandle?

For example, my RPI 4 has this:

mmcnr@7e300000 {
    compatible = "brcm,bcm2835-mmc\0brcm,bcm2835-sdhci";
    reg = <0x7e300000 0x100>;
    interrupts = <0x00 0x7e 0x04>;
    clocks = <0x07 0x1c>;
    dmas = <0x0b 0x0b>;
    dma-names = "rx-tx";
    brcm,overclock-50 = <0x00>;
    non-removable;
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <0x1f>;
    bus-width = <0x04>;
    phandle = <0x38>;
};

How do I know what node 0x38 is?


Solution

  • You can iterate through all the nodes using of_find_all_nodes() starting by passing parameter to this function as NULL. This function returns device_node .. You can compare the returned device_node->phandle with 0x38, if it matches. That is the node