UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
237 Views
Registered: ‎09-06-2019

PS SPI Device Tree Question

We're having some confusion on how to properly instatiate a spi driver and device tree. Our bus has 3 chips so we have the following (legacy code):

&spi0 {
	status = "okay";
	num-cs = <3>;
	is-decoded-cs = <0>;
	label = "Audio-SPI";
	spi0_0: spi5a@0 {
		compatible = "spi5a";
		reg = <0>;
		spi-max-frequency = <4000000>;
	};
	spi0_1: spi5a@1 {
		compatible = "spi5a";
		reg = <1>;
		spi-max-frequency = <4000000>;
	};
	spi0_2: spi5a@2 {
		compatible = "spi5a";
		reg = <2>;
		spi-max-frequency = <4000000>;
	};
};

My question is this entry to the system-user.dtsi really works and where can I find a list of the 'compatible' devices? If we have to interface with a device that isn't in the compatible list, how would be go about adding the driver?

 

Thanks!

 

0 Kudos
1 Reply
Scholar rfs613
Scholar
200 Views
Registered: ‎05-28-2013

Re: PS SPI Device Tree Question


tkato@poc.com wrote:

My question is this entry to the system-user.dtsi really works and where can I find a list of the 'compatible' devices? If we have to interface with a device that isn't in the compatible list, how would be go about adding the driver?


The "compatible" property is gets matched against corresponding tables of strings in the Linux kernel (specifically, in the device drivers). To find them, you can search the Linux kernel source code:

cd <directory-containing-linux-kernel-source-code>
grep -r '\.compatible\s*=' drivers/

This list is huge... kernel 4.19 has over 6500 such strings. So rather than deal with all of them, start by looking into subdirectories, like drivers/spi or drivers/iio ("Industrial I/O") for example.

 

In general, if your device truly does not have a linux driver, then the usual process is:

- check the most recent Linux kernel version, a driver may exist there, just needs to be back-ported

- ask the manufacturer for support or pointers, often code already exists and it is just a matter of locating it

- otherwise, you have to write a driver. This usually involves finding an existing driver for a similar device, and either extending it, or using it as a base for a new driver.

 

Another option is to use the 'spidev' driver, which basically exists as a "shim" that lets you do the SPI operations from userspace.

0 Kudos