[PATCH v3 00/15] mtd: spi-nor: macronix: workaround for device id re-use

From: Esben Haabendal
Date: Thu Jul 11 2024 - 09:02:01 EST


Following up to various discussions, this series have now been
modified so that it gets rid of the old deprecated approach
for detecting when to do optional SFDP parsing.

Before these changes, spi-nor flashes were handled in 4 different
ways:

(1) SFDP only [size==0]

(2a) static config only [size!=0 && no_sfdp_flags & SPI_NOR_SKIP_SFDP]

(2b) static config only
[size!=0 &&
!(no_sfdp_flags & (SPI_NOR_SKIP_SFDP |
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
SPI_NOR_OCTAL_READ | SPI_NOR_OCTAL_DTR_READ))]

(3) SFDP with fallback to static config
[size!=0 &&
!(no_sfdp_flags & SPI_NOR_SKIP_SFDP) &&
(no_sfdp_flags & SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
SPI_NOR_OCTAL_READ | SPI_NOR_OCTAL_DTR_READ))]

Cases (2a) and (2b) have been handled slightly different, with
manufacturer and flash_info ->default_init() hooks being called in
case (2b) but not in case (2a).

With this series, that is changed to this simpler approach instead:

(1) SFDP only [size==0]

(2) static config only
[size!=0 && !(no_sfdp_flags & SPI_NOR_TRY_SFDP)]

(3) SFDP with fallback to static config
[size!=0 && (no_sfdp_flags & SPI_NOR_TRY_SFDP)]

Existing struct flash_info entries are modified, so that all those
that was case (2a) or (2b) are now case (2), and those that were (1)
and (3) are still (1) and (3).

As a consequence, the SPI_NOR_SKIP_SFDP flag is no more, and all
drivers that have been doing optional SFDP is now marked explicitly to
do that using the SPI_NOR_TRY_SFDP.

It is possible that some of these flashes does not really need to try
SFDP parsing, but as I am unable to test such changes, I will have to
leave that up to someone with access to hardware to do that. The
patches for doing that will be trivial, it is only a matter of testing.

As for the name of the flag, I guess that is still up for discussion.
I think SPI_NOR_TRY_SFDP explains pretty well what is the purpose, but
I am not really that attached to it.

As for the change in macronix.c for the mx25l3205d flash_info entry,
I only have access to boards with MX25L3233F flashes, so haven't been
able to test the backwards compatibility with the old MX25L3205D and
MX25L3206E flashes sharing flash ID with MX25L3233F. If anybody has
boards with MX25L3205D and/or MX25L3206E, please help test this patch.
Keep an eye for read performance regression.

It is worth nothing that both MX25L3205D and MX25L3206E are
end-of-life, and is unavailable from Macronix, so any new boards
featuring a Macronix flash with this ID will likely be using
MX25L3233F.

Signed-off-by: Esben Haabendal <esben@xxxxxxxxxx>
---
Changes in v3:
- Revised patch 1 in preparation for implementation of the new way of
detecting when to do optiona SFDP, as described above.
- Added patch 3 that aligns the handling of default_init() hooks to be
the same for case (2a) and case (2b) described above.
- Added patches for all spi-nor flash drivers to apply the
SPI_NOR_TRY_SFDP flag instead of relying on the "magic flags"
detection.
- Added patch dropping the deprecated "magic flags" code. This depends
on the merging of all the patches applying SPI_NOR_TRY_SFDP to
flash_info entries.
- Added patch dropping the SPI_NOR_SKIP_SFDP flag.
- Link to v2: https://lore.kernel.org/r/20240603-macronix-mx25l3205d-fixups-v2-0-ff98da26835c@xxxxxxxxxx

Changes in v2:
- Added new flag (SPI_NOR_TRY_SFDP) to spi-nor core to allow trying
SFDP and fallback to legacy parameters without having to specify
DUAL/QUAD parameters.
- Rewrite macronix to use SPI_NOR_TRY_SFDP flag.
- Use with the ancient EoL MX25L3205D chip will not get speed
increase, but stay at 1-bit mode as it is now.
- Link to v1: https://lore.kernel.org/r/20240524-macronix-mx25l3205d-fixups-v1-1-ee152e56afb3@xxxxxxxxxx

---
Esben Haabendal (15):
mtd: spi-nor: core: add flag for doing optional SFDP parsing
mtd: spi-nor: macronix: enable quad/dual speed for mx25l3205d chips
mtd: spi-nor: Align default_init() handling for SPI_NOR_SKIP_SFDP
mtd: spi-nor: atmel: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: eon: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: gigadevice: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: issi: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: macronix: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: micron-st: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: spansion: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: sst: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: winbond: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: xmc: Use new SPI_NOR_TRY_SFDP flag
mtd: spi-nor: Drop deprecated mechanism for optional SFDP parsing
mtd: spi-nor: spansion: Drop redundant SPI_NOR_SKIP_SFDP flag

drivers/mtd/spi-nor/atmel.c | 2 +-
drivers/mtd/spi-nor/core.c | 48 ++++++++++++----------------------------
drivers/mtd/spi-nor/core.h | 19 +++++++++++++---
drivers/mtd/spi-nor/eon.c | 6 ++---
drivers/mtd/spi-nor/gigadevice.c | 16 +++++++-------
drivers/mtd/spi-nor/issi.c | 18 +++++++--------
drivers/mtd/spi-nor/macronix.c | 26 +++++++++++-----------
drivers/mtd/spi-nor/micron-st.c | 41 +++++++++++++++++-----------------
drivers/mtd/spi-nor/spansion.c | 46 +++++++++++++++++++-------------------
drivers/mtd/spi-nor/sst.c | 6 ++---
drivers/mtd/spi-nor/winbond.c | 32 +++++++++++++--------------
drivers/mtd/spi-nor/xmc.c | 4 ++--
12 files changed, 129 insertions(+), 135 deletions(-)
---
base-commit: a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6
change-id: 20240524-macronix-mx25l3205d-fixups-882e92eed7d7

Best regards,
--
Esben Haabendal <esben@xxxxxxxxxx>