Post Go back to editing

AD7904 returns "Input/Output Error" for all connected voltage lines (Using AD7923 Driver)

I've been spending a few days trying to get this kernel module hooked up properly, and I'm running out of options on the software front.

Here is the output from the command line. I get "Invalid argument" for scale, and "Input/Output Error" for all the adc lines except voltage0 returns 0 but that line isn't hooked up to anything.

:~# cat /sys/bus/iio/devices/iio\:device0/name
ad7904
:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale
cat: '/sys/bus/iio/devices/iio:device0/in_voltage_scale': Invalid argument
:~# cat /sys/bus/iio/devices/iio\:device0/
buffer/                  dev                      in_voltage1_raw          in_voltage3_raw          name                     power/                   subsystem/               uevent
current_timestamp_clock  in_voltage0_raw          in_voltage2_raw          in_voltage_scale         of_node/                 scan_elements/           trigger/
:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
0
:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw
cat: '/sys/bus/iio/devices/iio:device0/in_voltage1_raw': Input/output error
:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage2_raw
cat: '/sys/bus/iio/devices/iio:device0/in_voltage2_raw': Input/output error
:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage3_raw
cat: '/sys/bus/iio/devices/iio:device0/in_voltage3_raw': Input/output error

This is my device tree:

&quad_spi {
	#address-cells = <2>;
	#size-cells = <0>;

	gpiom2: gpio@0 {
			compatible = "microchip,mcp23s17";
			gpio-controller;
			#gpio-cells = <2>;
			microchip,spi-present-mask = <0x02>;
			reg = <0>;
			spi-max-frequency = <1000000>;
		};

	adc_supply: fixedregulator {
		compatible = "regulator-fixed";
		regulator-name = "fixed-supply";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
	};

	adc_vref: fixedregulator {
		compatible = "regulator-fixed";
		regulator-name = "fixed-supply";
		regulator-min-microvolt = <2500000>;
		regulator-max-microvolt = <2500000>;
	};

	ad7904: ad7904@1 {
			compatible = "adi,ad7904";
			reg = <1>;
			spi-max-frequency = <1000000>;
			spi-cpha;
			spi-cpol;
			vcc-supply = <&adc_supply>;
			vref-supply = <&adc_vref>;
		};
};

This is my first time dealing with device tree. The gpioe works already and this ADC is on the same spi bus.

The AD7904 uses the AD7923 driver, but there is no documentation for this one, only a git source. I've been looking at other drivers similar and trying to make the device tree properly.

Any and all advice would be appreciated. I'm asking our EE if there is a line I can probe easily for chip-select and will update on whether its toggling.

Parents
  •  Your author of the driver. Has this been tested for all 4 models?

    I'm running out of ideas besides the driver just crapping out. I probed all the lines and they work! I see data coming to and from the part and the cs going low. However, the driver will always EIO, which only seems to appear if the address pins are wrong but how can that be?

  • Reading scale returns error since the regulator issn't connected.

    Can you check if you kernel is CONFIG_REGULATOR_FIXED_VOLTAGE enabled?

    Regarding -EIO on raw reads, this can only be related to read the data via SPI.

    Can you add this debug print and read all channels:

    pr_err("%s:%d: ret = 0x%X", __func__, __LINE__, ret;)
    
    if (chan->address == EXTRACT(ret, 12, 4))
        *val = EXTRACT(ret, 0, 12);
    else
        return -EIO;
     

    -Michael

  • HI Michael! First off thank you for responding.

    I went into the config and added 

    CONFIG_REGULATOR_FIXED_VOLTAGE=y
    However, now it screams
    [ 14.099833] spi_master spi5: /amba_pl@0/axi_quad_spi@80100000/fixedregulator has no valid 'reg' property (-22)
    [ 14.104209] spi_master spi5: Failed to create SPI device for /amba_pl@0/axi_quad_spi@80100000/fixedregulator
    in_voltage_scale still throws the same error. The regulator inclusion is just based on the example device trees I've seen in the wiki but not sure if actually needed? Vref is connected 2.5v line but not a configurable regulator of any sort.
    As for the prints on debugging, currently working on that. Problem is I work on a propriety skew of linux so finding where the "actual kernel" files are have been difficult.
Reply
  • HI Michael! First off thank you for responding.

    I went into the config and added 

    CONFIG_REGULATOR_FIXED_VOLTAGE=y
    However, now it screams
    [ 14.099833] spi_master spi5: /amba_pl@0/axi_quad_spi@80100000/fixedregulator has no valid 'reg' property (-22)
    [ 14.104209] spi_master spi5: Failed to create SPI device for /amba_pl@0/axi_quad_spi@80100000/fixedregulator
    in_voltage_scale still throws the same error. The regulator inclusion is just based on the example device trees I've seen in the wiki but not sure if actually needed? Vref is connected 2.5v line but not a configurable regulator of any sort.
    As for the prints on debugging, currently working on that. Problem is I work on a propriety skew of linux so finding where the "actual kernel" files are have been difficult.
Children