linux-device-driverembedded-linuxspidevice-tree

Warnings in DTS Linux


While I compile DTS for my device, it gives me warnings, that don't really make sense to me. There are two spi-chips on my device, their description is DTS is the following:

spi-gpio {
    compatible = "spi-gpio";
    #address-cells = <0x1>;
    ranges;
    status = "okay";

    sck-gpios   = <&pio 4 9 GPIO_ACTIVE_HIGH>;  // PE9
    mosi-gpios  = <&pio 4 6 GPIO_ACTIVE_HIGH>;  // PE6
    miso-gpios  = <&pio 4 8 GPIO_ACTIVE_HIGH>;  // PE8
    cs-gpios    = <&pio 4 4 GPIO_ACTIVE_HIGH>,  // PE4
                  <&pio 4 17 GPIO_ACTIVE_HIGH>; // PE17
    num-chipselects = <2>;

    /* Clients */
    m90e32@0 {
        reg = <0>;
        compatible = "atmel,m90e32";
        spi-max-frequency = <1000>;
        reset-gpios = <&pio 4 18 GPIO_ACTIVE_HIGH>; // PE17
    };

    m90e32@1 {
        reg = <1>;
        compatible = "atmel,m90e32";
        spi-max-frequency = <1000>;
        reset-gpios = <&pio 4 18 GPIO_ACTIVE_HIGH>; // PE17
    };
};

The warnings are:

Warning (reg_format): /spi-gpio/m90e32@0:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)

Warning (reg_format): /spi-gpio/m90e32@1:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)

I've read documentation for DTS and I've seen a similar question on SO, but it' doesn't really suit my situation. What am I missing?


Solution

  • In general, the reg property encodes an arbitrary number of (address, length) pairs. The number of <u32> cells required to encode each pair is given by the sum of the #address-cells and #size-cells properties in the parent node. The first #address-cells number of cells encodes the address, and the remaining #size-cells number of cells encodes the length, both in big-endian byte order.

    If #address-cells is not specified in the parent node, it defaults to 2.

    If #size-cells is not specified in the parent node, it defaults to 1.

    The #size-cells property can be set to 0 in the parent node to omit the length from each (address, length) pair.

    SPI and I2C devices only have a single-cell address1, and do not have a length, so the parent (controller) node should specify #address-cells=1; #size-cells=0;. Also, the ranges property in an SPI or I2C controller node has no effect on the child device nodes and can be omitted.

    spi-gpio {
        compatible = "spi-gpio";
        #address-cells = <0x1>;
        #size-cells = <0x0>;
        status = "okay";
    
        sck-gpios   = <&pio 4 9 GPIO_ACTIVE_HIGH>;  // PE9
        mosi-gpios  = <&pio 4 6 GPIO_ACTIVE_HIGH>;  // PE6
        miso-gpios  = <&pio 4 8 GPIO_ACTIVE_HIGH>;  // PE8
        cs-gpios    = <&pio 4 4 GPIO_ACTIVE_HIGH>,  // PE4
                      <&pio 4 17 GPIO_ACTIVE_HIGH>; // PE17
        num-chipselects = <2>;
    
        /* Clients */
        m90e32@0 {
            reg = <0>;
            compatible = "atmel,m90e32";
            spi-max-frequency = <1000>;
            reset-gpios = <&pio 4 18 GPIO_ACTIVE_HIGH>; // PE17
        };
    
        m90e32@1 {
            reg = <1>;
            compatible = "atmel,m90e32";
            spi-max-frequency = <1000>;
            reset-gpios = <&pio 4 18 GPIO_ACTIVE_HIGH>; // PE17
        };
    };
    

    1 Actually, SPI devices can have more than one address, but each address is encoded as single <u32> address cell with no length cell following it.