This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3358: spi slave

Part Number: AM3358

我当前将am3358内核版本升级到了linux5.10.153,看到内核对spi slave有支持,当前我们需要此功能,下面是我的spi配置

 spi0_pins_default: spi0_pins_default {
pinctrl-single,pins = <
AM33XX_IOPAD(0x950, PIN_INPUT | MUX_MODE0) /* (A17) spi0_sclk.spi0_sclk */
AM33XX_IOPAD(0x954, PIN_INPUT | MUX_MODE0) /* (B17) spi0_d0.spi0_d0 */
AM33XX_IOPAD(0x958, PIN_INPUT | MUX_MODE0) /* (B16) spi0_d1.spi0_d1 */
AM33XX_IOPAD(0x95c, PIN_INPUT | MUX_MODE0) /* (A16) spi0_cs0.spi0_cs0 */
>;
};

&spi0 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_default>;
spi-slave;
slave@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "rohm,dh2228fv";
spi-max-frequency = <24000000>;
reg = <0>;
};
};

在编译过程中出现下面错误

arch/arm/boot/dts/am33xx-l4.dtsi:1210.16-1223.6: Warning (spi_bus_bridge): /ocp/interconnect@48000000/segment@0/target-module@30000/spi@0: incorrect #address-cells for SPI bus
also defined at arch/arm/boot/dts/am335x-evm.dts:389.7-402.3
arch/arm/boot/dts/am335x-evm.dtb: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'

在测试过程中发现数据spidev0.0节点可以接收数据,但是接收到的数据打印出来都是0

麻烦帮忙看一下对于spi配置还有什么需要修改的地方

  • 设备树中有一些问题,这可能导致SPI从设备的配置不正确。需要修复一下设备树中的警告和错误,然后再检查SPI从设备的配置是否正确。

  • 我搜了一下你的spi-slave关键词,有一些参考你可以看看别的板子怎么配置的 github.com/search

  • &spi0 {
    status = "okay";
    #address-cells = <0>;
    pinctrl-names = "default";
    reg = <0>;
    pinctrl-0 = <&spi0_pins_default>;
    spi-slave;
    slave:slave@0 {
    compatible = "rohm,dh2228fv";
    spi-cpha;
    spi-max-frequency = <24000000>;
    reg = <0>;
    };
    };

    按照上面对slave模式配置,添加#address-cells = <0>;,编译还是会出现下面问题,这个是否会有影响

    + make zImage dtbs -j8
    DTC arch/arm/boot/dts/am335x-evm.dtb
    arch/arm/boot/dts/am335x-evm.dts:394.5-15: Warning (reg_format): /ocp/interconnect@48000000/segment@0/target-module@30000/spi@0:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
    arch/arm/boot/dts/am335x-evm.dts:405.11-21: Warning (reg_format): /ocp/interconnect@48000000/segment@0/target-module@30000/spi@0/slave@0:reg: property has invalid length (4 bytes) (#address-cells == 0, #size-cells == 0)
    arch/arm/boot/dts/am335x-evm.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/am335x-evm.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/am335x-evm.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
    CALL scripts/atomic/check-atomics.sh

  • 您好,感谢您分享的方法

  • 找到编译出现问题的地方了,删掉上面的reg = <0>;就可以了

  • 谢谢您的反馈