Skip to contentSkip to conversation

mtd: spinand: Add support for SkyHigh S35ML-3 family

PATCH Applied [email protected] 2 participants 5 messages Dec 3, 2024 – Dec 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover mtd: spinand: Add support for SkyHigh S35ML-3 family

From: Takahiro Kuwano <[email protected]>

This series is successor of the patch submitted by KR Kim:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Changes in v3:
- Add Fixes tag to the patch 1/3

Changes in v2:
- Add new patch that removes redundant write enable in markbad()
- Make ondie ECC engine ops return error in raw access case and add fallback mechanism in isbad() and markbad()
- Add detailed comment about block lock register in Skyhigh driver

Takahiro Kuwano (3):
mtd: spinand: Remove write_enable_op() in markbad()
mtd: spinand: Introduce a way to avoid raw access
mtd: spinand: Add support for SkyHigh S35ML-3 family

 drivers/mtd/nand/spi/Makefile  |   2 +-
 drivers/mtd/nand/spi/core.c    |  25 ++++--
 drivers/mtd/nand/spi/skyhigh.c | 147 +++++++++++++++++++++++++++++++++
 include/linux/mtd/spinand.h    |   2 +
 4 files changed, 170 insertions(+), 6 deletions(-)
 create mode 100644 drivers/mtd/nand/spi/skyhigh.c
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw

PATCH v3 1/3 mtd: spinand: Remove write_enable_op() in markbad()

From: Takahiro Kuwano <[email protected]>

We don't have to call spinand_write_enable_op() in spinand_markbad() as it is called in spinand_write_page().

Fixes b645ad39d568 ("mtd: spinand: Do not erase the block before writing a bad block marker")
---
 drivers/mtd/nand/spi/core.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/mtd/nand/spi/core.c +0 -4
index 4d76f9f71a0e..47c369f2925d 100644
@@ -942,10 +942,6 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
 	if (ret)
 		return ret;
 
-	ret = spinand_write_enable_op(spinand);
-	if (ret)
-		return ret;
-
 	return spinand_write_page(spinand, &req);
 }
 
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#2 lore raw

PATCH v3 2/3 mtd: spinand: Introduce a way to avoid raw access

In reply to [email protected]

From: Takahiro Kuwano <[email protected]>

SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed.

Introduce SPINAND_NO_RAW_ACCESS flag to advertise the device does not support raw access. In such devices, the on-die ECC engine ops returns error to I/O request in raw mode.

Checking and marking BBM need to be cared as special case, by adding fallback mechanism that tries read/write OOB with ECC enabled.

---
 drivers/mtd/nand/spi/core.c | 22 ++++++++++++++++++++--
 include/linux/mtd/spinand.h |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/mtd/nand/spi/core.c +20 -2
index 47c369f2925d..2ff3c32d46d3 100644
@@ -294,6 +294,9 @@ static int spinand_ondie_ecc_prepare_io_req(struct nand_device *nand,
 	struct spinand_device *spinand = nand_to_spinand(nand);
 	bool enable = (req->mode != MTD_OPS_RAW);
 
+	if (!enable && spinand->flags & SPINAND_NO_RAW_ACCESS)
+		return -EOPNOTSUPP;
+
 	memset(spinand->oobbuf, 0xff, nanddev_per_page_oobsize(nand));
 
 	/* Only enable or disable the engine */
@@ -901,9 +904,17 @@ static bool spinand_isbad(struct nand_device *nand, const struct nand_pos *pos)
 		.oobbuf.in = marker,
 		.mode = MTD_OPS_RAW,
 	};
+	int ret;
 
 	spinand_select_target(spinand, pos->target);
-	spinand_read_page(spinand, &req);
+
+	ret = spinand_read_page(spinand, &req);
+	if (ret == -EOPNOTSUPP) {
+		/* Retry with ECC in case raw access is not supported */
+		req.mode = MTD_OPS_PLACE_OOB;
+		spinand_read_page(spinand, &req);
+	}
+
 	if (marker[0] != 0xff || marker[1] != 0xff)
 		return true;
 
@@ -942,7 +953,14 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
 	if (ret)
 		return ret;
 
-	return spinand_write_page(spinand, &req);
+	ret = spinand_write_page(spinand, &req);
+	if (ret == -EOPNOTSUPP) {
+		/* Retry with ECC in case raw access is not supported */
+		req.mode = MTD_OPS_PLACE_OOB;
+		ret = spinand_write_page(spinand, &req);
+	}
+
+	return ret;
 }
 
 static int spinand_mtd_block_markbad(struct mtd_info *mtd, loff_t offs)
include/linux/mtd/spinand.h +1 -0
index 702e5fb13dae..5cf11005b41a 100644
@@ -314,6 +314,7 @@ struct spinand_ecc_info {
 #define SPINAND_HAS_CR_FEAT_BIT		BIT(1)
 #define SPINAND_HAS_PROG_PLANE_SELECT_BIT		BIT(2)
 #define SPINAND_HAS_READ_PLANE_SELECT_BIT		BIT(3)
+#define SPINAND_NO_RAW_ACCESS				BIT(4)
 
 /**
  * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#3 lore raw

PATCH v3 3/3 mtd: spinand: Add support for SkyHigh S35ML-3 family

In reply to [email protected]

From: Takahiro Kuwano <[email protected]>

SkyHigh S35ML01G300, S35ML01G301, S35ML02G300, and S35ML04G300 are 1Gb, 2Gb, and 4Gb SLC SPI NAND flash family. This family of devices has on-die ECC which parity bits are stored to hidden area. In this family the on-die ECC cannot be disabled so raw access needs to be prevented.

---
 drivers/mtd/nand/spi/Makefile  |   2 +-
 drivers/mtd/nand/spi/core.c    |   1 +
 drivers/mtd/nand/spi/skyhigh.c | 147 +++++++++++++++++++++++++++++++++
 include/linux/mtd/spinand.h    |   1 +
 4 files changed, 150 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/skyhigh.c
drivers/mtd/nand/spi/Makefile +1 -1
index 19cc77288ebb..1e61ab21893a 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 spinand-objs := core.o alliancememory.o ato.o esmt.o foresee.o gigadevice.o macronix.o
-spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o
+spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +1 -0
index 2ff3c32d46d3..77aa77ea4564 100644
@@ -1131,6 +1131,7 @@ static const struct spinand_manufacturer *spinand_manufacturers[] = {
 	&macronix_spinand_manufacturer,
 	&micron_spinand_manufacturer,
 	&paragon_spinand_manufacturer,
+	&skyhigh_spinand_manufacturer,
 	&toshiba_spinand_manufacturer,
 	&winbond_spinand_manufacturer,
 	&xtx_spinand_manufacturer,
drivers/mtd/nand/spi/skyhigh.c new file +147 -0

147 lines not on this page · raw message

include/linux/mtd/spinand.h +1 -0
index 5cf11005b41a..cbbcd44ac225 100644
@@ -268,6 +268,7 @@ extern const struct spinand_manufacturer gigadevice_spinand_manufacturer;
 extern const struct spinand_manufacturer macronix_spinand_manufacturer;
 extern const struct spinand_manufacturer micron_spinand_manufacturer;
 extern const struct spinand_manufacturer paragon_spinand_manufacturer;
+extern const struct spinand_manufacturer skyhigh_spinand_manufacturer;
 extern const struct spinand_manufacturer toshiba_spinand_manufacturer;
 extern const struct spinand_manufacturer winbond_spinand_manufacturer;
 extern const struct spinand_manufacturer xtx_spinand_manufacturer;
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer Applied
#4 lore raw
In reply to [email protected]
Quoted 9 lines · On Tue, 03 Dec 2024 11:46:47 +0900, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This series is successor of the patch submitted by KR Kim:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Changes in v3:
- Add Fixes tag to the patch 1/3

[...]

Applied to nand/next, thanks!

[1/3] mtd: spinand: Remove write_enable_op() in markbad() [2/3] mtd: spinand: Introduce a way to avoid raw access [3/3] mtd: spinand: Add support for SkyHigh S35ML-3 family

Patche(s) will be available within hours on:
mtd/linux.git

Kind regards,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/