linux-device-driverdevice-tree

Device tree override reg value


I have a device tree that I want to override some node's reg value. The problem is that my understanding the name of the node has to match the reg value. How can this node's reg change without overriding the parent node.

Example:

\{

parent_name : parent {
   n10 : node@10 {
       reg = <10>;
  };

   n100 : node@100 {
      reg = <100>;
   };
};

To override node@100 to have a different reg value, can this be done:

&n100 {
  reg = <200>;
}

If this is done, the reg of node@100 will be 200 which is not what the specs says.


Solution

  • the name of the node has to match the reg value

    Correct, the Device Tree Specification does mention this requirement.

    You should not try to "redefine" the reg property which would create a discrepancy.
    Rather you could create a whole new node with the proper node name & unit address.

    You can delete the old node using

    /delete-node/ node@100;
    

    or

    /delete-node/ &n100;
    

    Note that /delete-node/ is a directive to the DT compiler, and is not some kind of comment.
    Refer to Device Tree Source Undocumented for more details.