4

Following is the code snippet in a device tree file:

flash@0 {
                compatible = "n25q128";
                reg = <0x0>;
                spi-max-frequency = <50000000>;
                #address-cells = <1>;
                #size-cells = <1>;
                partition@qspi-fsbl-uboot {
                    label = "qspi-fsbl-uboot";
                    reg = <0x0 0x100000>;
                };
                partition@qspi-linux {
                    label = "qspi-linux";
                    reg = <0x100000 0x500000>;
                };
                partition@qspi-device-tree {
                    label = "qspi-device-tree";
                    reg = <0x600000 0x20000>;
                };
                partition@qspi-rootfs {
                    label = "qspi-rootfs";
                    reg = <0x620000 0x5E0000>;
                };
                partition@qspi-bitstream {
                    label = "qspi-bitstream";
                    reg = <0xC00000 0x400000>;
                };
            };

My simple question is what are the two values in < >? for example in reg = <0x600000 0x20000>;

I thought it is initial and final address , but this will be meaning less here since final cannot be lower than initial.

  • Given the values, I'd bet for <offset length>. – Stéphane Chazelas Mar 25 '14 at 14:07
2

Angle brackets (<>) denotes a "32-bit unsigned integer array" and I believe they are often refereed to as "cells". In the case with the reg property, the first value is the (offset) address and the second the length of the register(s). Note that it is also possible to have multiple ranges i.e.

reg = <addr1 addr1_length addr2 addr2_length  ... addrN addrN_length>

Sources:

1

It does not have to be just two numbers in general

Furthermore, as explained at: https://elinux.org/Device_Tree_Usage#How_Addressing_Works it does not have to be just two numbers each.

E.g., in 64 bit devices, we often have:

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

which implies address and offset are of type:

reg = <0x1 0x2 0x3 0x4>

which represents a region with:

  • base address: 00000001 00000002 (composed of 2 32-bit numbers due to #address-cells = <2>;)
  • length: 00000003 00000004 (composed of 2 32-bit numbers due to #size-cells = <2>;)

This is because each number in the device tree is 32-bit wide by definition, so we need two for each 64 bit value.

0

Yes, the reg<0xxxx 0xxxx> stands for reg<offset length>.

offset is the base address of the device and length will determine the range of address of the given device.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.