0

我正在尝试在 Raspberry Pi 4B+ 上实现适用于 Linux 的 ADC AD7606 设备驱动程序,以便通过 SPI 尽可能快地从所有通道读取数据。内核版本为 v5.10.83,编译和安装内核时支持 AD7606 和 AD7606_SPI 作为模块 ( make menuconfig)。

设备树覆盖是通过使用 Analog Devices https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7606上的示例创建的,现在是这样的:

/dts-v1/;
/plugin/;

#include <../include/dt-bindings/gpio/gpio.h>
#include <../include/dt-bindings/interrupt-controller/irq.h>

/ {
    compatible = "brcm,bcm2835";
    fragment@0 {
    target = <&spi0>;
    __overlay__ {
        #address-cells = <1>;
        #size-cells = <0>;
        adc0: adc@0 {
            compatible = "adi,ad7606-8";
            reg = <0>;
            spi-max-frequency = <1000000>;
            spi-cpol;
            spi-cpha;

            interrupts = <25 IRQ_TYPE_EDGE_FALLING>;
            interrupt-parent = <&gpio>;
            adi,conversion-start-gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
            reset-gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
            adi,first-data-gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
            adi,oversampling-ratio-gpios = <&gpio 18 GPIO_ACTIVE_HIGH>,
                                           <&gpio 23 GPIO_ACTIVE_HIGH>,
                                           <&gpio 26 GPIO_ACTIVE_HIGH>;
            standby-gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
            adi,sw-mode;
            };
    
        };
    };
};

覆盖在/boot/config.txt中激活, SPI 的还原 DT 部分如下所示:

spi@7e204000 {
            compatible = "brcm,bcm2835-spi";
            clocks = < 0x08 0x14 >;
            status = "okay";
            #address-cells = < 0x01 >;
            interrupts = < 0x00 0x76 0x04 >;
            cs-gpios = < 0x07 0x08 0x01 0x07 0x07 0x01 >;
            #size-cells = < 0x00 >;
            dma-names = "tx\0rx";
            phandle = < 0x33 >;
            reg = < 0x7e204000 0x200 >;
            pinctrl-0 = < 0x0e 0x0f >;
            dmas = < 0x0c 0x06 0x0c 0x07 >;
            pinctrl-names = "default";

            adc@0 {
                spi-cpol;
                compatible = "adi,ad7606-8";
                adi,conversion-start-gpios = < 0x07 0x11 0x00 >;
                spi-cpha;
                adi,first-data-gpios = < 0x07 0x16 0x00 >;
                adi,oversampling-ratio-gpios = < 0x07 0x12 0x00 0x07 0x17 0x00 0x07 0x1a 0x00 >;
                interrupt-parent = < 0x07 >;
                interrupts = < 0x19 0x02 >;
                reset-gpios = < 0x07 0x1b 0x00 >;
                phandle = < 0xe9 >;
                standby-gpios = < 0x07 0x18 0x01 >;
                reg = < 0x00 >;
                adi,sw-mode;
                spi-max-frequency = < 0xf4240 >;
            };

            spidev@1 {
                compatible = "spidev";
                #address-cells = < 0x01 >;
                #size-cells = < 0x00 >;
                phandle = < 0xb0 >;
                reg = < 0x01 >;
                spi-max-frequency = < 0x7735940 >;
            };

            spidev@0 {
                compatible = "spidev";
                #address-cells = < 0x01 >;
                #size-cells = < 0x00 >;
                phandle = < 0xaf >;
                reg = < 0x00 >;
                spi-max-frequency = < 0x7735940 >;
            };
        };

在激活此覆盖的内核启动期间,我收到内核消息:

[    5.171792] spi-bcm2835 fe204000.spi: chipselect 0 already in use
[    5.171827] spi_master spi0: spi_device register error /soc/spi@7e204000/spidev@0
[    5.171861] spi_master spi0: Failed to create SPI device for /soc/spi@7e204000/spidev@0

如何解决此问题或进行故障排除?

4

0 回答 0