spidev

cancel
Showing results for 
Search instead for 
Did you mean: 

spidev

5,127 Views
roryhansen
Contributor II

I have 2 spi devices on the spi bus that I want to access as "/dev/spidevx.x".  I have altered "mx28evk.c" as follows:

static struct spi_board_info spi_device_info[2] __initdata = {

    [0] = {

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

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

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

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

        .chip_select = 1, /* Framework chip select. */

    },

    [1] = {

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

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

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

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

        .chip_select = 2, /* Framework chip select. */

    },

};

static void spi_device_init(void)

{

    spi_register_board_info(spi_device_info, ARRAY_SIZE(spi_device_info));

}

When I do a  search for spi devices on the target system I get:

root@freescale /$ find -name '*spi*'

./lib/modules/2.6.35.3-670-g914558e/kernel/drivers/scsi/scsi_transport_spi.ko

./proc/irq/98/mxs-spi.0

./proc/irq/84/mxs-spi.0

./sys/devices/platform/mxs-spi.0

./sys/devices/platform/mxs-spi.0/spi_master

./sys/devices/platform/mxs-spi.0/spi_master/spi1

./sys/bus/platform/devices/mxs-spi.0

./sys/bus/platform/drivers/mxs-spi

./sys/bus/platform/drivers/mxs-spi/mxs-spi.0

./sys/bus/spi

./sys/bus/spi/drivers/spidev

./sys/class/spi_master

./sys/class/spi_master/spi1

./sys/class/spidev

./sys/module/spi_mxs

./sys/module/spidev

So, what am I missing and/or doing wrong?


Labels (2)
0 Kudos
10 Replies

545 Views
varsmolta
Contributor V

Can you paste your kernel logs (full debug output)?

0 Kudos

545 Views
bfac
NXP Employee
NXP Employee

Hello!

I have a similar issue, would you have any update on that topic?

Tks!

Bruno

0 Kudos

545 Views
roryhansen
Contributor II

We had originally setup SSP3 for the SPI device bus, but SSP3_SS0 had been assigned as a GPIO for other purposes.  WIth no slave select, the driver would not create the /dev/spidevx.x entry.  When we configured SSP3_SS0 as a SPI select, then the driver generates the device entry.

0 Kudos

545 Views
polestar
Contributor I

Why can't I use m25p80 and spidev simultaneously?

If each one of them is in separate bus (SSP2 and SSP3), for example?

  • I've edited my board info like this in mx28evk.c:

static struct spi_board_info 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 */

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

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

  .chip_select = 0, /* Framework chip select. */

  .platform_data = &mx28_spi_flash_data,

  },

#endif

  {

  .modalias = "spidev",

  .max_speed_hz = 20000000,

  .bus_num = 2,

  .chip_select = 0,

  .mode = SPI_MODE_0,

  },

};


  • in addition I've added support for SSP3 in device.c:

static struct mxs_spi_platform_data spi1_data = {

  .clk = "ssp.3",

  .slave_mode = 0,

};

static struct resource ssp3_resources[] = {

  {

  .start = SSP3_PHYS_ADDR,

  .end = SSP3_PHYS_ADDR + 0x2000 - 1,

  .flags = IORESOURCE_MEM,

  }, {

  .start = MXS_DMA_CHANNEL_AHB_APBH_SSP3,

  .end = MXS_DMA_CHANNEL_AHB_APBH_SSP3,

  .flags = IORESOURCE_DMA,

  }, {

  .start = IRQ_SSP3_DMA,

  .end = IRQ_SSP3_DMA,

  .flags = IORESOURCE_IRQ,

  }, {

  .start = IRQ_SSP3,

  .end = IRQ_SSP3,

  .flags = IORESOURCE_IRQ,

  },

};

static void __init mx28_init_spi1(void)

{

  struct platform_device *pdev;

  pdev = mxs_get_device("mxs-spi", 1);

  if (pdev == NULL || IS_ERR(pdev))

  return;

  pdev->resource = ssp3_resources;

  pdev->num_resources = ARRAY_SIZE(ssp3_resources);

  pdev->dev.platform_data = &spi1_data;

  mxs_add_device(pdev, 3);

}

  • and, of course, defined the SSP3 pins in mx28evk_pins.c:

#if defined(CONFIG_SPI_MXS) || defined(CONFIG_SPI_MXS_MODULE)

static struct pin_desc mx28evk_spi_pins[] = {

  {

  .name = "SSP2 MOSI",

  .id = PINID_SSP2_MOSI,

  .fun = PIN_FUN1,

  .strength = PAD_4MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP2 MISO",

  .id = PINID_SSP2_MISO,

  .fun = PIN_FUN1,

  .strength = PAD_4MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP2 SCK",

  .id = PINID_SSP2_SCK,

  .fun = PIN_FUN1,

  .strength = PAD_4MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP2 SS0",

  .id = PINID_SSP2_SS0,

  .fun = PIN_FUN1,

  .strength = PAD_8MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP3 MOSI",

  .id = PINID_SSP3_MOSI,

  .fun = PIN_FUN1,

  .strength = PAD_4MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP3 MISO",

  .id = PINID_SSP3_MISO,

  .fun = PIN_FUN1,

  .strength = PAD_4MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP3 SCK",

  .id = PINID_SSP3_SCK,

  .fun = PIN_FUN1,

  .strength = PAD_4MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

  {

  .name = "SSP3 SS0",

  .id = PINID_SSP3_SS0,

  .fun = PIN_FUN1,

  .strength = PAD_8MA,

  .voltage = PAD_3_3V,

  .drive = 1,

  },

};

#endif

But still SPIDEV won't create the device driver...

The m25p80 is working fine though...

Thanks a lot for anyone's help with this.....

0 Kudos

545 Views
YixingKong
Senior Contributor IV

Rory, if Victor's coment helps you, please click Correct Answer/Helpful Answer.

Thanks,

Yixing

0 Kudos

545 Views
roryhansen
Contributor II

Hi there,

As are you from Freescale, perhaps you can answer this.  I have this and one other problem that have yet to be resolved, and really need to be.  It is possible to escalate this to someone at Freescale to try to get this resolved?

0 Kudos

545 Views
HugoOsornio
NXP Employee
NXP Employee

Hi Rory.

I had the same issue with the i.MX6x and found out that I was not calling the spi_device_init function.

Once I ensured that the function was called, I was able to see the spidev0.0 and spidev4.0 (I am using ECSPI1 and ECSPI5).

Hope this helps

0 Kudos

545 Views
roryhansen
Contributor II

"spi_device_init" is definitely being called, but still no "/dev/spidevx.x" entries.

0 Kudos

545 Views
HugoOsornio
NXP Employee
NXP Employee

Hi Rory,

Then allow me to state everything I did to get the spidev running on my end.

1.- Configure Kernel to ensure that spidev module gets compiled and installed.

     on ltib install folder type "./ltib -c"

     Check the Configure the Kernel checkbox

     A new prompt will appear, go to Device Drivers

     Go to SPI Support

     Make sure that Freescale i.MX SPI controllers and User mode SPI device driver support are checked.

     Exit and Build.

2.- Altered the file as you did (I did it for i.MX6 though).

However i did change the .bus_num number, as I have 2 buses and one device per bus.

static struct spi_board_info spi_device_info[] __initdata = {

    {

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

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

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

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

        .chip_select = 0, /* Framework chip select. */

        .mode = SPI_MODE_0,

    },

    {

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

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

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

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

        .chip_select = 0, /* Framework chip select. */

        .mode = SPI_MODE_0,

    },

};

0 Kudos

545 Views
roryhansen
Contributor II

Yep, doing all that.  I'm sure it will wind up being something silly, but for now, ?????

0 Kudos