Search code examples
memorydevice-tree

Meaning of declaration of Memory map in flattened device tree


I have declaration for memory map as follows:

memory@40000000 {
    device_type = "memory";
    reg = <0 0x40000000 0 0x20000000>;
};

memory@200000000 {
    device_type = "memory";
    reg = <2 0x00000000 0 0x20000000>;
};

What is the meaning of each number in reg (base size) ?


Solution

  • The two statements

    reg = <0 0x40000000 0 0x20000000>;
    reg = <2 0x00000000 0 0x20000000>;
    

    mean, that a 64bit addressing scheme is used. However, each number in a device tree 'cell' represents a 32bit field. Thus, the numbers have to be read together as:

    Addr: 0x040000000 Size: 0x020000000
    Addr: 0x200000000 Size: 0x020000000
    

    Thus, you have two 512MiB RAM ranges at two distinct address segments.

    Please look for a declaration in your dts/dtsi file like:

    #address-cells = <2>;
    #size-cells = <2>;