Skip to content
Advertisement

Incorrect values for #address-cells and #size-cells in Device Tree

I am trying to add a tlv320aic3110 codec to my project and I have been recommended adding these endpoints to the i2s and i2c attributes:

&i2s1 {
    ...
    i2s1_port: port {
        i2s1_endpoint: endpoint {
            remote-endpoint = <&tlv320aic3110_tx_endpoint>;
            format = "i2s";
            mclk-fs = <256>;
        };
    };
};

&i2c1 {
    ...
    codec: codec@18 {
        ...
        ports {
            port@0 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <0>;
                tlv320aic3110_tx_endpoint: endpoint {
                    remote-endpoint = <&i2s1_endpoint>;
                };
            };
        };
    };
};

The problem I’m having is that, when I build this device tree into a dtb file, I get a lot of warnings:

arch/arm/boot/dts/stm32mp135-evt0.dts:334.5-15: Warning (reg_format): /soc/i2c@40012000/codec@18/ports/port@0:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
arch/arm/boot/dts/stm32mp135-evt0.dtb: Warning (pci_device_reg): Failed prerequisite 'reg_format'
arch/arm/boot/dts/stm32mp135-evt0.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
arch/arm/boot/dts/stm32mp135-evt0.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
arch/arm/boot/dts/stm32mp135-evt0.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
arch/arm/boot/dts/stm32mp135-evt0.dts:331.11-338.6: Warning (avoid_default_addr_size): /soc/i2c@40012000/codec@18/ports/port@0: Relying on default #address-cells value
arch/arm/boot/dts/stm32mp135-evt0.dts:331.11-338.6: Warning (avoid_default_addr_size): /soc/i2c@40012000/codec@18/ports/port@0: Relying on default #size-cells value
arch/arm/boot/dts/stm32mp135-evt0.dts:332.5-26: Warning (graph_port): /soc/i2c@40012000/codec@18/ports/port@0:#address-cells: graph node '#address-cells' is -1, must be 1
arch/arm/boot/dts/stm32mp135-evt0.dts:333.5-23: Warning (graph_port): /soc/i2c@40012000/codec@18/ports/port@0:#size-cells: graph node '#size-cells' is -1, must be 0

The warnings say that the value of #address-cells is both 2 and -1, and the value of #size-cells is both 1 and -1. But I have set their value to 1 and 0, respectively, and it still gives me the warnings. Am I missing something?

I have also tried adding #address-cells and #size-cells to the endpoint in i2s, but the warning remains.

Setting them to the values mentioned in the warning also did nothing.

I’m very new to device trees, obviously.

Advertisement

Answer

But I have set their value to 1 and 0, respectively, and it still gives me the warnings. Am I missing something?

You’re trying to assign two special properties for a node in the incorrect node. The Device Tree Specification (v04-rc1) clearly states that:

The #address-cells and #size-cells properties may be used in any device node that has children in the devicetree hierarchy and describes how child device nodes should be addressed.

You’re using these two properties in a node that has no children. So that is clearly incorrect.

The parent node is where these properties need to be specified for its child nodes.
The parent of your port@0 node is the port node. So that portion of your DT should instead look like:

&i2c1 {
    ...
    codec: codec@18 {
        ...
        ports {
            #address-cells = <1>;
            #size-cells = <0>;
    
            port@0 {
                reg = <0>;
                tlv320aic3110_tx_endpoint: endpoint {
                    remote-endpoint = <&i2s1_endpoint>;
                };
            };
        };
    };
};

For a very similar example in the mainline kernel, review the &i2c5 node in stm32mp15xx-dhcom-pdk2.dtsi:

&i2c5 { /* Header X21 */
        ...

        sgtl5000: codec@a {
                compatible = "fsl,sgtl5000";
                reg = <0x0a>;
                ...

                sgtl5000_port: port {
                        #address-cells = <1>;
                        #size-cells = <0>;

                        sgtl5000_tx_endpoint: endpoint@0 {
                                reg = <0>;
                                ...
                        };

                        sgtl5000_rx_endpoint: endpoint@1 {
                                reg = <1>;
                                ...
                        };
                };

        };

        ...
};
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement