2022-04-16 01:40:19

by Chuanhong Guo

[permalink] [raw]
Subject: [PATCH 0/2] mtd: spinand: add support for detection with param page

This patchset adds support for spi-nand detection using parameter page.
This helps dealing with future JEDEC ID conflicts introduced by crazy
vendors. Also, the added ability to auto-detect chip capacity can help
reducing number of entries in our spi-nand id table.

Chuanhong Guo (2):
mtd: spinand: add support for detection with param page
mtd: spinand: probe Winbond W25N01GV/W using param page

drivers/mtd/nand/spi/Makefile | 2 +-
drivers/mtd/nand/spi/core.c | 23 +--
drivers/mtd/nand/spi/onfi.c | 298 +++++++++++++++++++++++++++++++++
drivers/mtd/nand/spi/winbond.c | 25 ++-
include/linux/mtd/spinand.h | 53 ++++++
5 files changed, 380 insertions(+), 21 deletions(-)
create mode 100644 drivers/mtd/nand/spi/onfi.c

--
2.35.1


2022-04-16 02:38:00

by Chuanhong Guo

[permalink] [raw]
Subject: [PATCH 2/2] mtd: spinand: probe Winbond W25N01GV/W using param page

The JEDEC ID of EFAA21 is assigned to both W25N01G and W25N01K.
Probing the chip with JEDEC ID isn't reliable anymore. Use parameter
page instead.

Signed-off-by: Chuanhong Guo <[email protected]>
---
drivers/mtd/nand/spi/onfi.c | 4 +++-
drivers/mtd/nand/spi/winbond.c | 25 ++++++++++++++++---------
include/linux/mtd/spinand.h | 3 +++
3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/spi/onfi.c b/drivers/mtd/nand/spi/onfi.c
index 5cc888e3d038..27484e0cd22d 100644
--- a/drivers/mtd/nand/spi/onfi.c
+++ b/drivers/mtd/nand/spi/onfi.c
@@ -141,7 +141,9 @@ static void nand_bit_wise_majority(const void **srcbufs, unsigned int nsrcbufs,
}
}

-static const struct spinand_manufacturer *spinand_onfi_manufacturers[] = {};
+static const struct spinand_manufacturer *spinand_onfi_manufacturers[] = {
+ &winbond_onfi_spinand_manufacturer,
+};

static const struct spinand_onfi_info *
spinand_onfi_chip_match(struct nand_onfi_params *p,
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 76684428354e..601316c80b3e 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -85,15 +85,15 @@ static const struct spinand_info winbond_spinand_table[] = {
0,
SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL),
SPINAND_SELECT_TARGET(w25m02gv_select_target)),
- SPINAND_INFO("W25N01GV",
- SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa),
- NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
- NAND_ECCREQ(1, 512),
- SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
- &write_cache_variants,
- &update_cache_variants),
- 0,
- SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)),
+};
+
+static const struct spinand_onfi_info winbond_spinand_onfi_table[] = {
+ SPINAND_ONFI_INFO(SPINAND_ONFI_MODELS("W25N01GV", "W25N01GW"),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ 0,
+ SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)),
};

static int winbond_spinand_init(struct spinand_device *spinand)
@@ -125,3 +125,10 @@ const struct spinand_manufacturer winbond_spinand_manufacturer = {
.nchips = ARRAY_SIZE(winbond_spinand_table),
.ops = &winbond_spinand_manuf_ops,
};
+
+const struct spinand_manufacturer winbond_onfi_spinand_manufacturer = {
+ .name = "Winbond",
+ .onfi_chips = winbond_spinand_onfi_table,
+ .nchips = ARRAY_SIZE(winbond_spinand_onfi_table),
+ .ops = &winbond_spinand_manuf_ops,
+};
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index dc218082d773..610320b03773 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -268,6 +268,9 @@ extern const struct spinand_manufacturer paragon_spinand_manufacturer;
extern const struct spinand_manufacturer toshiba_spinand_manufacturer;
extern const struct spinand_manufacturer winbond_spinand_manufacturer;

+/* SPI NAND manufacturers with ONFI parameter page support */
+extern const struct spinand_manufacturer winbond_onfi_spinand_manufacturer;
+
/**
* struct spinand_op_variants - SPI NAND operation variants
* @ops: the list of variants for a given operation
--
2.35.1