Project

General

Profile

Virtual SPI device setup and access using spidev - Altera Cyclone V case

Added by Gianni Casonato over 7 years ago

Ref: <similar message in ARM9 Based Platforms Forum> https://support.criticallink.com/redmine/boards/10/topics/5285

Hi all,

I'm using a MitySOM-5CSX Altera SOCFPGA Cyclone V board with kernel version 3.16.0-g9cf65cd-dirty and filesystem ext3 to simulate with SW only a SPI device (I don't have the HW yet). For doing that I've tried to define a dummy SPI device in order to access it from user space using spidev.

I've tried several options for defining the SPI device in the dev-tree (dts file) and refreshing the boot image in the SD, but no way up to now. The system boots correctly but when I load spidev module nothing happens in the /dev, no /dev/spidevX.Y appears... It looks no probe is called, i.e the dummy SPI device is not recognized or not linked to spidev. at that purpose I've also used a modified version of spidev where I've added log messages at init - probe and exit points. The former and the latter are correctly called adding and removing the module, the probe one never gets called instead.
I've enabled SPI master and SPIDEV controller as well in the kernel, and rebuild and reinstalled it in the SD.

I wonder if that SW emulation of the SPI device is really possible...

Attached an example of dts I've used (not successfully). My addition are delimited by "GC added start" / "GC added stop" lines. I've tried both to add the SPI device as separate node at the end of the dts, and as part of "soc" node.
Note: after changing the dts I only run a "make .... dtbs" and then I copy the generated dtbs in the SD card. No other kernel refresh. Is it ok?

Finally - it's not fully clear to me how I can instruct the kernel builder for the dts file to use. I've found out which one it is among the set of dts files in the boot directory using greps... and I'm modifying that one directly. But I'd like to create a test one and work on it separately. Is it possible?

Thanks in advance for any help on that topic,
Gianni

my_dt_for_SPI_test.dts (4.08 KB) my_dt_for_SPI_test.dts Test dts file for dummy SPI device - not working(!)

Replies (5)

RE: Virtual SPI device setup and access using spidev - Altera Cyclone V case - Added by Daniel Vincelette over 7 years ago

Hello Gianni,

I see that you've tried to add both the spidev devices to a FPGA spi core and the HPS peripheral. I would recommend going with the HPS peripheral because there is a known bug with the FPGA spi core and spidev, as discussed in this post: https://support.criticallink.com/redmine/boards/45/topics/5239?r=5298#message-5298.

I've took the adding of the HPS SPI from your DTS and added it to the bottom of the socfpga_mitysom5csx-h6-4ya_devkit.dts for testing. I also used the mitysom5csx_devkit_defconfig with no alterations, spidev support is built in. With this setup I can see a /dev/spidev0.0 and /dev/spidev0.1

I've attached my dts/dtb/uImage.

In order to have make build the dtb you need need add under the CONFIG_ARCH_SOCFPGA section of arch/arm/boot/dts/Makefile

Dan

RE: Virtual SPI device setup and access using spidev - Altera Cyclone V case - Added by Gianni Casonato over 7 years ago

Dan,
thanks for it.
I've added the spi0 section at the bottom of my dts and it works!!! Fantastic!!

The only point is that is works only using your uImage, not with mine... that's now my next issue.
But in any case I'm moving on now :)

Could you tell me which settings you applied, or even better to post the .config you used? That would be great.

Thanks again,
Gianni

RE: Virtual SPI device setup and access using spidev - Altera Cyclone V case - Added by Gianni Casonato over 7 years ago

Dan,
solved also this step!

I rebuilt the my kernel version using the default .config you suggested me, modified to enable other feature I need to use, and here it is!
I've also managed to use a custom version of spidev.c, that I need to modify for simulating a specific behavior.

Thanks a lot again!!

Cheers,
Gianni

    (1-5/5)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)