AnsweredAssumed Answered

AD7791 iio driver and device tree entry

Question asked by GrzegorzBieszczad on Nov 29, 2017
Latest reply on Dec 20, 2017 by Kla

Hi,

I'm developing system with AD7791 running under custom linux system. I'm building on buildroot version 2017.02.1 with linux kernel 4.9.13.

I have configured spi hardware support, IIO support and AD7791 driver. most significant configs in regard to spi and iio are shown below:

CONFIG_SPI=y
CONFIG_SPI_DEBUG=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_DESIGNWARE=y
CONFIG_SPI_DW_MMIO=y

 

CONFIG_IIO=y
CONFIG_IIO_BUFFER=y
# CONFIG_IIO_BUFFER_CB is not set
CONFIG_IIO_KFIFO_BUF=y
CONFIG_IIO_TRIGGERED_BUFFER=y
CONFIG_IIO_CONFIGFS=y
CONFIG_IIO_TRIGGER=y
CONFIG_IIO_CONSUMERS_PER_TRIGGER=2
CONFIG_IIO_SW_DEVICE=y
# CONFIG_IIO_SW_TRIGGER is not set

 

CONFIG_AD_SIGMA_DELTA=y

CONFIG_AD7791=y

I don't use boardconfig (or whatever it was called) but device tree. I have made dts entry like that:

        hps_spim0: spi@0xfff00000 {
            compatible = "snps,dw-spi-mmio-17.0", "snps,dw-spi-mmio", "snps,dw-apb-ssi";
            reg = <0xfff00000 0x00000100>;
            interrupt-parent = <&hps_arm_gic_0>;
            interrupts = <0 154 4>;
            clocks = <&spi_m_clk>;
            #address-cells = <1>;    /* embeddedsw.dts.params.#address-cells type NUMBER */
            #size-cells = <0>;    /* embeddedsw.dts.params.#size-cells type NUMBER */
            //bus-num = <0>;    /* embeddedsw.dts.params.bus-num type NUMBER */
            num-chipselect = <4>;    /* embeddedsw.dts.params.num-chipselect type NUMBER */
            status = "okay";    /* embeddedsw.dts.params.status type STRING */
            
               VtempADC@0 {
                compatible="adi,ad7791";
                status = "okay";
                reg = <0>; //chipselect
                spi-max-frequency= <5000000>;
                //bus-num = <0>;
                spi-cpha;
                spi-cpol;
                vref-supply = <&adc_vref>;
                vcc-supply = <&adc_supply>;
               };

...

my system detects 2 spi devices:

dmesg | grep spi
[    0.701451] dw_spi_mmio fff00000.spi: Detected FIFO size: 256 bytes
[    0.701705] dw_spi_mmio fff00000.spi: registered master spi32766 (dynamic)
[    0.702513] spi spi32766.0: setup mode 3, 8 bits/w, 5000000 Hz max --> 0
[    0.702770] dw_spi_mmio fff00000.spi: registered child spi32766.0
[    0.702817] spi spi32766.1: setup mode 3, 8 bits/w, 5000000 Hz max --> 0
[    0.703026] dw_spi_mmio fff00000.spi: registered child spi32766.1
[    0.961755] ad7791 spi32766.0: Missing IRQ.
[    0.965969] ad7791 spi32766.1: Missing IRQ.

/sys/bus/spi/devices/

directory shows two spi devices correctly i guess:

spi32766.0/  spi32766.1/

 

         BUT,

 

/sys/bus/iio/devices/ directory is empty

 

iio_info tool gives output like that

iio_info
Library version: 0.9 (git tag: v0.9)
Compiled with backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.9 (git tag: v0.9)
Backend description string: Linux gb 4.9.13 #4 SMP Wed Nov 29 16:17:28 CET 2017 armv7l
IIO context has 1 attributes:
        local,kernel: 4.9.13
IIO context has 0 devices:

 

Does anyone have any clue why my SPI devices are not detected by iio subsystem?

or

Can I easily handle ADCs with SPI alone, without IIO?

Outcomes