Zephyr Cadence SPI Driver Support
This page gives an overview of the Cadence SPI Zephyr driver which is available as part of the zephyr-amd repo.
HW Features
Master mode
Slave mode
All SPI flash instructions
Support for 3 slaves - can be extended using a 3 to 8 decoder
Driver uses manual chip select and auto start options
Programmable clock frequency, polarity, and phase
Interrupt support
Design Notes
N/A
Implementation
Features Supported
Master mode
All SPI flash instructions
Support for 3 slaves - can be extended using a 3 to 8 decoder
Programmable clock frequency, polarity, and phase
Driver uses manual chip select
Auto start options / Manual start options
Polled and Interrupt mode
Synchronous
Missing Features
Asynchronous
Slave mode
Known Issues
N/A
Limitations
Kernel Configuration
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MAIN_STACK_SIZE=2048
Device Tree
Example SPI Node
spi0: spi@f1970000 { compatible = "cdns,spi-r1p6"; status = "okay"; reg = <0xf1970000 0x1000>; interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>; #address-cells = <1>; #size-cells = <0>; cdns,num-ss-bits = <0x3>; is-decoded-cs = <0x00>; clocks = <&spi_ref_clk>; flash@2 { compatible = "jedec,spi-nor"; reg = <0x02>; spi-max-frequency = <8000000>; jedec-id = [ c2 25 36 ]; /*mx25u3235f*/ size = <33554432>; /*32Mb*/ has-dpd; t-enter-dpd = <10000>; t-exit-dpd = <35000>; }; }; spi_ref_clk: spi_ref_clk { compatible = "fixed-clock"; clock-frequency = <199998001>; #clock-cells = <0> ; };
Driver Stack Size
TBD
Test Platform
Tenzing2_se7 RPU
Test SoC Architecture
RPU - R52 Core
Testing Sequence
Build zephyr application for R52 core
west build -p -b <board> <sample application path>Flash Ztets: west build -p always -b tenzing2_se7_rpu tests/drivers/flash/common/ –forceFlash Samples: west build -p always -b tenzing2_se7_rpu samples/drivers/spi_flash/ –force
Run zephyr elf on Tenzing2_se7 RPU
Example Tests
Test Name |
Example Source |
Description |
|---|---|---|
Flash Ztest |
tests/drivers/flash/common/ |
These tests focus on the correct functionality of the flash drivers, covering cases such as:
|
Flash Example test |
samples/drivers/spi_flash/ |
This example application performs basic Erase/Write/ Read on spi-nor flash using SPI driver |
Code Coverage
Code coverage with flash z-tests and example tests:
Flash example test
Lines: 81.5%
Functions: 80.2%
Branches: 62.9%
Flash ztests
Lines: 81.5%
Functions: 80.2%
Branches: 60.6%
Expected Output
Connecting to device com0. Use Ctrl-\ to escape.
*** Booting Zephyr OS build xilinx_v2024.2 ***
Running TESTSUITE flash_driver
===================================================================
Test will run on device flash@2
START - test_flash_fill
PASS - test_flash_fill in 0.966 seconds
===================================================================
START - test_flash_flatten
PASS - test_flash_flatten in 0.916 seconds
===================================================================
START - test_read_unaligned_address
PASS - test_read_unaligned_address in 0.318 seconds
===================================================================
TESTSUITE flash_driver succeeded
------ TESTSUITE SUMMARY START ------
SUITE PASS - 100.00% [flash_driver]: pass = 3, fail = 0, skip = 0, total = 3 duration = 2.200 seconds
PASS - [flash_driver.test_flash_fill] duration = 0.966 seconds
PASS - [flash_driver.test_flash_flatten] duration = 0.916 seconds
PASS - [flash_driver.test_read_unaligned_address] duration = 0.318 seconds
------ TESTSUITE SUMMARY END ------
===================================================================
Performance Metric
TBA
Mainline Status
Not in mainline as of March 19, 2025.
Driver Source Path
drivers/spi/spi_cdns.c
Misra C Report
TBA