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 dreamer21,

    Since the driver initialized there seems to be no problem in regards to the SPI bus.
    Because the issue arises when reading samples one-by-one (reading from in_voltage11-voltage0_raw
    triggers a single conversion) and the error is Input/output the problem should be with the setup of
    interrupts.

    To check if the interrupt is registered and they are getting triggered you can look at /proc/interrupts.

    Example from raspberry pi 3:

    root@analog:~# cat /proc/interrupts
               CPU0       CPU1       CPU2       CPU3
    [...]
    199:       1115          0          0          0  pinctrl-bcm2835  19 Edge      ad7124-8


    Could you please check if you are getting any interrupts triggered when reading from that file?

  • Hi Dumitru,

    Thanks for your response.

    I am not getting any interrupts while reading any of the files.

    Where is the interrupt line connected? Is it in DOUT/RDY?

    How to configure the interrupt in Device Tree?

    Current DT entries for interrupt:

    interrupts = <25 2>;
    interrupt-parent = <&gpio5>;

Reply Children
  •    The interrupt line you can say is "multiplexed" with the DOUT SPI pin, hence the "DOUT/RDY" naming.
    Usually the MISO or DOUT SPI pin from the processor does not not support to also register interrupts 
    so it will be necessary to connect DOUT/RDY to another pin as well.

        To configure the interrupt in the device tree you need to specify the desired GPIO pin in the first position
    of the "interrupts" property, the second number just specifies the type of interrupt (here, 2 selects falling edge).

       Since the interrupt was configured and appears registered in /proc/interrupts, the hardware connections must
    be at fault. You will need to also connect the DOUT/RDY pin from the ADC to GPIO 25.
    (or select a different GPIO pin "interrupts = <x 2>" and connect DOUT/RDY to GPIO x as well)

  • Ok,

    Let me spend some time on this and get back to you.

    Thanks for your input this is helpful.