set up ad7190 support for imx6sx SOM (device tree)

I need to set up an ad7190 IC connected to the system SPI bus using the device tree.

According my current linux kernel (4.1.15) the IC is supported by the ad7192.c driver (see [2]). I already checked the docu from AnalogDevices (see [1]).

I already configured my SPI bus including chip select (see [3]) and tested the interface successfully. Than I added the device tree node from [1] and edited the SPI and GPIO for interrupt (see [4]. Afterwards I am able to compile the kernel and run the system. But I fail to check the device in thy system, because /sys/bus/iio/devices/ is empty.

How can I debug what the problem is? Is my device tree misconfigured?

[1]:

https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7192

[2]:

$ grep ID_AD7190 drivers/staging/iio/adc/ad7192.c
#define ID_AD7190 0x4

[3]:

/* SPI_A implemented via ECSPI5, 1x CS */
&ecspi5 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_ecspi5>;
        fsl,spi-num-chipselects = <1>;
        cs-gpios = <&gpio4 28 0>;
        status = "okay";

        spidev@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "linux,spidev";
                spi-max-frequency = <20000000>;
                reg = <0>;
        };
};

[4]:

/ {

	fragment@0 {
		target-path = "/";
		dvdd: fixedregulator@0 {
			compatible = "regulator-fixed";
			regulator-name = "fixed-supply";
			regulator-min-microvolt = <3300000>;
			regulator-max-microvolt = <3300000>;
			regulator-boot-on;
		};
	};

	fragment@1 {
		target-path = "/";
		avdd: fixedregulator@1 {
			compatible = "regulator-fixed";
			regulator-name = "fixed-supply2";
			regulator-min-microvolt = <3300000>;
			regulator-max-microvolt = <3300000>;
			regulator-boot-on;
		};
	};

	fragment@3 {
		target = <&ecspi5>; /* SPI_A */
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

		ad7190@0 {
			compatible = "adi,ad7190";
			reg = <0>;
			spi-max-frequency = <1000000>;
			spi-cpol;
			spi-cpha;
			#interrupt-cells = <2>;
			interrupts = <23 0x2>;
			interrupt-parent = <&gpio4>;
			dvdd-supply = <&dvdd>;
			avdd-supply = <&avdd>;

			adi,reference-voltage-mv = /bits/ 16  <3300>;
			adi,clock-source-select = [02];
			adi,refin2-pins-enable;
			adi,rejection-60-Hz-enable;
			adi,chop-enable;
			adi,buffer-enable;
			adi,burnout-currents-enable;
			adi,sinc3-filter-enable;
			adi,unipolar-enable;
		};
	};
};

Parents Reply Children
  • Hello all,

    I am a colleague of brenkem and take this task now.

    Now we have the kernel version 4.9.88.

    At the moment I have the problem that the device ad7190 is not available at the SPI.
    I got the following error message from dmesg:

    ad7192 spi4.0: no platform data?



    I configured the kernel like under [1]


    Here is the part of my device tree. [2]

    Can you please provide me the correct device tree configuration.

    Thanks!!!

    [1]

    https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7192

    [2]

    #ifdef CONFIG_EFUSA9X_SPI_A
    /* SPI_A implemented via ECSPI5, 2x CS */
    &ecspi5 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&pinctrl_ecspi5>;
    	fsl,spi-num-chipselects = <2>;
    	cs-gpios = <&gpio4 28 0>, <&gpio4 18 0>;
    	status = "okay";
    
    
    	dvdd: fixedregulator@0 {
    		compatible = "regulator-fixed";
    		regulator-name = "fixed-supply";
    		regulator-min-microvolt = <3300000>;
    		regulator-max-microvolt = <3300000>;
    		regulator-boot-on;
    	};
    
    	avdd: fixedregulator@1 {
    		compatible = "regulator-fixed";
    		regulator-name = "fixed-supply2";
    		regulator-min-microvolt = <5000000>;
    		regulator-max-microvolt = <5000000>;
    		regulator-boot-on;
    	};
    
    
    
    	ad7192@0 {
    
    		compatible = "adi,ad7192";
    		reg = <0>;
    		spi-max-frequency = <1000000>;
    		spi-cpol;
    		spi-cpha;
    		dvdd-supply = <&dvdd>;
    		avdd-supply = <&avdd>;
    
    		adi,reference-voltage-mv = /bits/ 16  <3300>;
    		adi,clock-source-select = [02];
    		adi,refin2-pins-enable;
    		adi,rejection-60-Hz-enable;
    		adi,chop-enable;
    		adi,buffer-enable;
    		adi,burnout-currents-enable;
    		adi,sinc3-filter-enable;
    		adi,unipolar-enable;
    	};
    
    	ad7192@1 {
    		compatible = "adi,ad7192";
    		reg = <0>;
    		spi-max-frequency = <1000000>;
    		spi-cpol;
    		spi-cpha;
    		dvdd-supply = <&dvdd>;
    		avdd-supply = <&avdd>;
    
    		adi,reference-voltage-mv = /bits/ 16  <3300>;
    		adi,clock-source-select = [02];
    		adi,refin2-pins-enable;
    		adi,rejection-60-Hz-enable;
    		adi,chop-enable;
    		adi,buffer-enable;
    		adi,burnout-currents-enable;
    		adi,sinc3-filter-enable;
    		adi,unipolar-enable;
    	};
    };
    #endif /* CONFIG_EFUSA9X_SPI_A */

  • 0
    •  Analog Employees 
    on Aug 12, 2020 9:00 AM 2 months ago in reply to schmidtc

    The ad7192 driver (which controls also the ad7190 chip)  is pretty old in kernel version 4.9

    Maybe try to update to a more updated version?

    You would technically need to apply some patches from our own tree, or backport some patches from an upstream kernel.

    At around kernel 5.4 - 5.7 (I don't recall exactly), the ad7192 driver is completely upstreamed.

    In the meantime, you could update from here:

    https://github.com/analogdevicesinc/linux/blob/adi-4.9.0/drivers/staging/iio/adc/ad7192.c  [ this is on an 4.9 kernel]; but i don't think it is too update-to-date;

    you could also take directly from the 4.19 kernel:

    https://github.com/analogdevicesinc/linux/blob/adi-4.19.0/drivers/staging/iio/adc/ad7192.c

    If it doesn't behave too well, you may need to backport some parts from ad_sigma_delta.c (this is the core driver for all AD Sigma Delta drivers):

    https://github.com/analogdevicesinc/linux/blob/adi-4.19.0/drivers/iio/adc/ad_sigma_delta.c

    We do have this overlay for the Raspberry Pi for the AD7190, which also works for AD7192/AD7193:

    https://github.com/analogdevicesinc/linux/blob/rpi-4.19.y/arch/arm/boot/dts/overlays/rpi-ad7190-overlay.dts

    I remember this working on our 4.9 kernel version; but I would still suggest a newer kernel; it's hard to remember when we fixed things;