All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spinand: winbond: add support for W25N04LV
@ 2026-08-16  9:31 ` Huasin Liao
  0 siblings, 0 replies; 4+ messages in thread
From: Huasin Liao @ 2026-08-16  9:31 UTC (permalink / raw)
  To: miquel.raynal, vigneshr
  Cc: richard, tudor.ambarus, linux-mtd, linux-kernel, huasin.liao,
	Huasin Liao

Add support for the Winbond W25N04LV. Tested on an Airoha
AN7581-based board with the on-board W25N04LV, verified
erase/read/write.

Link: https://www.winbond.com/hq/product/code-storage-flash-memory/qspinand-flash/?__locale=en&partNo=W25N04LV
Cc: huasin.liao@airoha.com
Signed-off-by: Huasin Liao <huasinliao@gmail.com>
---
 drivers/mtd/nand/spi/winbond.c | 38 ++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 9b78c1e6cbc9..892220a12b22 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -345,6 +345,35 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
 	.free = w25n02kv_ooblayout_free,
 };
 
+static int w25n04lv_ooblayout_ecc(struct mtd_info *mtd, int section,
+				  struct mtd_oob_region *region)
+{
+	if (section > 7)
+		return -ERANGE;
+
+	region->offset = 128 + (16 * section);
+	region->length = 13;
+
+	return 0;
+}
+
+static int w25n04lv_ooblayout_free(struct mtd_info *mtd, int section,
+				   struct mtd_oob_region *region)
+{
+	if (section > 7)
+		return -ERANGE;
+
+	region->offset = (16 * section) + 2;
+	region->length = 14;
+
+	return 0;
+}
+
+static const struct mtd_ooblayout_ops w25n04lv_ooblayout = {
+	.ecc = w25n04lv_ooblayout_ecc,
+	.free = w25n04lv_ooblayout_free,
+};
+
 static int w25n01jw_ooblayout_ecc(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *region)
 {
@@ -759,6 +788,15 @@ static const struct spinand_info winbond_spinand_table[] = {
 					      &update_cache_variants),
 		     0,
 		     SPINAND_ECCINFO(&w25n02kv_ooblayout, w25n02kv_ecc_get_status)),
+	SPINAND_INFO("W25N04LV", /* 3.3V */
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x8b, 0x23),
+		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&w25n04lv_ooblayout, w25n02kv_ecc_get_status)),
 	SPINAND_INFO("W25N04KW", /* 1.8V */
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xba, 0x23),
 		     NAND_MEMORG(1, 2048, 128, 64, 4096, 40, 1, 1, 1),
-- 
2.39.3 (Apple Git-146)


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] mtd: spinand: winbond: add support for W25N04LV
@ 2026-08-16  9:31 ` Huasin Liao
  0 siblings, 0 replies; 4+ messages in thread
From: Huasin Liao @ 2026-08-16  9:31 UTC (permalink / raw)
  To: miquel.raynal, vigneshr
  Cc: richard, tudor.ambarus, linux-mtd, linux-kernel, huasin.liao,
	Huasin Liao

Add support for the Winbond W25N04LV. Tested on an Airoha
AN7581-based board with the on-board W25N04LV, verified
erase/read/write.

Link: https://www.winbond.com/hq/product/code-storage-flash-memory/qspinand-flash/?__locale=en&partNo=W25N04LV
Cc: huasin.liao@airoha.com
Signed-off-by: Huasin Liao <huasinliao@gmail.com>
---
 drivers/mtd/nand/spi/winbond.c | 38 ++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 9b78c1e6cbc9..892220a12b22 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -345,6 +345,35 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
 	.free = w25n02kv_ooblayout_free,
 };
 
+static int w25n04lv_ooblayout_ecc(struct mtd_info *mtd, int section,
+				  struct mtd_oob_region *region)
+{
+	if (section > 7)
+		return -ERANGE;
+
+	region->offset = 128 + (16 * section);
+	region->length = 13;
+
+	return 0;
+}
+
+static int w25n04lv_ooblayout_free(struct mtd_info *mtd, int section,
+				   struct mtd_oob_region *region)
+{
+	if (section > 7)
+		return -ERANGE;
+
+	region->offset = (16 * section) + 2;
+	region->length = 14;
+
+	return 0;
+}
+
+static const struct mtd_ooblayout_ops w25n04lv_ooblayout = {
+	.ecc = w25n04lv_ooblayout_ecc,
+	.free = w25n04lv_ooblayout_free,
+};
+
 static int w25n01jw_ooblayout_ecc(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *region)
 {
@@ -759,6 +788,15 @@ static const struct spinand_info winbond_spinand_table[] = {
 					      &update_cache_variants),
 		     0,
 		     SPINAND_ECCINFO(&w25n02kv_ooblayout, w25n02kv_ecc_get_status)),
+	SPINAND_INFO("W25N04LV", /* 3.3V */
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x8b, 0x23),
+		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&w25n04lv_ooblayout, w25n02kv_ecc_get_status)),
 	SPINAND_INFO("W25N04KW", /* 1.8V */
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xba, 0x23),
 		     NAND_MEMORG(1, 2048, 128, 64, 4096, 40, 1, 1, 1),
-- 
2.39.3 (Apple Git-146)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: spinand: winbond: add support for W25N04LV
  2026-08-16  9:31 ` Huasin Liao
@ 2026-08-16 11:19   ` Dominique Martinet
  -1 siblings, 0 replies; 4+ messages in thread
From: Dominique Martinet @ 2026-08-16 11:19 UTC (permalink / raw)
  To: Huasin Liao
  Cc: miquel.raynal, vigneshr, richard, tudor.ambarus, linux-mtd,
	linux-kernel, huasin.liao

Huasin Liao wrote on Sun, Aug 16, 2026 at 05:31:24PM +0800:
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index 9b78c1e6cbc9..892220a12b22 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -345,6 +345,35 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
>  	.free = w25n02kv_ooblayout_free,
>  };
>  
> +static int w25n04lv_ooblayout_ecc(struct mtd_info *mtd, int section,
> +				  struct mtd_oob_region *region)
> +{
> +	if (section > 7)
> +		return -ERANGE;
> +
> +	region->offset = 128 + (16 * section);
> +	region->length = 13;
> +
> +	return 0;
> +}
> +
> +static int w25n04lv_ooblayout_free(struct mtd_info *mtd, int section,
> +				   struct mtd_oob_region *region)
> +{
> +	if (section > 7)
> +		return -ERANGE;
> +
> +	region->offset = (16 * section) + 2;
> +	region->length = 14;
> +
> +	return 0;
> +}
> +
> +static const struct mtd_ooblayout_ops w25n04lv_ooblayout = {
> +	.ecc = w25n04lv_ooblayout_ecc,
> +	.free = w25n04lv_ooblayout_free,

FWIW, these two are the same as what I consolidated in
https://lore.kernel.org/r/20260814-w25n04lw-v3-1-c6a7423ac7d0@atmark-techno.com
using oobsize, so we probably want to reuse that here too

(Should I split the patch?)

-- 
Dominique Martinet | Asmadeus

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: spinand: winbond: add support for W25N04LV
@ 2026-08-16 11:19   ` Dominique Martinet
  0 siblings, 0 replies; 4+ messages in thread
From: Dominique Martinet @ 2026-08-16 11:19 UTC (permalink / raw)
  To: Huasin Liao
  Cc: miquel.raynal, vigneshr, richard, tudor.ambarus, linux-mtd,
	linux-kernel, huasin.liao

Huasin Liao wrote on Sun, Aug 16, 2026 at 05:31:24PM +0800:
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index 9b78c1e6cbc9..892220a12b22 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -345,6 +345,35 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
>  	.free = w25n02kv_ooblayout_free,
>  };
>  
> +static int w25n04lv_ooblayout_ecc(struct mtd_info *mtd, int section,
> +				  struct mtd_oob_region *region)
> +{
> +	if (section > 7)
> +		return -ERANGE;
> +
> +	region->offset = 128 + (16 * section);
> +	region->length = 13;
> +
> +	return 0;
> +}
> +
> +static int w25n04lv_ooblayout_free(struct mtd_info *mtd, int section,
> +				   struct mtd_oob_region *region)
> +{
> +	if (section > 7)
> +		return -ERANGE;
> +
> +	region->offset = (16 * section) + 2;
> +	region->length = 14;
> +
> +	return 0;
> +}
> +
> +static const struct mtd_ooblayout_ops w25n04lv_ooblayout = {
> +	.ecc = w25n04lv_ooblayout_ecc,
> +	.free = w25n04lv_ooblayout_free,

FWIW, these two are the same as what I consolidated in
https://lore.kernel.org/r/20260814-w25n04lw-v3-1-c6a7423ac7d0@atmark-techno.com
using oobsize, so we probably want to reuse that here too

(Should I split the patch?)

-- 
Dominique Martinet | Asmadeus

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-16 11:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16  9:31 [PATCH] mtd: spinand: winbond: add support for W25N04LV Huasin Liao
2026-08-16  9:31 ` Huasin Liao
2026-08-16 11:19 ` Dominique Martinet
2026-08-16 11:19   ` Dominique Martinet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.