Can't read data from AD7793 with Linux driver

I have a similar problem.

{
.modalias = "ad7793",
.max_speed_hz = 1000000,
.bus_num = 0,
.chip_select = 0,
.platform_data = &ad7793_pdata,
.mode = SPI_MODE_3,
.irq = gpio_to_irq(9), // Raspberry Pi SPI0_MISO is GPIO9.
}

cat /sys/bus/iio/devices/iio\:device0/name

I get "ad7793".

But 

cat in_voltage0-voltage0_raw // connect 0.5v

cat in_voltage1-voltage1_raw // null

cat in_voltage2-voltage2_raw // null

I always get the same thing(7502040).

Parents
  • Raspberry Pi 2 B/Linux kernel 4.9.x:

    I use

    linux/ad7793.c at xcomm_zynq_4_9 · analogdevicesinc/linux · GitHub 

    and ad7793-overlay.dts.

    /*
    * Device Tree overlay for ad7793
    *
    */

    /dts-v1/;
    /plugin/;

    / {
    compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

    fragment@0 {
    target = <&spi0>;
    __overlay__ {
    status = "okay";
    };
    };

    fragment@1 {
    target = <&spidev0>;
    __overlay__ {
    status = "disabled";
    };
    };

    fragment@2 {
    target = <&spidev1>;
    __overlay__ {
    status = "disabled";
    };
    };

    fragment@3 {
    target = <&gpio>;
    __overlay__ {
    ad7793_pins: ad7793_pins {
    brcm,pins = <25>;
    brcm,function = <0>;
    brcm,pull = <2>;
    };
    };
    };

    fragment@4 {
    target = <&spi0>;
    __overlay__ {
    /* needed to avoid dtc warning */
    #address-cells = <1>;
    #size-cells = <0>;

    ad7793: ad-7793@0{
    compatible = "adi,ad7793";
    reg = <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&ad7793_pins>;

    spi-max-frequency = <1000000>;
    interrupts = <25 2>; /* high-to-low edge triggered */
    interrupt-parent = <&gpio>;
    };
    };
    };
    };

    I get 

    ad7793 spi0.0:device ID query failed

    ad7793 spi0.0:setup failed

    I don't know how to solve.

Reply
  • Raspberry Pi 2 B/Linux kernel 4.9.x:

    I use

    linux/ad7793.c at xcomm_zynq_4_9 · analogdevicesinc/linux · GitHub 

    and ad7793-overlay.dts.

    /*
    * Device Tree overlay for ad7793
    *
    */

    /dts-v1/;
    /plugin/;

    / {
    compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

    fragment@0 {
    target = <&spi0>;
    __overlay__ {
    status = "okay";
    };
    };

    fragment@1 {
    target = <&spidev0>;
    __overlay__ {
    status = "disabled";
    };
    };

    fragment@2 {
    target = <&spidev1>;
    __overlay__ {
    status = "disabled";
    };
    };

    fragment@3 {
    target = <&gpio>;
    __overlay__ {
    ad7793_pins: ad7793_pins {
    brcm,pins = <25>;
    brcm,function = <0>;
    brcm,pull = <2>;
    };
    };
    };

    fragment@4 {
    target = <&spi0>;
    __overlay__ {
    /* needed to avoid dtc warning */
    #address-cells = <1>;
    #size-cells = <0>;

    ad7793: ad-7793@0{
    compatible = "adi,ad7793";
    reg = <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&ad7793_pins>;

    spi-max-frequency = <1000000>;
    interrupts = <25 2>; /* high-to-low edge triggered */
    interrupt-parent = <&gpio>;
    };
    };
    };
    };

    I get 

    ad7793 spi0.0:device ID query failed

    ad7793 spi0.0:setup failed

    I don't know how to solve.

Children
No Data