Skip to content

Conversation

@anangl
Copy link
Contributor

@anangl anangl commented Jul 28, 2025

Cherry-pick commits from zephyrproject-rtos/zephyr#93093.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could the part not specific to mspi be moved to jesd216.h? Some defines used here are already in that header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed BFP_DW1_ADDR_* symbols and used instead corresponding ones from jesd216.h, but I don't think there's a point in adding some definitions in this file now. It's better to do it when implementing runtime SFDP processing, as probably some new decoding functions will be also added there.

set_up_xfer(dev, MSPI_TX);
rc = perform_xfer(dev, 0xE7, false);
if (rc < 0) {
LOG_ERR("Command 0xE7 failed: %d", rc);
Copy link
Contributor

Choose a reason for hiding this comment

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

__function__? 0xE7 seems cryptic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, it should be 0xB7, actually...
But the spec says "issue write enable instruction 06h, then issue instruction B7h", so I'm not sure if it's worth defining a symbol for it.

Copy link
Contributor Author

@anangl anangl Jul 30, 2025

Choose a reason for hiding this comment

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

fixed the command code

Comment on lines 66 to 76
/* Wait for previous write to finish */
rc = wait_until_ready(dev, K_USEC(1));
if (rc < 0) {
return rc;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong commit? This change is not mentioned in the commit description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This waiting here is not needed because quad_enable_set() waits after writing the status register. But I can mention this in the commit message so there's no doubt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added explanation of the change in the commit message.

@anangl anangl force-pushed the improve_flash_mspi_nor_ncs branch 3 times, most recently from edbb020 to cb4926c Compare July 31, 2025 06:26
anangl added 7 commits July 31, 2025 10:04
…rable

Although the value currently hard-coded in the driver (10 ms) is quite
high, it may turn out to be insufficient when there is a need to use
some very low SCK frequency, like 250 kHz.
Make the timeout value configurable per-instance, via devicetree.

Signed-off-by: Andrzej Głąbek <[email protected]>
(cherry picked from commit 7efa5c8)
Get parameters for used flash commands and requirements for enabling
Quad and Octal modes from dts uint8-arrays containing data read from
SFDP tables for particular flash chips.

Upstream PR #: 93093

Signed-off-by: Andrzej Głąbek <[email protected]>
- Use standard operation codes and parameters from SFDP for handling
  the used flash commands (allow to override some of them through dts
  with the `read-command`, `write-command`, and `rx-dummy` properties)
- Use all available erase types as specified by SFDP
- Allow using all IO modes
- Add support for switching to 4-byte addressing mode
- Use common functions for reading and writing of status registers
  and for enabling write operations
- Switch IO mode (between the target one and Single IO) in a common
  function that performs transfers and do it only when required for
  a given command

Upstream PR #: 93093

Signed-off-by: Andrzej Głąbek <[email protected]>
… handling of OER

Complete implementation of quad_enable_set() by adding support for all
possible Quad Enable Requirements (QER) as specified by the SFDP JEDEC
standard (JESD216). Add also corresponding octal_enable_set() to handle
Octal Enable Requirements.

Also remove initial waiting from mxicy_mx25r_post_switch_mode() which
became unneeded, as now such waiting is done in cmd_wrsr() which is
called at the end of quad_enable_set().

Upstream PR #: 93093

Signed-off-by: Andrzej Głąbek <[email protected]>
Add implementation of the most common Soft Reset routine (sequence of
reset enable instruction 0x66 and reset instruction 0x99).

Upstream PR #: 93093

Signed-off-by: Andrzej Głąbek <[email protected]>
…ad disabling

Using a GPIO reset for a flash chip that has a dual function pin
(RESET# or SIO3) and is to be used in Quad mode is rather a bad idea
and so is clearing of the Quad Enable bit at every initialization
of the flash driver, since this bit is usually non-volatile, so such
operation means unnecessary wearing of the flash chip. Soft Reset
should be use instead in such case.

Upstream PR #: 93093

Signed-off-by: Andrzej Głąbek <[email protected]>
…" property

Add support for supplying power to the flash chip by activation of
a GPIO specified through the "supply-gpios" property. Implementation
of gpio_reset() is also slightly modified so that it is consistent
with soft_reset() and the new power_supply() and so that all these
functions can use a common routine that performs a reset recovery
delay.

Upstream PR #: 93093

Signed-off-by: Andrzej Głąbek <[email protected]>
@anangl anangl force-pushed the improve_flash_mspi_nor_ncs branch from cb4926c to 646c849 Compare July 31, 2025 08:04
@anangl
Copy link
Contributor Author

anangl commented Jul 31, 2025

Rebased.

@anangl anangl merged commit 81ae924 into nrfconnect:main Jul 31, 2025
19 checks passed
@anangl anangl deleted the improve_flash_mspi_nor_ncs branch July 31, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants