2009-04-10 17:55:43     SPI probe function not being called

Document created by Aaronwu Employee on Aug 14, 2013
Version 1Show Document
  • View in full screen mode

2009-04-10 17:55:43     SPI probe function not being called

Doug Bailey (UNITED STATES)

Message: 72522   

 

I am upgrading an established product running the 2.6.16 kernel to the 2.6.22

kernel that is part of the 2008RC1.5 tag.  (built with gcc 4.1)

 

Things are going reasonably well except that my SPI device's probe function is

not being called when I load my device driver module.

 

Having read over, http://docs.blackfin.uclinux.org/doku.php?id=spi&s[]=spi I do

not see where my code is not setting things up correctly.  (It did work on the

older kernel.)

 

Among the things I have verified:

I am able to see that the spi_register_board_info is registering the SPI bus and

    adding it to its board list.

I am receiving a 0 on the return of the spi_register_driver call within my

    device driver.

/sys/bus/spi/drivers_autoprobe is set to 1

 

Is there something that has changed from 2.6.16 to 2.6.22 that breaks the

behavior I am assuming?

 

Is there some setting in configuration that I am missing?

 

 

===============================================================================

Bus set up code:

 

static struct bfin5xx_spi_chip sx00i_spi_info = {

.ctl_reg = 0x1c00,

.enable_dma = 0,

.bits_per_word = 8,

};

 

static struct spi_board_info bfin_spi_board_info[] __initdata = {

#if defined(CONFIG_MTD_M25P80) \

    || defined(CONFIG_MTD_M25P80_MODULE)

       {

           /* the modalias must be the same as spi device driver name */

               .modalias = "m25p80", /* Name of spi_driver for this device */

           /* this value is the baudrate divisor */

               .max_speed_hz = 20000000,

               .bus_num = 0, /* Framework bus number */

               .chip_select = 1, /* Framework chip select. On sx00i_core537 it is SPISSEL1*/

               .platform_data = &bfin_spi_flash_data,

               .controller_data = &spi_flash_chip_info,

        .mode = SPI_MODE_3,

       },

#endif

       {

        .modalias = "sx00i-echo",  

        .max_speed_hz = 2000000,  

        .bus_num = 0,

        .chip_select = 7,

        .platform_data = NULL,

        .controller_data = &sx00i_spi_info,

        .mode = SPI_MODE_3,

       },

  

#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)

    {

        .modalias = "spidev",

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

        .bus_num = 0,

        .chip_select = 6,

        .controller_data = &spidev_chip_info,

    },

#endif

 

};

 

 

static int __init sx00i_core_init(void)

{

    printk("%s(): registering device resources\n", __FUNCTION__);

    platform_add_devices(sx00i_core_devices, ARRAY_SIZE(sx00i_core_devices));

#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)

    spi_register_board_info(bfin_spi_board_info,

                   ARRAY_SIZE(bfin_spi_board_info));

#endif

    return 0;

}

 

 

======================================================================================

Code from my driver:

 

static struct spi_driver sx00i_driver = {

    .driver = {

        .name    = "sx00i-echo",

        .bus    = &spi_bus_type,

        .owner    = THIS_MODULE,

    },

    .probe    = sx00i_spi_probe,

    .remove    = __devexit_p(sx00i_spi_remove),

};

 

int init_sx00i_spi(void)

{

    int x = spi_register_driver(&sx00i_driver);

    /* Returns with x = 0 */

    return x;

}

 

QuoteReplyEditDelete

 

 

2009-04-10 18:00:49     Re: SPI probe function not being called

Mike Frysinger (UNITED STATES)

Message: 72523   

 

you do not need the #if protection around the call to spi_register_board_info()

 

you should not set the .bus field of the .driver member

 

you should not set ctl_reg anymore -- use the common SPI framework defines for those

 

otherwise, post the full kernel boot log ...

QuoteReplyEditDelete

 

 

2009-04-16 10:08:39     Re: SPI probe function not being called

Doug Bailey (UNITED STATES)

Message: 72757   

 

The problem was that the bus was not being properly registered.  The issue was cleared up by taking the steps you mentioned, adding resource structure to my platfrom_device description and insuring that my bus was being properly referenced by my driver.

 

Thanks for the help.

 

Doug

Attachments

    Outcomes