[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220309141702.173879-5-tudor.ambarus@microchip.com>
Date: Wed, 9 Mar 2022 16:17:01 +0200
From: Tudor Ambarus <tudor.ambarus@...rochip.com>
To: <p.yadav@...com>, <michael@...le.cc>
CC: <miquel.raynal@...tlin.com>, <richard@....at>, <vigneshr@...com>,
<linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
"Tudor Ambarus" <tudor.ambarus@...rochip.com>
Subject: [PATCH 4/5] mtd: spi-nor Favor the BFPT-parsed Quad Enable method
JESD216 SFDP defines in the BFPT standard methods to enable Quad Mode. The
flash parameters and settings that are retrieved from SFDP have higher
precedence than the static initialized ones, because they should be more
accurate and less error prone than those initialized statically. Favor the
BFPT-parsed Quad Enable method and use the generic core methods where
possible.
This patch may introduce regressions in case BFPT contains wrong data. The
fix is to introduce a post_bfpt() fixup hook and update the wrong BFPT
data.
Signed-off-by: Tudor Ambarus <tudor.ambarus@...rochip.com>
---
drivers/mtd/spi-nor/core.c | 5 +++--
drivers/mtd/spi-nor/issi.c | 4 ++--
drivers/mtd/spi-nor/macronix.c | 14 ++++++--------
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 5de46a786cc5..9a5299a7b212 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2427,9 +2427,11 @@ static void spi_nor_late_init_params(struct spi_nor *nor)
if (nor->info->fixups && nor->info->fixups->late_init)
nor->info->fixups->late_init(nor);
- /* Default method kept for backward compatibility. */
+ /* Default methods kept for backward compatibility. */
if (!params->set_4byte_addr_mode)
params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_brwr;
+ if (!params->quad_enable)
+ params->quad_enable = spi_nor_sr2_bit1_quad_enable;
spi_nor_init_flags(nor);
spi_nor_init_fixup_flags(nor);
@@ -2497,7 +2499,6 @@ static void spi_nor_init_default_params(struct spi_nor *nor)
const struct flash_info *info = nor->info;
struct device_node *np = spi_nor_get_flash_node(nor);
- params->quad_enable = spi_nor_sr2_bit1_quad_enable;
params->otp.org = &info->otp_org;
/* Default to 16-bit Write Status (01h) Command */
diff --git a/drivers/mtd/spi-nor/issi.c b/drivers/mtd/spi-nor/issi.c
index c012bc2486e1..0fefda46ccad 100644
--- a/drivers/mtd/spi-nor/issi.c
+++ b/drivers/mtd/spi-nor/issi.c
@@ -69,13 +69,13 @@ static const struct flash_info issi_nor_parts[] = {
NO_SFDP_FLAGS(SECT_4K) },
};
-static void issi_nor_default_init(struct spi_nor *nor)
+static void issi_nor_late_init(struct spi_nor *nor)
{
nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
}
static const struct spi_nor_fixups issi_fixups = {
- .default_init = issi_nor_default_init,
+ .late_init = issi_nor_late_init,
};
const struct spi_nor_manufacturer spi_nor_issi = {
diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index c267cbcc7f1d..4fd65d55388a 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -102,20 +102,18 @@ static const struct flash_info macronix_nor_parts[] = {
FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
};
-static void macronix_nor_default_init(struct spi_nor *nor)
-{
- nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
-}
-
static void macronix_nor_late_init(struct spi_nor *nor)
{
- if (!nor->params->set_4byte_addr_mode)
- nor->params->set_4byte_addr_mode =
+ struct spi_nor_flash_parameter *params = nor->params;
+
+ if (!params->set_4byte_addr_mode)
+ params->set_4byte_addr_mode =
spi_nor_set_4byte_addr_mode_en4b_ex4b;
+ if (!params->quad_enable)
+ params->quad_enable = spi_nor_sr1_bit6_quad_enable;
}
static const struct spi_nor_fixups macronix_nor_fixups = {
- .default_init = macronix_nor_default_init,
.late_init = macronix_nor_late_init,
};
--
2.25.1
Powered by blists - more mailing lists