Skip to content

drivers: spi: Added ZynqMP Generic Quad SPI driver #88466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

robhancocksed
Copy link
Contributor

Add a driver for the Generic Quad SPI hardware that is part of the Xilinx MPSoC. This is mostly commonly used with QSPI flash devices which are also used for initial image loading, but can also be used with other SPI devices.

Also added corresponding settings for the QSPI device and emulated flash devices for the QEMU Cortex-R5 board.

@robhancocksed
Copy link
Contributor Author

Ping.. any feedback?

@robhancocksed
Copy link
Contributor Author

Ping, needs review

@AmitMahapatra
Copy link

Hello @robhancocksed

I ran Ztest suite and sample tests for flash devices with the patch series. The tests passed on QEMU but are failing on the actual hardware.

regards,
Amit

@robhancocksed
Copy link
Contributor Author

@AmitMahapatra , note that if you are testing on boards with certain Micron flash devices, such as ZCU102, you will need the patches from #88467 since those devices require the flag status register to be read after each program operation, otherwise they get into a state where all following reads return zeros. You will also need the appropriate flags in DT to enable that usage. These are the DT entries I have at the board level which are working for me on ZCU102 with those patches in place:

&qspi {
	status = "okay";
	clock-frequency = <124987511>;

	flash@0 {
		compatible = "jedec,spi-nor";
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0x0>;
		spi-max-frequency = <166000000>;
		use-flag-status-register;
		use-fast-read;
	};

	flash@1 {
		compatible = "jedec,spi-nor";
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0x1>;
		spi-max-frequency = <166000000>;
		use-flag-status-register;
		use-fast-read;
	};
};

return -ENOTSUP;
}

if ((spi_cfg->operation & SPI_LINES_MASK) == SPI_LINES_OCTAL) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can skip dual and octal too, there is nothing in the SPI API to enable the proper use of dual/quad/octal. (there was a plan to do so years ago...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does have support for basic dual/quad reads/writes which might be useful for some use cases. However, as you noted the SPI API would probably need more fine-grained control to be usable for QSPI flash in those modes, for example..

@robhancocksed robhancocksed force-pushed the add-zynqmp-gqspi-driver branch from 9c34a65 to 19591cc Compare June 16, 2025 21:58
@robhancocksed
Copy link
Contributor Author

Rebased to main, and added a fix for the shared-data-bus DT parameter not taking effect properly.

Comment on lines 252 to 262
if (spi_cfg->operation & SPI_MODE_CPOL) {
data->spi_cfg |= GQSPI_CFG_CLK_PH_MASK;
} else {
data->spi_cfg &= ~GQSPI_CFG_CLK_PH_MASK;
}

if (spi_cfg->operation & SPI_MODE_CPHA) {
data->spi_cfg |= GQSPI_CFG_CLK_POL_MASK;
} else {
data->spi_cfg &= ~GQSPI_CFG_CLK_POL_MASK;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POL and PH swapped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fixed now.

@kartben kartben requested a review from Copilot June 16, 2025 22:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Generic Quad SPI (GQSPI) driver for the Xilinx ZynqMP platform along with the necessary device tree bindings and configuration updates for both hardware and emulated environments.

  • Added a dts binding file for the ZynqMP QSPI interface.
  • Updated device tree source (DTS) files to integrate the new QSPI node configurations for both ARM and QEMU boards.
  • Added Kconfig and CMakeLists entries to enable building the new driver.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
dts/bindings/spi/xlnx,zynqmp-qspi-1.0.yaml New binding file defining properties for the ZynqMP QSPI driver.
dts/arm/xilinx/zynqmp.dtsi Added QSPI node configuration for integration with the DT.
drivers/spi/Kconfig.xlnx_zynqmp_gqspi New Kconfig file for enabling the ZynqMP GQSPI driver.
drivers/spi/Kconfig Updated to source the new Kconfig file.
drivers/spi/CMakeLists.txt Added driver source file for the ZynqMP GQSPI driver.
boards/qemu/cortex_r5/qemu_cortex_r5.dts Enabled QSPI and updated flash definitions for the QEMU board.
boards/qemu/cortex_r5/Kconfig.defconfig Added default configuration for SPI NOR SFDP selection.

@robhancocksed robhancocksed force-pushed the add-zynqmp-gqspi-driver branch from 19591cc to 181c42c Compare June 16, 2025 22:45
Add a driver for the Generic Quad SPI hardware that is part of the
Xilinx MPSoC. This is mostly commonly used with QSPI flash devices which
are also used for initial image loading, but can also be used with other
SPI devices.

Signed-off-by: Robert Hancock <[email protected]>
Added device tree entries for the QSPI device and the flash devices
which are present behind it on this emulated board.

Signed-off-by: Robert Hancock <[email protected]>
Currently ZynqMP board setups do not appear to be using the flash0 node
which is used for running in XIP mode from QSPI flash storage. Mark this
node as disabled to avoid tripping up the
drivers.flash.common.disable_spi_nor tests, which would otherwise try to
build with FLASH enabled and SPI_NOR disabled.

Signed-off-by: Robert Hancock <[email protected]>
@robhancocksed robhancocksed force-pushed the add-zynqmp-gqspi-driver branch from 9768032 to c876ea7 Compare June 18, 2025 19:32
@github-actions github-actions bot requested a review from decsny June 18, 2025 19:33
Copy link

@robhancocksed robhancocksed requested a review from kartben June 19, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants