Hello!
I am trying to implement SPI driver for AD7606 (AD7606BSTZ) on Raspberry Pi 4B . The kernel v5.10.83 was build with support of AD7606_SPI driver as module. The chip is wired as it shown spec. During my tries to read data (in sys/bus/iio/deviceX/input_voltageY_raw) or test driver with iio_info command I am getting error "Input/output error (5)" or "Connection timed out (110)". I guess this is because there is mistake in device tree overlay. It is my first experience of implementing driver thus for me not all properties are clear. So need your support.
The device tree overlay is below:
/dts-v1/;
/plugin/;
#include </home/pi/Desktop/linux_master_5.10_depth=1/include/dt-bindings/gpio/gpio.h>
#include </home/pi/Desktop/linux_master_5.10_depth=1/include/dt-bindings/interrupt-controller/irq.h>
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@1 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
adc0: adc@0 {
compatible = "adi,ad7606-8";
reg = <0>;
spi-max-frequency = <10000>;
spi-cpol;
spi-cpha;
avcc-supply = <&vdd_5v0_reg>;
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;
};
};
};
};
And reverted DT overlay is below(the part for SPI):
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 >;
avcc-supply = < 0xe2 >;
standby-gpios = < 0x07 0x18 0x01 >;
reg = < 0x00 >;
adi,sw-mode;
spi-max-frequency = < 0x2710 >;
};
spidev@1 {
compatible = "spidev";
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
phandle = < 0xb0 >;
reg = < 0x01 >;
spi-max-frequency = < 0x7735940 >;
};
spidev@0 {
compatible = "spidev";
status = "disabled";
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
phandle = < 0xaf >;
reg = < 0x00 >;
spi-max-frequency = < 0x7735940 >;
};
};
At this moment questions are:
- I am not sure that I wrote "avcc-supply" correct. What is "avcc-supply" property mean? There are few words about this.
- Has "adi,conversion-start-gpios" to be really GPIO_ACTIVE_HIGH?
- This question more about raspberry but anyway if you give advice about this I would be happy: how to determine correct GPIO pin numbers in device tree properties. I used BCM2711 gpio numbers (like &gpio 22) but I am not sure that this is correct.