Probe function of SPI Driver not getting called (Apalis iMX6 + Ixora)

Hi Team ,
I am trying to add support to an “Analog SPI device AD7606” from device tree
so that the driver’s “drivers/staging/iio/adc/ad7606_spi.c”
probe function is called ( Apalis iMX6 + IXORA )

Enabled the spi device in arch/arm/boot/dts/imx6qdl-apalis-ixora.dtsi to get

/* Apalis SPI1 */                                                                
&ecspi1 {                                                                        
          status = "okay";                                                         
                                                                                   
          spidev0: spidev@1 {                                                      
                  compatible = "toradex,evalspi";                                  
                  reg = <0>;                                                       
                  spi-max-frequency = <18000000>;                                  
          };                                                                       
                                                                                   
          ad7606-8@2 {                                                             
                  compatible = "adi,ad7606-8","adi,ad7606-4","adi,ad7606-4";       
                  reg = <0>;                                                       
                  spi-max-frequency = <18000000>;                                  
          };                                                                                                                                                                                                               
};                                                                               

The driver code to bind the device is

static const struct spi_device_id ad7606_id[] = {                                
          {"ad7606-8", ID_AD7606_8},                                               
          {"ad7606-6", ID_AD7606_6},                                               
          {"ad7606-4", ID_AD7606_4},                                               
          {}                                                                       
  };                                                                               
MODULE_DEVICE_TABLE(spi, ad7606_id);                                             
                                                                                   
static struct spi_driver ad7606_driver = {                                       
         .driver = {                                                              
                 .name = "ad7606",                                                
                 .owner = THIS_MODULE,                                            
                 .pm    = AD7606_SPI_PM_OPS,                                      
          },                                                                       
         .probe = ad7606_spi_probe,                                               
         .remove = ad7606_spi_remove,                                             
         .id_table = ad7606_id,                                                   
};                                                                               

module_spi_driver(ad7606_driver);      

Could team please let me know what might be the problem here or
if team can please provide any pointers.

Hi Toradex Team
From analog DSP website i could find an pointer where in we are required to add

  1. static struct spi_board_info board_spi_board_info followed by function call to spi_register_board_info()

  2. Add an platform_device structure

The link is as mentioned below :-
https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7606#declaring_spi_slave_devices

Could member please let me know respective files where i could do the changes for Apalis iMX6 + IXORA

Hi

What you describe in your driver snipplet and what the link to analog devices website describes is called platform data, e.g. instances of data structures describing a device in code. With the device tree this data is moved out of the kernel code into an external data representation.

Traditionally you would add platform code in a board_xxx file in e.g. arch/arm/mach-imx, however currently there is no apalis specifc board file as there is no driver needing board specific platform data.

I guess your better option is to integrate device tree support in the driver you have and then use the device tree. Have a look at this article.

In addition to adding the compatible string which binds the driver to the device tree node you would have to define device-tree properties and read them from the device-tree in probe() to fill the platform data.
This commit did something similar for a I2C touch controller.

Max

Dear Max ,
Thanks for pointer , will check the options suggested by you.

  1. w.r.t no support of Apalis specifc board file , thanks for confirming.

  2. The idea was to get the basic binding of spi driver & device-tree & then add additional properties like interrupt etc. Wanted the probe to be called at least.
    So i thought to create an entry in device tree and in driver mention the same compatible string so as to get the probe function of driver called at-least.
    Do just call an basic probe do i need to do any additional change.

  3. Adding support of device tree , will do it .

I expect the addition of

    static const struct of_device_id my_of_ids[] = {
	{ .compatible = "long,funky-device-tree-name" },
	{ }
    };

    static struct platform_driver my_driver = {
	/* ... */
	.driver	= {
		.name = "my-driver",
		.of_match_table = my_of_ids
 	}
    };

to the driver and then setting ‘long,funky-device-tree-name’ in the device tree results in a call to probe() of your driver.

Dear Max ,
Thanks a lot for finding time in your busy schedule & sharing the pointers.

Got the probe function called by modifying the contents of spi node
/* Apalis SPI1 */
&ecspi1 {
status = “okay”;

/*	
	spidev0: spidev@1 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <18000000>;
	};


*/
	adcc7606-8@0 {
		compatible = "adi,adcc7606-8";
		reg = <0>;
		spi-max-frequency = <18000000>;
	};
};

This is first project of mine working with device-tree hence not sure Why “0” is required at adcc7606-8@0
and reg = <0>;

In these location if i try any other values the probe function was not getting called.
To get an idea i checked how the node has been declared in imx6qdl-XXXXX.dtsi under arch/arm/boot/dts.

If possible could you please let me know what’s the significance of “0” here.
I would try reading the documentation under device-tree Linux documentation /

Adding the respective file in case going ahead if any member faces similar issue.
link text

link text