mtd: spinand: Add support for SkyHigh S35ML-3 family
Subsystems (2)
v2 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 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/
PATCH v2 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().
--- drivers/mtd/nand/spi/core.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/mtd/nand/spi/core.c +0 -4
@@ -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/
Re: [PATCH v2 1/3] mtd: spinand: Remove write_enable_op() in markbad()
Quoted 4 lines · On 11/21/24 2:08 AM, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
We don't have to call
spinand_write_enable_op()inspinand_markbad()as it is called inspinand_write_page().
Indeed. The patch is a follow up for:
writing a bad block marker")
That commit removed spinand_erase_op(), but failed to remove spinand_write_enable_op() with it.
Miquel, shall the spinand_write_enable_op() call be moved into spinand_erase_op()?
Quoted 11 lines
Signed-off-by Takahiro Kuwano <[email protected]>--- drivers/mtd/nand/spi/core.c | 4 ---- 1 file changed, 4 deletions(-)drivers/mtd/nand/spi/core.c +0
-0
drivers/mtd/nand/spi/core.c static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos) · line 947
Quoted 10 lines
drivers/mtd/nand/spi/core.c +0
-4@@ -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); }
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH v2 1/3] mtd: spinand: Remove write_enable_op() in markbad()
Hello,
Quoted 9 lines · Tudor Ambarus
Quoted 4 lines · On 11/21/24 2:08 AM, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
We don't have to call
spinand_write_enable_op()inspinand_markbad()as it is called inspinand_write_page().Indeed. The patch is a follow up for:
Fixes b645ad39d568 ("mtd: spinand: Do not erase the block beforewriting a bad block marker")
Correct.
Takahiro, would you mind updating the commit log to mention that commit, please? It makes sense to have it mentioned. Otherwise the series looks good, I'll apply it once you send a v3.
Quoted 7 lines
That commit removed
spinand_erase_op(), but failed to removespinand_write_enable_op()with it.Reviewed-by Tudor Ambarus <[email protected]>Miquel, shall the
spinand_write_enable_op()call be moved intospinand_erase_op()?
Thanks a lot for the review!
spinand_erase_op() is just about the "op", not about handling an "mtd" erase. It is called from spinand_erase() which already does the spinand_write_enable_op() and I believe it makes more sense to keep it there, so when we browse the code we don't need to enter the low-level functions and immediately identify what operations we send to the chip without surprises.
Cheers,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 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
@@ -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
@@ -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/
PATCH v2 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
@@ -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
@@ -1131,6 +1131,7 @@ static const struct spinand_manufacturer *spinand_manufacturers[] = { ¯onix_spinand_manufacturer, µn_spinand_manufacturer, ¶gon_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
@@ -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/