Post Go back to editing

AD7124-8 Driver Issue: Input/Output Error When Reading Raw Data

Category: Software
Product Number: AD7124-8
Software Version: Kernel 5.15

Hello AD Community,

I'm currently working with the AD7124-8 ADC on a custom board and encountering an issue. The driver loads successfully and the device tree configuration seems to be correct. However, when I attempt to read from the raw data files (e.g., /sys/bus/iio/devices/iio:device0/in_voltage11-voltage0_raw), I consistently receive an Input/output error.

Device Tree for reference:

ad7124_mclk: oscillator {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <614400>;
//clock-frequency = <8192000>;
};

adc@0 {
compatible = "adi,ad7124-8";
reg = <0>;
spi-max-frequency = <5000000>;
interrupts = <25 2>;
interrupt-parent = <&gpio5>;
clocks = <&ad7124_mclk>;
clock-names = "mclk";
syncreset-gpios = <&pca9539 15 GPIO_ACTIVE_HIGH>;

spi-cpol;
spi-cpha;

#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
diff-channels = <0 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@1 {
reg = <1>;
diff-channels = <1 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@2 {
reg = <2>;
diff-channels = <2 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@3 {
reg = <3>;
diff-channels = <3 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@4 {
reg = <4>;
diff-channels = <4 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@5 {
reg = <5>;
diff-channels = <5 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@6 {
reg = <6>;
diff-channels = <6 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@7 {
reg = <7>;
diff-channels = <7 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@8 {
reg = <8>;
diff-channels = <8 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@9 {
reg = <9>;
diff-channels = <9 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@10 {
reg = <10>;
diff-channels = <10 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@11 {
reg = <11>;
diff-channels = <11 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@12 {
reg = <12>;
diff-channels = <12 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@13 {
reg = <13>;
diff-channels = <13 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@14 {
reg = <14>;
diff-channels = <14 0>;
bipolar = <0>;
adi,buffered-positive;
};

channel@15 {
reg = <15>;
diff-channels = <15 0>;
bipolar = <0>;
adi,buffered-positive;
};
};
};

Observations:

The driver initializes successfully

Despite successful initialization, attempting to read the raw data from the ADC input channels results in an Input/output error.

root@target:/sys/bus/iio/devices/iio:device0# cat in_voltage11-voltage0_raw
cat: in_voltage11-voltage0_raw: Input/output error

Request:

I’m seeking advice on what could be causing this issue. Is there something specific in the configuration or hardware setup that I might be missing? Any guidance or suggestions for additional debugging steps would be greatly appreciated.

Thank you in advance for your support.

Parents
  • Hi  ,

    You can check this example ad7124-4 device tree where the channels used are single-ended: https://github.com/analogdevicesinc/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/rpi-ad7124-overlay.dts

    /dts-v1/;
    /plugin/;
    
    / {
    	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
    
    	fragment@0 {
    		target-path = "/";
    		__overlay__ {
    			vref: fixedregulator@0 {
    				compatible = "regulator-fixed";
    				regulator-name = "fixed-supply";
    				regulator-min-microvolt = <2500000>;
    				regulator-max-microvolt = <2500000>;
    				regulator-boot-on;
    			};
    		};
    	};
    
    	fragment@1 {
    		target-path = "/";
    		__overlay__ {
    			clocks {
    				ad7124_mclk: clock@0 {
    					#clock-cells = <0>;
    					compatible = "fixed-clock";
    					clock-frequency = <614400>;
    				};
    			};
    		};
    	};
    
    	fragment@2 {
    		target = <&spi0>;
    		__overlay__ {
    			#address-cells = <1>;
    			#size-cells = <0>;
    			status = "okay";
    
    			ad7124@0 {
    				compatible = "adi,ad7124-4";
    				reg = <0>;
    				spi-max-frequency = <5000000>;
    				interrupts = <25 2>;
    				interrupt-parent = <&gpio>;
    				refin1-supply = <&vref>;
    				clocks = <&ad7124_mclk>;
    				clock-names = "mclk";
    
    				#address-cells = <1>;
    				#size-cells = <0>;
    
    				channel@0 {
    					reg = <0>;
    					diff-channels = <0 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@1 {
    					reg = <1>;
    					diff-channels = <1 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@2 {
    					reg = <2>;
    					diff-channels = <2 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@3 {
    					reg = <3>;
    					diff-channels = <3 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@4 {
    					reg = <4>;
    					diff-channels = <4 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@5 {
    					reg = <5>;
    					diff-channels = <5 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@6 {
    					reg = <6>;
    					diff-channels = <6 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@7 {
    					reg = <7>;
    					diff-channels = <7 19>;
    					adi,reference-select = <0>;
    				};
    			};
    		};
    	};
    
    	fragment@3 {
    		target = <&spidev0>;
    		__overlay__ {
    			status = "disabled";
    		};
    	};
    
    	fragment@4 {
    		target = <&spidev1>;
    		__overlay__ {
    			status = "disabled";
    		};
    	};
    };

    Note that to be able to create the single-ended channels, each ADC channel was paired with channel 19, which is a ground. And also note that this device tree example is compatible with the AD7124-4 which only has 4 channels. You can just adjust the number of channels for your AD7124-8.

    You can try to edit your existing device tree and let us know if this works for you.

    Regards,
    Andy

Reply
  • Hi  ,

    You can check this example ad7124-4 device tree where the channels used are single-ended: https://github.com/analogdevicesinc/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/rpi-ad7124-overlay.dts

    /dts-v1/;
    /plugin/;
    
    / {
    	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
    
    	fragment@0 {
    		target-path = "/";
    		__overlay__ {
    			vref: fixedregulator@0 {
    				compatible = "regulator-fixed";
    				regulator-name = "fixed-supply";
    				regulator-min-microvolt = <2500000>;
    				regulator-max-microvolt = <2500000>;
    				regulator-boot-on;
    			};
    		};
    	};
    
    	fragment@1 {
    		target-path = "/";
    		__overlay__ {
    			clocks {
    				ad7124_mclk: clock@0 {
    					#clock-cells = <0>;
    					compatible = "fixed-clock";
    					clock-frequency = <614400>;
    				};
    			};
    		};
    	};
    
    	fragment@2 {
    		target = <&spi0>;
    		__overlay__ {
    			#address-cells = <1>;
    			#size-cells = <0>;
    			status = "okay";
    
    			ad7124@0 {
    				compatible = "adi,ad7124-4";
    				reg = <0>;
    				spi-max-frequency = <5000000>;
    				interrupts = <25 2>;
    				interrupt-parent = <&gpio>;
    				refin1-supply = <&vref>;
    				clocks = <&ad7124_mclk>;
    				clock-names = "mclk";
    
    				#address-cells = <1>;
    				#size-cells = <0>;
    
    				channel@0 {
    					reg = <0>;
    					diff-channels = <0 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@1 {
    					reg = <1>;
    					diff-channels = <1 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@2 {
    					reg = <2>;
    					diff-channels = <2 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@3 {
    					reg = <3>;
    					diff-channels = <3 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@4 {
    					reg = <4>;
    					diff-channels = <4 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@5 {
    					reg = <5>;
    					diff-channels = <5 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@6 {
    					reg = <6>;
    					diff-channels = <6 19>;
    					adi,reference-select = <0>;
    				};
    
    				channel@7 {
    					reg = <7>;
    					diff-channels = <7 19>;
    					adi,reference-select = <0>;
    				};
    			};
    		};
    	};
    
    	fragment@3 {
    		target = <&spidev0>;
    		__overlay__ {
    			status = "disabled";
    		};
    	};
    
    	fragment@4 {
    		target = <&spidev1>;
    		__overlay__ {
    			status = "disabled";
    		};
    	};
    };

    Note that to be able to create the single-ended channels, each ADC channel was paired with channel 19, which is a ground. And also note that this device tree example is compatible with the AD7124-4 which only has 4 channels. You can just adjust the number of channels for your AD7124-8.

    You can try to edit your existing device tree and let us know if this works for you.

    Regards,
    Andy

Children