Qspi
Qspi
Introduction
Table of Contents
Drivers can be found at /drivers/spi/spi-zynqmp-gqspi.c
MTD layer handles all the flash devices used with QSPI. This layer handles flash devices of different makes (Micron/Numonyx, Winbond and Spansion being
the most common)
of different sizes from 128Mbit to 1Gbit. The features of all flash devices are not alike and hence handled through different flags indicating the support.
This layer was customized by xilinx to support parallel and stacked configurations. It can be found at drivers/mtd/devices/m25p80.c on Xilinx Git
HW IP Features
The GQSPI controller used in Zynqmp supports the following features.- Support Low level (Generic) Access
- Support Future Commands
- Supports 3,4,6…N byte addressing
- Supports Command Queuing (Generic FIFO depth is 32)
- Supports 4 or 8-bit interface
- Supports 2 Chip Select Lines
- Supports 4-Bit Bi-Directional I/O signals
- Supports x1/x2/x4 Read/Write
- Supports 44-bit address space on AXI in DMA mode
- Supports byte stripe when two data buses are connected
- Supports single interrupt for QSPI/DMA Interrupt status
Driver Features
The Zynqmp GQSPI supports the following features:- Supports DMA for receiving the aligned data from the tx fifo.
- Supports PIO read for receiving the unaligned data from the rx fifo.
- Supports PIO write from programing page to the flash.
- Supports extended addressing.
- Supports SIngle,Dual Parallel and Dual Stacked configurations.
- Supports Normal and Quad read modes
Known issues and limitations
This driver supports GenericQSPI(GQSPI) not Linear QSPI(LQSPI)Xilinx GQSPI Driver Kernel Configuration
The following config options need to be enabledCONFIG_SPI_ZYNQMP_GQSPI
It depends on SPI_MASTER and HAS_DMA
CONFIG_SPI_ZYNQMP_GQSPI: │ │ │ │ Enables Xilinx GQSPI controller driver for Zynq UltraScale+ MPSoC. │ │ │ │ Symbol: SPI_ZYNQMP_GQSPI [=y] │ │ Type : tristate │ │ Prompt: Xilinx ZynqMP GQSPI controller │ │ Location: │ │ -> Device Drivers │ │ -> SPI support (SPI [=y]) │ │ Defined at drivers/spi/Kconfig:716 │ │ Depends on: SPI [=y] &&&& SPI_MASTER [=y] &&&& HAS_DMA [=y]
If required, enable MTD block devices support - MTD_BLKDEVS
Devicetree
Refer to Documentation/devicetree/bindings/spi/spi-zynqmp-qspi.txtfor complete description.
These are some specific points to be noted about the qspi properties:
- is-dual - Set if parallel. Reset if single or stacked.
Example:
The following example shows adding a QSPI node to the devicetree in single mode.
spi@ff0f0000 { compatible = "xlnx,zynqmp-qspi-1.0"; status = "okay"; clock-names = "ref_clk", "pclk"; interrupts = <0x0 0xf 0x4>; interrupt-parent = <0x1>; num-cs = <0x1>; reg = <0x0 0xff0f0000 0x0 0x1000 0x0 0xc0000000 0x0 0x8000000>; #address-cells = <0x1>; #size-cells = <0x0>; power-domains = <0x13>; clocks = <0x14 0x14>; is-dual = <0x0>; flash@0 { compatible = "m25p80"; reg = <0x0>; #address-cells = <0x1>; #size-cells = <0x1>; spi-max-frequency = <0x66ff300>; spi-tx-bus-width = <0x1>; spi-rx-bus-width = <0x4>; partition@0x00000000 { label = "qspi-fsbl-uboot"; reg = <0x0 0x4000000>; }; partition@0x01e40000 { label = "qspi-linux"; reg = <0x1e40000 0x1a00000>; }; partition@0x03840000 { label = "qspi-device-tree"; reg = <0x3840000 0x10000>; }; partition@qspi-linux { label = "qspi-rootfs"; reg = <0x100000 0x500000>; }; partition@qspi-rootfs { label = "qspi-bitstream"; reg = <0x620000 0x5e0000>; }; }; };
Testing Procedure
This section details the common tests using jffs2 and flashcp.
In order to test different flash sizes and configurations (single, parallel, stacked), the above devicetree should be modified and relevant hardware and design should be used.
QSPI flash testing with flashcp
#List the MTD partitions present and select a partition
cat /proc/mtd
dev: size erasesize name mtd0: 00400000 00020000 "qspi-fsbl-uboot" mtd1: 01a00000 00020000 "qspi-linux" mtd2: 00010000 00020000 "qspi-device-tree" mtd3: 00500000 00020000 "qspi-rootfs" mtd4: 005e0000 00020000 "qspi-bitstream"
dd if=/dev/urandom of=./sample.bin bs=1024 count=4096
4096+0 records in 4096+0 records out 4194304 bytes (4.0MB) copied, 3.227253 seconds, 1.2MB/s
flashcp -v ./smaple.bin /dev/mtd0
Erasing block: 32/32 (100%) Writing kb: 4088/4096 (99%) Verifying kb: 4088/4096 (99%)
QSPI flash testing with jffs2
#List the MTD partitions present and select a partition
cat /proc/mtd
dev: size erasesize name mtd0: 00400000 00020000 "qspi-fsbl-uboot" mtd1: 01a00000 00020000 "qspi-linux" mtd2: 00010000 00020000 "qspi-device-tree" mtd3: 05000000 00020000 "qspi-rootfs" mtd4: 005e0000 00020000 "qspi-bitstream"
#Erase a the whole partition with jffs2 markers
flash_eraseall -j /dev/mtd3
Erasing 128 Kibyte @ 5c0000 - 97% complete. Cleanmarker written at 5c0000. Erasing 128 Kibyte @ 5e0000 - 100% complete.
mkdir qspi_flash0
#Mount the partition to spi_flash0
mount -t jffs2 /dev/mtdblock3 /qspi_flash0
#Create a file to be written to the flash
dd if=/dev/urandom of=./sample.bin bs=1024 count=4096
4096+0 records in 4096+0 records out 4194304 bytes (4.0MB) copied, 3.227253 seconds, 1.2MB/s
cp ./sample.bin /qspi_flash0/
#Check the presence of the file(s) in spi_flash0
ls /qspi_flash0
sample.bin
umount spi_flash0
#Mount again - MTD 0 to spi_flash0
mount -t jffs2 /dev/mtdblock3 /qspi_flash0
#Compare the files - there should be no differences
diff ./sample.bin /qspi_flash0/sample.bin
#Unmount
umount qspi_flash0
The data can be verified again after a power on reset if desired.
Logs:
root@Xilinx-ZCU102-2016_1:~# root@Xilinx-ZCU102-2016_1:~# cat /proc/mtd dev: size erasesize name mtd0: 00400000 00002000 "qspi-fsbl-uboot" mtd1: 01a00000 00002000 "qspi-linux" mtd2: 00020000 00002000 "qspi-device-tree"1 mtd3: 005e0000 00002000 "qspi-rootfs" mtd4: 00500000 00002000 "qspi-bit-stream" root@Xilinx-ZCU102-2016_1:~# root@Xilinx-ZCU102-2016_1:~# dmesg | grep "spi" [ 2.947332] m25p80 spi0.0: found n25q512a, expected m25p80 [ 2.952738] [spi_nor_scan]: read_opcode = 0x3b [ 2.957158] [spi_nor_scan]: program_opcode = 0x2 [ 2.961807] [spi_nor_scan]: addr_width=4 [ 2.965668] [spi_nor_scan]: read_dummy = 8 [ 2.969746] m25p80 spi0.0: n25q512a (65536 Kbytes) [ 2.974532] 4 ofpart partitions found on MTD device spi0.0 [ 2.979986] Creating 4 MTD partitions on "spi0.0": [ 2.984763] 0x000000000000-0x000000400000 : "qspi-fsbl-uboot" [ 2.991031] 0x000001e40000-0x000003840000 : "qspi-linux" [ 2.996731] 0x000003840000-0x000003860000 : "qspi-device-tree" [ 3.002990] 0x000000100000-0x0000006E0000 : "qspi-rootfs" root@Xilinx-ZCU102-2016_1:~#
MTD Speed test: root@Xilinx-ZCU102-2016_1:~# root@Xilinx-ZCU102-2016_1:~# insmod /lib/modules/4.4.0+/kernel/drivers/sp mtd/te <# insmod /lib/modules/4.4.0+/kernel/drivers/mtd/tes ts/mtd_speedtest.ko dev=2 [ 261.298795] ================================================= [ 261.304512] mtd_speedtest: MTD device: 2 [ 261.308414] mtd_speedtest: not NAND flash, assume page size is 512 bytes. [ 261.315185] mtd_speedtest: MTD device size 131072, eraseblock size 4096, page size 512, count of eraseblocks 32, pages per eraseblock 8, OOB size 0 [ 261.454323] mtd_speedtest: testing eraseblock write speed [ 261.581574] mtd_speedtest: eraseblock write speed is 1057 KiB/s [ 261.587410] mtd_speedtest: testing eraseblock read speed [ 261.601605] mtd_speedtest: eraseblock read speed is 16000 KiB/s [ 262.821979] mtd_speedtest: testing page write speed [ 262.949098] mtd_speedtest: page write speed is 1049 KiB/s [ 262.954411] mtd_speedtest: testing page read speed [ 262.981224] mtd_speedtest: page read speed is 5818 KiB/s [ 264.200981] mtd_speedtest: testing 2 page write speed [ 264.328393] mtd_speedtest: 2 page write speed is 1049 KiB/s [ 264.333881] mtd_speedtest: testing 2 page read speed [ 264.353385] mtd_speedtest: 2 page read speed is 9142 KiB/s [ 264.358784] mtd_speedtest: Testing erase speed [ 265.581894] mtd_speedtest: erase speed is 105 KiB/s [ 265.586683] mtd_speedtest: Testing 2x multi-block erase speed [ 265.719973] mtd_speedtest: 2x multi-block erase speed is 1007 KiB/s [ 265.726154] mtd_speedtest: Testing 4x multi-block erase speed [ 265.859429] mtd_speedtest: 4x multi-block erase speed is 1007 KiB/s [ 265.865614] mtd_speedtest: Testing 8x multi-block erase speed [ 265.998655] mtd_speedtest: 8x multi-block erase speed is 1007 KiB/s [ 266.004832] mtd_speedtest: Testing 16x multi-block erase speed [ 266.139297] mtd_speedtest: 16x multi-block erase speed is 1000 KiB/s [ 266.145563] mtd_speedtest: Testing 32x multi-block erase speed [ 266.278941] mtd_speedtest: 32x multi-block erase speed is 1007 KiB/s [ 266.285206] mtd_speedtest: Testing 64x multi-block erase speed [ 266.418343] mtd_speedtest: 64x multi-block erase speed is 1007 KiB/s [ 266.424616] mtd_speedtest: finished [ 266.428086] ================================================= root@Xilinx-ZCU102-2016_1:~#
Changelog
- 2016.3
- Added tap delay support
Related Links
© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy