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: 
Explorer
Explorer
10,071 Views
Registered: ‎02-18-2014

spidev not found

Jump to solution

Im trying to become more familiar with how to use spi, and i understand that if i use /dev/spidev that it will give me access via ioctrl(). My question is what is the process for creating a new device file in /dev/ for spidev.

 

I am using petalinux and have configured CONFIG_SPI_SPIDEV=y which from what i can tell is suppose to enable /dev/spidev which its not. Also from what i understand i would expect to the following in my .dts file.

 

spi1: spi@e0007000 {
            compatible = "xlnx,ps7-spi-1.00.a";
            reg = <0xE0007000 0x1000>;
            interrupts = <0 49 0>;
            interrupt-parent = <&gic>;
            speed-hz = <50000000>;
            bus-num = <0>;
            num-chip-select = <4>;

spidev@0 {
            compatible = "spidev";
            reg = <0x0>;
            spi-max-frequency = <50000000>;
            #address-cells = <1>;
            #size-cells = <1>;
            };            
        };

 

I don't have that in my .dts file, is that something that i can freely edit and add it in? Or when i save my configuration with petalinux-config and it builds my .dts, should i leave it alone?

 

Thanks!

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Xilinx Employee
Xilinx Employee
12,986 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

No problem! That's why we're here

 

Enabling the SPI driver in the kernel configuration *is* sufficient to ensure that it is compiled and part of your kernel blob.  It is *not* sufficient to make sure that the appropriate entries are included in your DTS file.  That is still the responsibility of the system designer since you may have tweaks/customizations that you need to perform that are specific to your system.

 

So, once you have enabled SPI in the kernel configuration, edit your DTS file to add the SPI entries and give it a whirl.

-------------------------------------------
this space intentionally left blank
0 Kudos
21 Replies
Explorer
Explorer
10,059 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

update:

 

I've got spidev in /sys/class/spidev and /sys/module/spidev... but still nothing appears in /dev/.. from reading the documentation on it... i think im suppose to find something along the lines of /dev/spidevX.X..

 

Am i suppose to "bind" the device to something to make the device files appear in /dev/?

 

Anyone know documentation i can read through that explains this better then the wiki and petalinux kernel documentation.

 

Thanks!

0 Kudos
Explorer
Explorer
10,057 Views
Registered: ‎02-16-2014

Re: spidev not found

Jump to solution

Do you have SPI enabled in your hardware design (Vivado or ISE)?

0 Kudos
Explorer
Explorer
10,050 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

No, not yet. I was hoping to start some development on it while the custom hardware was getting figure out. Is it required to be implemented in hardware to have a device file show up? And thanks for the reply.

0 Kudos
Explorer
Explorer
10,037 Views
Registered: ‎02-16-2014

Re: spidev not found

Jump to solution

Hmmm... I'm 99% sure it should be enabled.

0 Kudos
Explorer
Explorer
10,036 Views
Registered: ‎02-16-2014

Re: spidev not found

Jump to solution

Also, did you enable Xilinx PS SPI driver in kernel?

0 Kudos
Xilinx Employee
Xilinx Employee
10,028 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

Do you happen to be using the master-next branch?  If so, the spi-zynq.c driver is gone and has been replaced with the spi-cadence.c driver.  Make sure it is enabled to be compiled in the kernel menuconfig and update your dts to use the compatible line "cdns,spi-r1p6"

-------------------------------------------
this space intentionally left blank
0 Kudos
Explorer
Explorer
10,017 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

In the kernel config settings (petalinux-config -c kernel) what I've had included was:

- Xilinx SPI Controller common module

- Xilinx PS QSPI controller

- Xilinx PS SPI controller

- User mode SPI device driver support (this is the one that is suppose to include spidev)

 

I'm not aware of any master-next branch? How would i know that i am or am not using that? Also from everywhere that i've read so far, i believe i shouldn't have to manually change my dts at all.

 

Thanks for helping all.

0 Kudos
Xilinx Employee
Xilinx Employee
10,012 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

If you're seeing those entries in your kernel menuconfig then you're probably not grabbing code out of the tree so my comment about master-next isn't relavent.

 

Also, I mis-read one of your comments in your OP last night.  Do you *not* have those entries in your DTS?  If not, make sure to add them.  What you have posted should be sufficient for generic SPI.  Which board are you using? Are you sure it actually has regular SPI peripherals and not QSPI?

-------------------------------------------
this space intentionally left blank
0 Kudos
Explorer
Explorer
10,011 Views
Registered: ‎02-16-2014

Re: spidev not found

Jump to solution

tmcdowe: Could you please elaborate on that. When, why,  why it called cadence and etc?

0 Kudos
Xilinx Employee
Xilinx Employee
8,086 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

I'm referring to the master-next branch in our Git tree: https://github.com/Xilinx/linux-xlnx

In PetaLinux, you'd specify the repo and branch settings in the system-level configuration.  See the screenshot below for where to specify it. I recommend *only* using a branch out of the tree if you have a specific reason and know-how.Untitled.png

 

As to the "why" question, some of the peripherals in the Zynq PS7 are industry-standard IP blocks and we're updating our drivers to reflect that.

-------------------------------------------
this space intentionally left blank
0 Kudos
Explorer
Explorer
8,080 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

Im using Z702 board with petalinux. I know the board has QSPI for the onboard flash but i want to use SPI for more generic applications.

 

Correct i do not have any spidev entries in my .dts file. I do however have a QSPI entry in the .dts file(ps7_qspi0, and ps7_qspi_linear_0).

0 Kudos
Explorer
Explorer
8,079 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution
My settings match yours via your screenshot. Those and "remote" are my only options to set, and for now I've ignored remote.
0 Kudos
Xilinx Employee
Xilinx Employee
8,075 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

Recall that QSPI and SPI are separate PS7 peripherals and (as we already discussed) use different drivers.  The QSPI peripheral has hardware support (and DTS support) with the ZC702.

 

For the regular SPI controller, what do you intend to communicate with?  Your design will need to enable the SPI peripheral in hardware as well as route the pins somewhere and connect to some kind of peripheral.  Then, you need to make sure that your Linux kernel has the approrpiate SPI (not QSPI) driver enabled in the kernel configuration and that your DTS contains the appropriate entires.

 

If you're routing off-board (or communicating with something in the Zynq PL) this should all be relatively straightforward.

-------------------------------------------
this space intentionally left blank
0 Kudos
Explorer
Explorer
8,070 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

I intend to communicate with a peripheral offboard. I've already routed as necessary.

 

Does petalinux provide SPI drivers automatically when the kernel has it enabled? I believe I have my kernel configuration correct but it has caused no change in my DTS. I've found lots of examples about how to use the spidev interface via ioctrl() and the /dev/spidev device file, yet that device file isn't showing up.

 

Thanks for your helpful responses.

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
12,987 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

No problem! That's why we're here

 

Enabling the SPI driver in the kernel configuration *is* sufficient to ensure that it is compiled and part of your kernel blob.  It is *not* sufficient to make sure that the appropriate entries are included in your DTS file.  That is still the responsibility of the system designer since you may have tweaks/customizations that you need to perform that are specific to your system.

 

So, once you have enabled SPI in the kernel configuration, edit your DTS file to add the SPI entries and give it a whirl.

-------------------------------------------
this space intentionally left blank
0 Kudos
Explorer
Explorer
8,065 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution
Great! that makes a lot more sense, is there a reference or documentation somewhere that could point me in the right direction of what is necessary to add to my DTS? There seems to be alot in there and so far anytime i try to change something, petalinux-build fails.
0 Kudos
Explorer
Explorer
8,062 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution
and to just verify one last time... by adding it to my DTS that should create the device file i need in /dev/ correct?
0 Kudos
Xilinx Employee
Xilinx Employee
8,059 Views
Registered: ‎12-17-2007

Re: spidev not found

Jump to solution

Assuming that the driver loads and find your peripherals (eg, what you've specified in the DTS), then yes it should create the device nodes in /dev

 

If the driver fails to load or you have some other kind of problem in the DTS entry, you may see a kernel panic.  If you do see a panic, review the log and it should give you an indication of what happened and what you need to do to fix it.

 

Can you post your full DTS that you have right now that is causing petalinux-build to fail?  What are the contents of the PetaLinux build.log file (from your project's build directory).

-------------------------------------------
this space intentionally left blank
0 Kudos
Explorer
Explorer
8,045 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

Attached is a copy of my failing .dts

 

As you can see im attempting to add spi0, spi1, and spidev.. this fails giving me a syntax error. And since im not familiar of what proper syntax looks here its a struggle to debug.

 

Also as a side note - at the top of the file i've added 4 uarts in the hardware... those build just fine but don't appear in my /dev/ directory either. Any thoughts about it would be appreciated.

 

Thanks

 

Im looking for the log file you asked for, i'll post it when i find it.

0 Kudos
Explorer
Explorer
3,730 Views
Registered: ‎02-18-2014

Re: spidev not found

Jump to solution

log file attached.

 

 

 

0 Kudos
Explorer
Explorer
3,724 Views
Registered: ‎02-16-2014

Re: spidev not found

Jump to solution
ps7_spi_1: ps7-spi@e0007000 {
bus-num = <0>;
compatible = "xlnx,ps7-spi-1.00.a";
interrupt-parent = <&ps7_scigic_0>;
interrupts = < 0 49 4 >;
clock-names = "ref_clk", "aper_clk";
clocks = <&clkc 26>, <&clkc 35>;
num-chip-select = <1>;
reg = < 0xe0007000 0x1000 >;
speed-hz = <1000000>; //1000000Hz
xlnx,has-ss0 = <0x1>;
xlnx,spi-clk-freq-hz = <0xF4240>; //1000000Hz
device@0{
compatible="linux,spidev";
reg =<0>; //chipselect 0
spi-max-frequency= <1000000>; //1000000Hz
};
}'

This is from my DTS.

0 Kudos