linux-kernellinux-device-driverdevice-tree

What is reg property in device tree?


What is address-cell and size-cells in the device tree? Is reg is related to address-cell and size-cell? If yes, then how?

For example:

memory: memory@20000000 { 
            #address-cells = <1>;
            #size-cells = <1>;
            device_type = "memory";
            reg = <0x20000000 0x80000000>;
    };

What is 0x20000000 ? from where we can get this ?


Solution

  • The meaning of reg depends on the type of bus the device is connected to and is documented in the device tree binding for the bus.

    Here, memory is directly mapped in the CPU address space and reg is <address size>.

    So, this means that your DDR is starts at address 0x20000000 and has a size of 2GB.

    This address is supposed to be documented in the SoC datasheet if you can get it, in a sections that is named memories or memory maps.