Defining QSPI in device tree on SAMA5D27 SOM1

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

gcb87
Posts: 8
Joined: Wed Jul 22, 2020 3:40 pm

Defining QSPI in device tree on SAMA5D27 SOM1

Thu May 06, 2021 4:21 pm

Hi,

I want to define a QSPI device that I need to use in order to communicate with an LCD.

I have a tried to read documentation etc but its not really clear to me what I need to define in the device tree ( I am using yocto)
At the moment I have the following in at91-sama5d27_som1_ek.dts.

Code: Select all

	qspi1: spi@f0024000 {
				status = "okay";
				qspidev@0 {
					compatible = "atmel-quadspi";
					reg = <0>;
					spi-max-frequency = <8000000>; 
				};
			};
I have also removed the flash@0 definition from at91-sama5d27_som1.dtsi

Obviously what I have done above with the device tree entry is completely wrong - there is nothing in dmesg and nothing in /dev
Can't find any examples or further documentation on how to define the device

Some help would really be appreciated!
blue_z
Location: USA
Posts: 2156
Joined: Thu Apr 19, 2007 10:15 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Fri May 07, 2021 11:33 pm

gcb87 wrote: I want to define a QSPI device that I need to use in order to communicate with an LCD.
You neglect to provide salient information.

What kernel version are you using? Be aware that Device Tree files for Microchip SoCs are still considered a "work in progress" and "unstable", meaning that DT files (and constructs for properties) must match the kernel source code.

What is this "QSPI device"?
What driver are you trying to reference using the compatibility string "atmel-quadspi"?

gcb87 wrote: I have also removed the flash@0 definition from at91-sama5d27_som1.dtsi
How have you disabled this chip on the SOM?
How have you verified that the "QSPI device" is connected and functional?
Or are you trying to use Linux to test out your hardware?

gcb87 wrote: ... there is nothing in dmesg and nothing in /dev
Can't find any examples or further documentation on how to define the device
Negative summations and exaggeration do not convey useful information.

If by "nothing" you are specifically referring to possible messages by the atmel-quadspi driver, then you need to be aware that this driver would only output a console message for an error condition during its probe/initialization. Apparently the author tried to minimize console output during boot and/or expects the slave device to provide boot messages.
One way to check for an active peripheral such as a (Q)SPI master controller is to review the allocations in the /proc/iomem file.
If by "nothing" you are referring to the lack of any device nodes named "[q]spi*" in /dev/, then you need to be aware that a (Q)SPI master controller is not userspace accessible and therefore would not have a device node.
A device node for your mystery (Q)SPI slave device (and unknown driver) requires a proper DT node and successful (SPI protocol) driver probe/initialization.


Regards
gcb87
Posts: 8
Joined: Wed Jul 22, 2020 3:40 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Sat May 08, 2021 7:34 am

Hi,

Thanks for your reply.
What kernel version are you using? Be aware that Device Tree files for Microchip SoCs are still considered a "work in progress" and "unstable", meaning that DT files (and constructs for properties) must match the kernel source code.
The kernel verson is 5.4

I think your last point is where my problem lies. I am expecting a device in /dev/
Where did you read/see that QSPI is not user space accesible? This is quite interesting..as far as I am aware SPI can be accessed via dev according to http://ww1.microchip.com/downloads/en/A ... 03253a.pdf

The LCD I need to communicate with via QSPI comes with userspace "drivers" that open a QSPI device from /dev
If I understand correctly my only option would be to communicate with the LCD via QSPI in kernel space?

Thanks
blue_z
Location: USA
Posts: 2156
Joined: Thu Apr 19, 2007 10:15 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Mon May 10, 2021 2:52 am

gcb87 wrote: I think your last point is where my problem lies. I am expecting a device in /dev/
Where did you read/see that QSPI is not user space accesible?
Review the driver. Does atmel-quadspi.c contain a file_operations structure?
No, it does not because atmel-quadspi.c is a platform driver.

SPI is a bus like USB.
The SPI bus has a master controller and slave devices, just like USB.
Is the USB master (aka host) controller accessible from userspace and/or have a device node in the /dev/ directory (e.g. /dev/usb0)?

Since you seem to make no distinction between the driver for the SPI master controller versus a SPI protocol driver, that probably means you have not studied the kernel's spi-summary documentation.
What is a "USB driver"? (It's a trick question, because it's ambiguous and I don't know the answer.)
In the same manner, what is a "SPI driver"? (Again it's a trick question, because it's ambiguous and I don't know the answer.)


gcb87 wrote: This is quite interesting..as far as I am aware SPI can be accessed via dev according to http://ww1.microchip.com/downloads/en/A ... 03253a.pdf
That appnote describes how to use SPIDEV.

SPIDEV is a psuedo device whose (SPI protocol) driver is a pass-through mechanism for SPI commands and data to a SPI slave device from userspace.
If you choose to ignore the Linux kernel framework for SPI that is in place, then you could crudely describe SPIDEV as "access[ing] the SPI bus driver via the device node /dev/spidev"'.

gcb87 wrote: The LCD I need to communicate with via QSPI comes with userspace "drivers" that open a QSPI device from /dev
That's a rather poorly stated and vague requirement.


gcb87 wrote: If I understand correctly my only option would be to communicate with the LCD via QSPI in kernel space?
Carefully study Section 2. Software Design of the application note you referenced and the kernel documentation for the SPIDEV driver.

Regards
gcb87
Posts: 8
Joined: Wed Jul 22, 2020 3:40 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Mon May 10, 2021 7:26 am

Review the driver. Does atmel-quadspi.c contain a file_operations structure?
No, it does not because atmel-quadspi.c is a platform driver.
Thanks - that gave me plenty to read up on.
Carefully study Section 2. Software Design of the application note you referenced and the kernel documentation for the SPIDEV driver.
Not sure I have managed to understand your hint here. Can't see anything there that would help me with QSPI seeing that SPIDEV isnt a platform driver as you mentioned.

It does seem to me that one route would be to create something similar to spidev (qspidev) that will create a node in /dev and allow read/write operations from user space. My experience is limited, so your advise would be very much welcome

Thanks
blue_z
Location: USA
Posts: 2156
Joined: Thu Apr 19, 2007 10:15 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Mon May 10, 2021 8:53 pm

gcb87 wrote: The LCD I need to communicate with via QSPI ...
Wait a minute.
You have a irritating habit of not answering questions and/or providing information piecemeal.

What "LCD" is this that uses QSPI?
Does this LCD actually require a Quad SPI interface and emulates a (flash) memory device?

Or does this LCD have a standard SPI interface?

FYI the QSPI peripheral in the SAMA5D2 is capable at the hardware level of either SPI or QSPI operation as a master.
However the Linux driver for this device (currently) only operates in QSPI mode for a (flash) memory:

Code: Select all

This driver does not support generic SPI.  
The implementation only supports spi-mem interface.

Regards
gcb87
Posts: 8
Joined: Wed Jul 22, 2020 3:40 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Mon May 10, 2021 9:07 pm

It’s an LCD that uses the following controller chip:

https://brtchip.com/ft81x/#81x

LCD in question
https://github.com/riverdi/riverdi-eve

It supports spi or quad spi
It isn’t emulating a flash device it has its own protocol

As the SAMA5D27 does not have a suitable LCD interface for our needs this overpriced LCD was chosen.
blue_z
Location: USA
Posts: 2156
Joined: Thu Apr 19, 2007 10:15 pm

Re: Defining QSPI in device tree on SAMA5D27 SOM1

Tue May 11, 2021 9:31 pm

gcb87 wrote: It’s an LCD that uses the following controller chip:
...
It supports spi or quad spi
Just because some hardware component has a capability does not mean that the final product actually has that capability.

The Linux host layer of that library for that panel does not "open a QSPI device from /dev".
Rather the Linux host layer simply uses the (well-known) spidev device.
As far as I can tell there is no QSPI mode supported at the Linux host layer, and therefore your QSPI requirement would be bogus.

gcb87 wrote: It isn’t emulating a flash device ...
Actually it does if you read the documentation:
The FT81X appears to the host MCU as a memory-mapped SPI device.

Regardless, the atmel_qspi driver is fundamentally incompatible with the FT81X initialization procedure in that library.
Seems like you need to connect the panel to a SPI controller rather than QSPI if you plan on using that provided library.

Regards

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 3 guests