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
Contributor
Contributor
225 Views
Registered: ‎05-04-2018

How to Properly Build Device Tree for SPI

Jump to solution

How do I know if I built the device tree properly for SPI? Do I have to have "spidev" in my list of devices or can it work without spidev?

 

Been going off of this:https://github.com/Xilinx/linux-xlnx/blob/master/Documentation/devicetree/bindings/spi/spi-cadence.txt 

As well as: https://events.static.linuxfound.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf 

 

However, none of this is solving my issue. I am trying to do SPI via the EMIO pins and use Petalinux 2017.4 with a ZCU102 board. Please offer advice.

 

Thanks

0 Kudos
1 Solution

Accepted Solutions
Contributor
Contributor
143 Views
Registered: ‎05-04-2018

Re: How to Properly Build Device Tree for SPI

Jump to solution

Hi @jadhavs ,

 

I actually submitted a service request that made the process for simple to boot external with access to external SPI. I am trying to use a light sensor attached to the PMODs. I have yet to test it with hardware. I'm trying to figure out how to quickly build Petalinux applications and debug them while running Petalinux. It seems that I cannot add applications unless I boot the image with the application. I added vim to my rootfs, but I can't do anything GUI related while on Petalinux. How can I best develop applications and debug code on Petalinux?

 

Here's the answer I got from the service request (that worked at least to get the spidev to appear in devices):

1. Enable SPI0 and SPI1 on the EMIO interface in the Vivado design within the ZCU102 block.

2. Use "petalinux-config -c kernel" and enable the following options under "Device Drivers" -> "SPI support":

  • Cadence SPI controller

  •  Xilinx SPI controller common module

  •  Xilinx ZynqMP GQSPI controller

  •  User mode SPI device driver support (this option is not selected by default; needs to be manually selected)

3. Make changes to system-user.dtsi located at <plnx_proj_root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

The file should look like:

 

/include/ "system-conf.dtsi"

/ {

};

&spi0 {

    is-decoded-cs = <0>;

    num-cs = <1>;

    status = "okay";

 

    spidev@0 {

        compatible="rohm,dh2228fv";

        reg =<0>;

        spi-max-frequency = <10000000>;

    };

};

&spi1 {

    is-decoded-cs = <0>;

    num-cs = <1>;

    status = "okay";

 

    spidev@0 {

        compatible="rohm,dh2228fv";

        reg =<0>;

        spi-max-frequency = <10000000>;

    };

};

4. Build petalinux project

I followed the same steps above and created a Petalinux 2017.4 project based on the ZCU102 ES2 Rev1.0 BSP. After Linux booted up on the APU, I was able to view the spi0 and spi1 devices in /dev as spidev1.0 and spidev 2.0, respectively.

 

0 Kudos
2 Replies
Xilinx Employee
Xilinx Employee
170 Views
Registered: ‎01-21-2008

Re: How to Properly Build Device Tree for SPI

Jump to solution

Hi @doverstreet6,

Our wiki page https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842437/SPI+Zynq+driver does not specify “spidev” DT node. But it explains two examples for SPI SoC to access EEPROM and SPI flash device. Have a look and let me know if this resolves your issue or not?

SPIDEV supports access to SPI devices using normal userspace I/O calls. Are you looking for this to enable in you application side? It yes, then let me know and I'll send you procedure for this. Otherwise simply use our Wiki page and your issue will get resolved.

0 Kudos
Contributor
Contributor
144 Views
Registered: ‎05-04-2018

Re: How to Properly Build Device Tree for SPI

Jump to solution

Hi @jadhavs ,

 

I actually submitted a service request that made the process for simple to boot external with access to external SPI. I am trying to use a light sensor attached to the PMODs. I have yet to test it with hardware. I'm trying to figure out how to quickly build Petalinux applications and debug them while running Petalinux. It seems that I cannot add applications unless I boot the image with the application. I added vim to my rootfs, but I can't do anything GUI related while on Petalinux. How can I best develop applications and debug code on Petalinux?

 

Here's the answer I got from the service request (that worked at least to get the spidev to appear in devices):

1. Enable SPI0 and SPI1 on the EMIO interface in the Vivado design within the ZCU102 block.

2. Use "petalinux-config -c kernel" and enable the following options under "Device Drivers" -> "SPI support":

  • Cadence SPI controller

  •  Xilinx SPI controller common module

  •  Xilinx ZynqMP GQSPI controller

  •  User mode SPI device driver support (this option is not selected by default; needs to be manually selected)

3. Make changes to system-user.dtsi located at <plnx_proj_root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

The file should look like:

 

/include/ "system-conf.dtsi"

/ {

};

&spi0 {

    is-decoded-cs = <0>;

    num-cs = <1>;

    status = "okay";

 

    spidev@0 {

        compatible="rohm,dh2228fv";

        reg =<0>;

        spi-max-frequency = <10000000>;

    };

};

&spi1 {

    is-decoded-cs = <0>;

    num-cs = <1>;

    status = "okay";

 

    spidev@0 {

        compatible="rohm,dh2228fv";

        reg =<0>;

        spi-max-frequency = <10000000>;

    };

};

4. Build petalinux project

I followed the same steps above and created a Petalinux 2017.4 project based on the ZCU102 ES2 Rev1.0 BSP. After Linux booted up on the APU, I was able to view the spi0 and spi1 devices in /dev as spidev1.0 and spidev 2.0, respectively.

 

0 Kudos