How to interface MCU with i.MX6 over SPI interface?

Hello all,

I want to interface the ARM Cortex-M3/M4 based MCU with i.MX6 over SPI interface.
For that Do I need to write the SPI driver ?
If yes, then please give some example driver code for reference.
How to add the entry for that MCU in Device tree?

Hello bhuvan,

I read all these documents but I am confused whether I should go with SPI protocol driver or SPIDEV driver?

Do you have any example SPI protocol driver?

Thanks & Regards,

It would be preferable to use the spidev from user space and just communicate with MCU over SPI like any other device with iMX6 as master. What do you exactly imply by a SPI protocol driver?

Hello Sanchayan,

I also thought about SPIDEV driver only since I found it little complex.
But is it possible to communicate with MCU using SPIDEV driver and API provided by it.
If I start with SPIDEV driver then which files I need to modify like they have given in the document mach-xx.c board file but I didn’t find any board file for i.MX6 in kernel source code?
kindly help regarding this issue.

Thanks & Regards,

Why modify the SPI driver? The spidev provided interface can be used to read or send data over SPI. Have a look at the spidev_test code please.

Unfortunately we are not having any example custom drivers. Refer the spi kernel documentation for the same, here.

Other possible way is to use spidev to communicate with the slave device. By default spidev interface support is available on our prebuild Linux images(not enabled by default), with which one can communicate with slave devices connected over the bus, have a look at this. One can communicate with the slave SPI devices connected on the bus via /dev/spidevB.C. More information related to spidev is available here and spidev usage example here.

As @Sanchayan pointed there is no need of changing spidev driver. The spidev driver provides a spidev interface in userspace via /dev/spidevB.C which is generic. To communicate with slave devices one need to use the spidev node available at /dev. Refer the spidev_test example for more information/hints on using spidev, also have a look at this example of using spidev to communicate with external SPI based DAC and ADC chips.