AD7606-8 not working with SPI

Hello,

I’m having problems integrating a AD7606-8 device.
It works fine when I control it using python and setting the gpios directly.
But when I try to activate the driver and use the iio-device I get a timeout when trying to read voltage data under /sys/bus/iio/devices/iio:device0 with cat in_voltage0_raw for example.

Here is the relevant part of my devicetree:

&ecspi1 {
	status = "ok";
	cs-gpios = <&gpio3 26 GPIO_ACTIVE_LOW>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>;

	adc4: adc@0 {
		status = "okay";
		compatible = "adi,ad7606-8";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_adc_colibri>;
		reg = <0>;
		spi-max-frequency = <1000000>;
		avcc-supply = <&adc_vref>;
		spi-cpol;
                //spi-cpha;
                num-channels = <8>;
                // SODIMM 133
		interrupts = <14 IRQ_TYPE_EDGE_FALLING>;
		interrupt-parent = <&gpio4>;
		// SODIMM 135
		adi,conversion-start-gpios = <&gpio1 24 GPIO_ACTIVE_HIGH>;
		// SODIMM 98
		reset-gpios = <&gpio4 26 GPIO_ACTIVE_HIGH>;
		// SODIMM 85 
		adi,first-data-gpios = <&gpio4 27 GPIO_ACTIVE_HIGH>;
		// SODIMM 103, 101, 97 ? 
		// SODIMM 79 ? 
		//standby-gpios = <&gpio4 23 GPIO_ACTIVE_LOW>;
		adi,sw-mode;
	};

	spidev0: spidev@0 {
		status = "disabled";
	};
};

		pinctrl_ecspi1_cs: ecspi1-cs-grp {
			fsl,pins = <
				MX6UL_PAD_LCD_DATA21__GPIO3_IO26	0x70a0	/* SODIMM 86 */
			>;
		};

		pinctrl_ecspi1: ecspi1-grp {
			fsl,pins = <
				MX6UL_PAD_LCD_DATA20__ECSPI1_SCLK	0x000a0	/* SODIMM 88 */
				MX6UL_PAD_LCD_DATA23__ECSPI1_MISO	0x100a0 /* SODIMM 90 */
				MX6UL_PAD_LCD_DATA22__ECSPI1_MOSI	0x000a0 /* SODIMM 92 */
			>;
		};
		
		pinctrl_adc_colibri: adc_colibri-grp {
			fsl,pins = <
				MX6UL_PAD_NAND_CE1_B__GPIO4_IO14	0x10b0 /* SODIMM 133 xxx */
				MX6UL_PAD_UART3_TX_DATA__GPIO1_IO24	0x10b0 /* SODIMM 135 xxx */
				MX6UL_PAD_CSI_DATA05__GPIO4_IO26	0x10b0 /* SODIMM 98 xxx */
				MX6UL_PAD_CSI_DATA06__GPIO4_IO27	0x10b0 /* SODIMM 85 xxx */
				MX6UL_PAD_CSI_DATA03__GPIO4_IO24	0x10b0 /* SODIMM 97 xxx */
				MX6UL_PAD_CSI_DATA00__GPIO4_IO21	0x10b0 /* SODIMM 101 xxx */
				MX6UL_PAD_CSI_DATA01__GPIO4_IO22	0x10b0 /* SODIMM 103 xxx */
				MX6UL_PAD_CSI_DATA02__GPIO4_IO23	0x10b0 /* SODIMM 79 xxx */
			>;
		};

Any ideas what could be wrong here?

Hello @doelken ,
Have you had a look at this topic in the community?

Best regards,
Josep

Sure, that was my first topic, but there I had a different problem.

As far as we could diagnose so far it seems that the SPI CS does not work.

The picture shows the signals when checking the voltage - D6 Busy, D5 Convsta, D4 First Data, D3 Reset, D0 SPI CLK, D1 should be Data and D2 is SPI CS.

Hi @doelken

According to the AD7606 documentation, there is a spi-cpha required property. Did you try to enable it?
Please refer to the documentation to check if something else is missing: adi,ad7606.yaml « adc « iio « bindings « devicetree « Documentation - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Could you please also share the kernel log (dmesg)? Sharing the kernel log after trying to read the ADC file can also be helpful.

Just for completeness, please share the following information:

  • You marked in the tags of this topic both iMX6 and iMX6ULL. Are you using both?
  • Could you please specify the full name of the module and its version?

Best regards,

Thanks for the response,
I found the problems:

First I had to use the ECSPI Macro instead of the GPIO Macro.
Then I had to change the HEX-Value for convsta to 0x50b0.
And in my case I had to comment out the adi,first-data line for the ADC.
Now it works fine.

Hi @doelken !

That’s great! Thanks for the update.

Could you please share the resulting device tree portion regarding the ADC? Sharing it will be a great contribution to the Community :slight_smile:

Best regards,