Skip to contentSkip to conversation

mtd: nand: add manafacturer specific handling

RFC PATCH In review Boris BREZILLON 2 participants 4 messages Feb 24, 2014 – May 2, 2016

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

cover mtd: nand: add manafacturer specific handling

Hello,

This is a proposal to add support for manufacturer specific handling of NAND chips.

Currently the only ones allowed to modify how NAND chips are accessed are NAND controllers (by modifying the nand_chip callbacks) and NAND core code (by setting default callbacks when these are not specified by the NAND controller).

This series adds support for manufacturer/vendor specific handling, which is particularly useful for read retry implementation that are (at least for the moment) manufacturer specific.

I know there was a debate on how we should support all these READ RETRY implementations (see http://permalink.gmane.org/gmane.linux.drivers.mtd/50603),
so please tell if I'm wrong.

Best Regards,

Boris

Boris BREZILLON (2):
mtd: nand: add manufacturer specific init infrastructure
mtd: nand: add hynix specific initializer

 drivers/mtd/nand/Makefile     |    2 +-
 drivers/mtd/nand/nand_base.c  |    7 ++
 drivers/mtd/nand/nand_hynix.c |  151 +++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/nand_ids.c   |    3 +-
 include/linux/mtd/nand.h      |    6 ++
 5 files changed, 167 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/nand/nand_hynix.c
Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH 1/2 mtd: nand: add manufacturer specific init infrastructure

Add new fields in nand_manufacturers and nand_chip struct to provide manufacturer specific handling like read retries.

---
 drivers/mtd/nand/nand_base.c |    7 +++++++
 include/linux/mtd/nand.h     |    4 ++++
 2 files changed, 11 insertions(+)
drivers/mtd/nand/nand_base.c +7 -0
index 9715a7b..8b16479 100644
@@ -3610,6 +3610,13 @@ ident_done:
 	if (mtd->writesize > 512 && chip->cmdfunc == nand_command)
 		chip->cmdfunc = nand_command_lp;
 
+	if (nand_manuf_ids[maf_idx].init) {
+		int err;
+		err = nand_manuf_ids[maf_idx].init(mtd, id_data);
+		if (err)
+			return ERR_PTR(err);
+	}
+
 	pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
 		*maf_id, *dev_id);
 	pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,
include/linux/mtd/nand.h +4 -0
index 32f8612..6189312 100644
@@ -575,6 +575,9 @@ struct nand_chip {
 	int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
 			int feature_addr, uint8_t *subfeature_para);
 	int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode);
+	void (*manuf_cleanup)(struct mtd_info *mtd);
+
+	void *manuf_priv;
 
 	int chip_delay;
 	unsigned int options;
@@ -720,6 +723,7 @@ struct nand_flash_dev {
 struct nand_manufacturers {
 	int id;
 	char *name;
+	int (*init)(struct mtd_info *mtd, const uint8_t *id);
 };
 
 extern struct nand_flash_dev nand_flash_ids[];
Signature · 1 line
1.7.9.5
#2 lore raw

RFC PATCH 2/2 mtd: nand: add hynix specific initializer

In reply to Boris BREZILLON

Add an hynix initializer to manage read retries on h27uxgt8t2a chips.

---
 drivers/mtd/nand/Makefile     |    2 +-
 drivers/mtd/nand/nand_hynix.c |  151 +++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/nand_ids.c   |    3 +-
 include/linux/mtd/nand.h      |    2 +
 4 files changed, 156 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/nand/nand_hynix.c
drivers/mtd/nand/Makefile +1 -1
index 542b568..c970ce7 100644
@@ -5,7 +5,7 @@
 obj-$(CONFIG_MTD_NAND)			+= nand.o
 obj-$(CONFIG_MTD_NAND_ECC)		+= nand_ecc.o
 obj-$(CONFIG_MTD_NAND_BCH)		+= nand_bch.o
-obj-$(CONFIG_MTD_NAND_IDS)		+= nand_ids.o
+obj-$(CONFIG_MTD_NAND_IDS)		+= nand_ids.o nand_hynix.o
 obj-$(CONFIG_MTD_SM_COMMON) 		+= sm_common.o
 
 obj-$(CONFIG_MTD_NAND_CAFE)		+= cafe_nand.o
drivers/mtd/nand/nand_hynix.c new file +151 -0

151 lines not on this page · raw message

drivers/mtd/nand/nand_ids.c +2 -1
index daa2faa..8d373af 100644
@@ -156,6 +156,7 @@ struct nand_flash_dev nand_flash_ids[] = {
 	{NULL}
 };
 
+
 /* Manufacturer IDs */
 struct nand_manufacturers nand_manuf_ids[] = {
 	{NAND_MFR_TOSHIBA, "Toshiba"},
@@ -164,7 +165,7 @@ struct nand_manufacturers nand_manuf_ids[] = {
 	{NAND_MFR_NATIONAL, "National"},
 	{NAND_MFR_RENESAS, "Renesas"},
 	{NAND_MFR_STMICRO, "ST Micro"},
-	{NAND_MFR_HYNIX, "Hynix"},
+	{NAND_MFR_HYNIX, "Hynix", hynix_nand_init},
 	{NAND_MFR_MICRON, "Micron"},
 	{NAND_MFR_AMD, "AMD/Spansion"},
 	{NAND_MFR_MACRONIX, "Macronix"},
include/linux/mtd/nand.h +2 -0
index 6189312..389b3c5 100644
@@ -729,6 +729,8 @@ struct nand_manufacturers {
 extern struct nand_flash_dev nand_flash_ids[];
 extern struct nand_manufacturers nand_manuf_ids[];
 
+int hynix_nand_init(struct mtd_info *mtd, const uint8_t *id);
+
 extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
 extern int nand_default_bbt(struct mtd_info *mtd);
 extern int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs);
Signature · 1 line
1.7.9.5
#3 lore raw
In reply to Boris BREZILLON
Quoted 10 lines · Boris BREZILLON

Hello,

This is a proposal to add support for manufacturer specific handling of NAND chips.

Currently the only ones allowed to modify how NAND chips are accessed are NAND controllers (by modifying the nand_chip callbacks) and NAND core code (by setting default callbacks when these are not specified by the NAND controller).

Quoted 7 lines

This series adds support for manufacturer/vendor specific handling, which is particularly useful for read retry implementation that are (at least for the moment) manufacturer specific.

I know there was a debate on how we should support all these READ RETRY implementations (see http://permalink.gmane.org/gmane.linux.drivers.mtd/50603),
so please tell if I'm wrong.

Just realized that this got no feedback at all.
Brian?

Signature · 2 lines
Thanks,
//richard