Skip to content

drivers: flash: flash_stm32_qspi: Make CS high time configurable #92742

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 4 commits into
base: main
Choose a base branch
from

Conversation

taltenbach
Copy link
Contributor

The STM32 QUADSPI peripheral allows to configure, in clock cycles, the duration the chip select signal must stay high between each command sent to the flash memory controller (QUADSPI_DCR_CSHT).

This value should be configured according to:

  • The minimal duration specified by the flash memory's datasheet (usually denoted "tSHSL", typically 30-50 ns).
  • The QSPI's clock frequency.

Currently, this value is set by the flash driver to 1 clock cycle in single flash mode and 3 clock cycles in dual flash mode. This may be too low for some configurations. In particular, in single flash mode, the current value is out-of-spec for all board configurations provided by Zephyr.

This MR adds a new devicetree property allowing to set the chip-select high time value according to the flash memory specifications and the QSPI configuration.

Secondarily, this MR also enables the 1/2 sample shift feature of the QUADSPI peripheral in both single and dual flash mode.


From RM0433:
Screenshot From 2025-07-06 02-31-35

From MT25QL512 datasheet (used on the STM32H747I-DISCO board):
Screenshot From 2025-07-06 02-37-17
Screenshot From 2025-07-06 02-35-47

The QSPI 1/2 sample shift (SSHIFT) was only enabled in dual flash mode.
This feature is useful to guarantee that data is ready at the sampling
moment, even if the signals are a bit delayed due to PCB constraints.
Therefore, it should be enabled when possible (only supported in STR
mode).

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
The STM32 QUADSPI peripheral allows to configure, in clock cycles, the
duration the chip select signal must stay high between each command sent
to the flash memory controller (QUADSPI_DCR_CSHT).

Currently, this value is set by the flash driver to 1 clock cycle in
single flash mode and 3 clock cycles in dual flash mode. However, the
minimal duration depends on the flash memory (typically 30-50 ns) and
the number of clock cycles on the QSPI's clock frequency. So, adding
this new property allows to select the value of CSHT to match the
requirement of the flash memory used. Also note that in single flash
mode, the current configuration is out-of-spec for most flash memories.

A default value of 4 clock cycles is used. This is enough for all board
configurations currently provided by Zephyr (flash memory needing up 50
ns and frequency up to 80 MHz).

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
This commit set the value of the cs-high-time property for all
STM32-based boards defined in Zephyr and having a QSPI flash memory.
The value is chosen according to the flash memory requirements (often
named 'tSHSL' in the datasheets) and the maximum QSPI frequency.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
This commit adds support for the new cs-high-time devicetree property.
The QUADSPI_DCR_CSHT is now configured according to the value indicated
in the devicetree, for both single and dual flash modes.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
Copy link

sonarqubecloud bot commented Jul 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants