8

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 ?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Pankaj Suryawanshi
  • 681
  • 1
  • 9
  • 23

1 Answers1

7

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.

Alexandre Belloni
  • 2,244
  • 13
  • 12
  • What is address cells and size cells ? – Pankaj Suryawanshi Jun 20 '19 at 15:43
  • There are not useful and should not be used because memory is not a bus. It would give the number of address cells and number of size cells for the reg property of child nod of a bus. – Alexandre Belloni Jun 21 '19 at 10:29
  • Then why address-cells and size-cells = <1> or <0> or <2>. different values – Pankaj Suryawanshi Jun 21 '19 at 11:34
  • 8
    @PankajSuryawanshi All numbers in the device tree are 32-bit. `#address-cells = <1>;` means the address consists of a single 32-bit number in the `reg` property. `#size-cells = <1>;` means the size consists of a single 32-bit number in the `reg` property. The `reg` property contains the address cells in big-endian order, followed by the size cells in big-endian order. So if `#address-cells = <2>; #size-cells = <2>;`, then the `reg` property would contain 4 values: `reg = ;`. – Ian Abbott Jun 25 '19 at 15:41