AnsweredAssumed Answered

ad7192 linux driver: no device0 created

Question asked by jcao on Jan 23, 2017
Latest reply on Sep 1, 2017 by DragosB

I am working on our prototype pcb based on raspberry pi Compute Module 1 with linux kernel rpi-4.4/rpi-4.10(tried both)

I have ad7190 on the pcb.

I have followed the instruction at https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7192#example_platform_device_initialization

But there is no device created under root:/> cd /sys/bus/iio/devices/

Below is how I did so far(with kernel rpi-4.10):

1)    Added the following into   /usr/src/linux/arch/arm/mach-bcm/board_bcm2835.c as below: 

[--snip--]

#include <linux/spi/spi.h>

#include </usr/src/linux/drivers/staging/iio/adc/ad7192.h>

[--snip--]

static struct ad7192_platform_data ad7192_pdata = {

        .vref_mv                = 5000,

        .clock_source_sel       = 2,

        .refin2_en              = false,

        .rej60_en               = true,

        .sinc3_en               = false,

        .chop_en                = true,

        .buf_en                 = true,

        .unipolar_en            = true,

        .burnout_curr_en        = false,

}; 

static struct spi_board_info board_spi_board_info[] __initdata = {

   #if defined(CONFIG_AD7192) \

        || defined(CONFIG_AD7192_MODULE)

        {

                .modalias = "ad7192",

                .max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */

                .bus_num = 0,

                .chip_select = 0,            /* CS, change it for your board */

                .platform_data = &ad7192_pdata,

                .mode = SPI_MODE_0,

                .irq = -1,                   /*IRQ_PF6,*/

        },

   #endif

};

static void __init bcm2835_init(void)

{

[--snip--]

        spi_register_board_info(board_spi_board_info, ARRAY_SIZE(board_spi_board_info));

[--snip--]

} 

2)    Configure kernel with “make menuconfig”  as below:

Linux Kernel Configuration    

   Device Drivers  --->             

      [*] Staging drivers  --->                      

         IIO staging drivers  --->                        

            Analog to digital converters  --->                               

               <M>   Analog Devices AD7190 AD7192 AD7195 ADC driver

3)   Rebuild the kernel

4)    Run raspi-config

Set SPI interface disable.

Note: Otherwise after reboot run demsg will show an error:

[    6.939750] spi-bcm2835 20204000.spi: chipselect 0 already in use

[    6.939772] spi_master spi0: spi_device register error /soc/spi@7e204000/spid                                                                                         

5)   reboot,

After reboot check with dmesg showed  no error.

6)    Run modprobe spi-bcm2835 and then modprobe ad7192

Check with dmesg showed a warning only:

[  233.753497] ad7192: module is from the staging directory, the quality is unknown, you have been warned. 

Note: I am not sure if modprobe spi-bcm2835 should be run, but it makes no difference in the end.

7)    Run lsmod showed as below

root@sm2:/# lsmod

Module                  Size  Used by

ad7192                  8325  0

ad_sigma_delta          6539  1 ad7192

industrialio_triggered_buffer     2813  1 ad_sigma_delta

kfifo_buf               3751  1 industrialio_triggered_buffer

industrialio           66261  4 ad7192,ad_sigma_delta,industrialio_triggered_buffer,kfifo_buf

spi_bcm2835             7424  0

cfg80211              530171  0

rfkill                 21278  1 cfg80211

joydev                  9386  0

rtc_ds1307             13710  0

hwmon                  10972  1 rtc_ds1307

evdev                  11714  2

hid_multitouch         11179  0

snd_bcm2835            23080  0

snd_pcm                96647  1 snd_bcm2835

snd_timer              22634  1 snd_pcm

snd                    68784  3 snd_timer,snd_bcm2835,snd_pcm

i2c_bcm2835             6369  0

bcm2835_gpiomem         3823  0

uio_pdrv_genirq         3718  0

uio                    10198  1 uio_pdrv_genirq

i2c_dev                 6642  0

ipv6                  386871  24

8)  Found no device0 under cd /sys/bus/iio/devices/

Only found ad7192 folder under /sys/bus/spi/drivers/ as below

root@sm2:/sys/bus/spi/drivers# ls

ad7192  spidev  stmpe-spi

 

Could anyone please help me?

Thanks in advance.

 

 

Outcomes