element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Avnet Boards General Linux driver for quad spi on Zedboard
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 2 replies
  • Subscribers 353 subscribers
  • Views 1100 views
  • Users 0 members are here
Related

Linux driver for quad spi on Zedboard

Former Member
Former Member over 9 years ago

I am quite new SoC, and I am currently working with the evaluation platform Zedboard. I have included a quad SPI in my block design and want to communicate with it through Linux running on one of the ARM processors. I need the SPI to transmit/receive 32bits in one burst and handle the communication from C++. However, I can't get it working.

The quad SPI is setup as standard, no FIFO and transaction width = 32 bits. I have updated the Linux device tree as follows:

axi_quad_spi_0@41E00000 {
compatible = "xlnx,xps-spi-2.00.b", "xlnx,xps-spi-2.00.a";
#address-cells = <0x1>;
#size-cells = <0x0>;
interrupt-parent = <0x2>;
interrupts = <0x0 0x39 0x1>;
reg = <0x41e00000 0xffff>;
xlnx,fifo-exist = <0x0>;
xlnx,num-ss-bits = <0x2>;
xlnx,num-transfer-bits = <0x20>;
xlnx,sck-ratio = <0x10>;
device@0 {
compatible = "spidev";
reg = <0x0>;
spi-max-frequency = <0x5f5e10>;
};
device@1 {
compatible = "spidev";
reg = <0x1>;
spi-max-frequency = <0x5f5e10>;
};
After this I can see spidev0.0 and spidev.0.1 in /dev as expected. Furthermore, when writing to the device files with bits_per_word = 8 I get an 8bit burst out of the quad SPI but with 32 clock periods, i.e. I get the first byte out corresponding to 1/4 of the 32 bit burst (seen with debug probes in Vivado). I guess I see this because the transaction width is set to 32bits.

However, when I want to change the burst to 32 bit (bits_per_word = 32) it doesn't work - I get the message "xilinx_spi_setup_transfer, unsupported bits_per_word=32" in my Linux terminal.

I use the following code in C++:

uint8_t tx[] = { 0xAD, 0xEF, 0x01, 0x23 };
uint8_t rx[4] = { 0 };
struct spi_ioc_transfer tr[2];
tr[0].tx_buf = (unsigned long)tx;
tr[0].rx_buf = (unsigned long)rx;
tr[0].len = 4;
tr[0].delay_usecs = delay;
tr[0].speed_hz = speed;
tr[0].bits_per_word = 32;
tr[0].cs_change = 0;

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
I have tried to compile the xilinx driver xilinx-spi.c but when I try to install it (with "modprobe xilinx_spi" in Linux) it says that the "Device or ressource busy".

How do I get this to support 32bit so I can transmit/receive 32bits in one burst? Can anybody help me out here? Thanks!

Br. Jacob

  • Sign in to reply
  • Cancel
  • zedhed
    0 zedhed over 9 years ago

    Hi Jacob,

    I don't have a lot of experience in working with this driver but I think what you are ultimately trying to do should work.

    To start off, I have some confusion over why you have set num-transfer-bits to 32 in your device tree entry.

    xlnx,num-transfer-bits = <0x20>;

    Do you really need to move 32-bit of data in one burst?  In your application code, it appears that you are just simply trying to move 4-bytes of data into your SPI device but I understand that you want all 4 bytes to go in the same SPI transaction.

    If I look at the Xilinx wiki entry for this device driver, I see that they set num-transfer-bits to 8 in their devicetree entry:

    xlnx,num-transfer-bits = <0x8>;

    http://www.wiki.xilinx.com/Linux+SPI+Driver

    I think if you set num-transfer-bits to 8 in your devicetree but sent 4 bytes of data from your application code, the driver will send out the string of 32-bits of data for you in a single SPI transaction.

    Let me know if I am misunderstanding this.

    Regards,

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to zedhed

    Hi Kevin,

    Thanks for the response.

    Yes, I need 32bit in one burst to be able to communicate with the ADC I'm interfacing to.

    If I set "xlnx,num-transfer-bits = <0x8>" I still get the same behaviour. I actually get all four bytes of data out but only 1 byte per 32bit burst with a delay of ~20ms between each burst.

    I still get the following error message if I try to set bits_per_word = 32:

    spidev spi0.0: xilinx_spi_setup_transfer, unsupported bits_per_word=32
    [  604.640443] spi_master spi0: failed to transfer one message from queue

    This error message comes from the driver xilinx_spi but I cannot see why this should happen. Any ideas? Thanks!

    Br. Jacob

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube