Hi,
I have been trying for the better part of two weeks to add SPI functionality to the Yocto image for the i.MX287EVK board. The current setup:
i.MX287EVK board
Ubuntu 64 bit 22.04 VM
Dunfell release of Yocto
core-image-full-cmdline
The image builds with no errors and boots from an SD card.
Is the following a true statement for the i.MX287 board?
There are two ways of using the user mode SPI device driver. To be able to do that, you need to enable your device with the spidev driver. An example would be as follows:
spidev@0x00 {
compatible = "spidev";
spi-max-frequency = <800000>; /* It depends on your device */
reg = <0>; /* correspond to chip select 0 */
};
You can call either the read/write functions or an ioctl(). By calling read/write, you can only read or write at a time. If you need full duplex read and write, you have to use the Input Output Control (ioctl) commands.
I would like to use SPI in full duplex mode.
What specific modifications do I need to make (DTS files, kernel configuration or anything else) if any, to enable the SPI functionality using Input Output Control (ioctl) commands in the hardware.
If the Input Output Control (ioctl) commands are not usable how are the read/write commands implemented (specifics)?
A sample of the user application code in C++ would also be very appreciated.
iMX287
已解决! 转到解答。
Hi @drb55
Hi @drb55 ,
Hi,
Thanks for the response, but it didn't resolve the problem. What is the correct entry for the compatible field if the device is an i.MX287.
According to the Linux Kernel documentation "spidev" is no longer supported
SPI userspace API — The Linux Kernel documentation
It used to be supported to define an SPI device using the “spidev” name. For example, as .modalias = “spidev” or compatible = “spidev”. But this is no longer supported by the Linux kernel and instead a real SPI device name as listed in one of the tables must be used.
Not having a real SPI device name will lead to an error being printed and the spidev driver failing to probe.
Thanks,
Dan
Hi @drb55
I hope you are doing well.
In the latest version of spidev.c driver, support for the "spidev" compatible string is removed because of the below reason.
Since spidev is a detail of how Linux controls a device rather than a description of the hardware in the system we should never have a node
described as "spidev" in DT, any SPI device could be a spidev so this is just not a useful description.
One can use any of the compatible strings in device tree node from the below table or add a hardware-specific string in below list at spidev. c.
static const struct of_device_id spidev_dt_ids[] = {
{ .compatible = "rohm,dh2228fv" },
{ .compatible = "lineartechnology,ltc2488" },
{ .compatible = "ge,achc" },
{ .compatible = "semtech,sx1301" },
{ .compatible = "lwn,bk4" },
{ .compatible = "dh,dhcom-board" },
{ .compatible = "menlo,m53cpld" },
{},
};
Thanks & Regards,
Sanket Parekh
Hi,
Thank you for the response.
Is there an application note or document that describes all of the steps necessary (like a checklist) to add an interface (SPI, I2C etc.) to the hardware description files (Including dtsi, dts, spidev.c and other files) and then test that the interface is functional.
Having one document for future reference would be very helpful.
Thanks
Dan
Hi @drb55
Hi,
Thank you for the documents, unfortunately the spidev is not working. I have spent many hours on this effort to no avail. I have included the dts and dtsi files as a reference, any suggestions to resolve this are greatly appreciated.
SPI user mode enabled in the kernel.
ls /dev/spidev*
/dev/spidev1.1 /dev/spidev2.0
Symbols file/directory is not loaded for some reason.
ls -l /proc/device-tree/__symbols__ | grep spi
ls: cannot access '/proc/device-tree/__symbols__': No such file or directory
root@imx28evk:/# dmesg | grep spi
[ 5.288199] mxs-spi 80014000.spi: registered master spi1
[ 5.290709] spi spi1.0: setup mode 0, 8 bits/w, 40000000 Hz max --> 0
[ 5.299155] spi-nor spi1.0: unrecognized JEDEC id bytes: ff ff ff ff ff ff
[ 5.307742] mxs-spi 80014000.spi: registered child spi1.0
[ 5.308037] spi spi1.1: setup mode 0, 8 bits/w, 5000000 Hz max --> 0
[ 5.315865] mxs-spi 80014000.spi: registered child spi1.1
[ 5.320976] mxs-spi 80016000.spi: registered master spi2
[ 5.322298] spi spi2.0: setup mode 0, 8 bits/w, 5000000 Hz max --> 0
[ 5.327063] mxs-spi 80016000.spi: registered child spi2.0
[ 5.788912] mxs-mmc 80010000.spi: Got WP GPIO
[ 5.823180] mxs-mmc 80010000.spi: initialized
Thanks, Dan
Hi @drb55
Hi @drb55