Skip to contentSkip to conversation

mtd: use the full-id as the keyword

PATCH Superseded Huang Shijie 4 participants 21 messages Jan 28, 2013 – Aug 8, 2013

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover mtd: use the full-id as the keyword

From: Huang Shijie <[email protected]>

I ever submitted a patch to use the full-id as the keyword for some unparsable nand chips. This is the second tries.

As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example.
I have 4 Toshiba's nand chips in my hand:

	TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2

When we read these chips' datasheets, we will get the geometry of these chips:

	TC58NVG2S0F : 4096 + 224
	TC58NVG3S0F : 4096 + 232
	TC58NVG5D2  : 8192 + 640
	TC58NVG6D2  : 8192 + 640

But we can not parse out the correct oob size for these chips from the id data. So it is time to add some new fields to the nand_flash_dev{},
and update the detection mechanisms.

v2 --> v3:
[1] remove the duplicated header.
[2] remove the field "ecc_len" in nand_flash_dev{}.
[3] fix some coding style warnings.
[4] add more comments

Huang Shijie (3):
mtd: add new fields to nand_flash_dev{}
mtd: add a new table for the unparsable nand chips
mtd: add the new detection method for the unparsable nand chips

 drivers/mtd/devices/doc2000.c     |    2 +-
 drivers/mtd/devices/doc2001.c     |    2 +-
 drivers/mtd/devices/doc2001plus.c |    2 +-
 drivers/mtd/nand/nand_base.c      |   35 ++++++-
 drivers/mtd/nand/nand_ids.c       |  217 +++++++++++++++++++++----------------
 drivers/mtd/nand/nandsim.c        |    2 +-
 drivers/mtd/nand/pxa3xx_nand.c    |    2 +-
 drivers/mtd/nand/sm_common.c      |   61 +++++------
 include/linux/mtd/nand.h          |    9 ++-
 9 files changed, 201 insertions(+), 131 deletions(-)
#1 lore raw

PATCH v3 1/3 mtd: add new fields to nand_flash_dev{}

As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example. I have 4 Toshiba's nand chips in my hand:

	TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2

When we read these chips' datasheets, we will get the geometry of these chips:

	TC58NVG2S0F : 4096 + 224
	TC58NVG3S0F : 4096 + 232
	TC58NVG5D2  : 8192 + 640
	TC58NVG6D2  : 8192 + 640

But we can not parse out the correct oob size for these chips from the id data. So it is time to add some new fields to the nand_flash_dev{}, and update the detection mechanisms.

This patch just adds some new fields to the nand_flash_dev{}:
@id[8] : the 8 bytes id data.
@id_len: the valid length of the id data. @oobsize: the oob size.

---
 drivers/mtd/devices/doc2000.c     |    2 +-
 drivers/mtd/devices/doc2001.c     |    2 +-
 drivers/mtd/devices/doc2001plus.c |    2 +-
 drivers/mtd/nand/nand_base.c      |    2 +-
 drivers/mtd/nand/nand_ids.c       |  196 ++++++++++++++++++++-----------------
 drivers/mtd/nand/nandsim.c        |    2 +-
 drivers/mtd/nand/pxa3xx_nand.c    |    2 +-
 drivers/mtd/nand/sm_common.c      |   61 ++++++------
 include/linux/mtd/nand.h          |    8 +-
 9 files changed, 147 insertions(+), 130 deletions(-)
drivers/mtd/devices/doc2000.c +1 -1
index a4eb8b5..93f037f 100644
@@ -379,7 +379,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
 
 	/* Print and store the manufacturer and ID codes. */
 	for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-		if (id == nand_flash_ids[i].id) {
+		if (id == nand_flash_ids[i].id[1]) {
 			/* Try to identify manufacturer */
 			for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
 				if (nand_manuf_ids[j].id == mfr)
drivers/mtd/devices/doc2001.c +1 -1
index f692795..15dd177 100644
@@ -206,7 +206,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
 
 	/* FIXME: to deal with multi-flash on multi-Millennium case more carefully */
 	for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-		if ( id == nand_flash_ids[i].id) {
+		if (id == nand_flash_ids[i].id[1]) {
 			/* Try to identify manufacturer */
 			for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
 				if (nand_manuf_ids[j].id == mfr)
drivers/mtd/devices/doc2001plus.c +1 -1
index 4f2220a..80aef1b 100644
@@ -314,7 +314,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
 		return 0;
 
 	for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-		if (id == nand_flash_ids[i].id) {
+		if (id == nand_flash_ids[i].id[1]) {
 			/* Try to identify manufacturer */
 			for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
 				if (nand_manuf_ids[j].id == mfr)
drivers/mtd/nand/nand_base.c +1 -1
index a8c1fb4..0e80ec4 100644
@@ -3204,7 +3204,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 		type = nand_flash_ids;
 
 	for (; type->name != NULL; type++)
-		if (*dev_id == type->id)
+		if (*dev_id == type->id[1])
 			break;
 
 	chip->onfi_version = 0;
drivers/mtd/nand/nand_ids.c +105 -91

242 lines not on this page · raw message

drivers/mtd/nand/nandsim.c +1 -1
index 4c31798..8742dc1 100644
@@ -770,7 +770,7 @@ static int init_nandsim(struct mtd_info *mtd)
 
 	/* Detect how many ID bytes the NAND chip outputs */
         for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-                if (second_id_byte != nand_flash_ids[i].id)
+		if (second_id_byte != nand_flash_ids[i].id[1])
                         continue;
 	}
 
drivers/mtd/nand/pxa3xx_nand.c +1 -1
index 37ee75c..78a8fd1 100644
@@ -989,7 +989,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
 	}
 
 	pxa3xx_flash_ids[0].name = f->name;
-	pxa3xx_flash_ids[0].id = (f->chip_id >> 8) & 0xffff;
+	pxa3xx_flash_ids[0].id[1] = (f->chip_id >> 8) & 0xffff;
 	pxa3xx_flash_ids[0].pagesize = f->page_size;
 	chipsize = (uint64_t)f->num_blocks * f->page_per_block * f->page_size;
 	pxa3xx_flash_ids[0].chipsize = chipsize >> 20;
drivers/mtd/nand/sm_common.c +30 -31

71 lines not on this page · raw message

include/linux/mtd/nand.h +6 -2
index 7ccb3c5..d8fd638 100644
@@ -585,7 +585,7 @@ struct nand_chip {
 /**
  * struct nand_flash_dev - NAND Flash Device ID Structure
  * @name:	Identify the device type
- * @id:		device ID code
+ * @id:		ID data
  * @pagesize:	Pagesize in bytes. Either 256 or 512 or 0
  *		If the pagesize is 0, then the real pagesize
  *		and the eraseize are determined from the
@@ -593,14 +593,18 @@ struct nand_chip {
  * @erasesize:	Size of an erase block in the flash device.
  * @chipsize:	Total chipsize in Mega Bytes
  * @options:	Bitfield to store chip relevant options
+ * @id_len:	The valid length of the id data.
+ * @oobsize:	OOB size
  */
 struct nand_flash_dev {
 	char *name;
-	int id;
+	u8 id[8];
 	unsigned long pagesize;
 	unsigned long chipsize;
 	unsigned long erasesize;
 	unsigned long options;
+	unsigned int id_len;
+	unsigned long oobsize;
 };
 
 /**
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 3 lines · Huang Shijie
(quoted diff) +2 -0
+       {"SmartMedia 256MiB 3,3V",      {0, 0x71}, 512, 256, 0x4000 },
+       {"SmartMedia 256MiB 3,3V ROM",  {0, 0x5b}, 512, 256, 0x4000,

NAND_ROM},

Sorry for a possibly stupid question, but what does it buy you adding another "0" to all the entries? I see you add another table, which you look up if the "traditional" table does not work. Why you need to add these zeroes?

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#3 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · Huang Shijie
(quoted diff) +2 -0
+       {"SmartMedia 256MiB 3,3V",      {0, 0x71}, 512, 256, 0x4000 },
+       {"SmartMedia 256MiB 3,3V ROM",  {0, 0x5b}, 512, 256, 0x4000,

NAND_ROM},

Sorry for a possibly stupid question, but what does it buy you adding another "0" to all the entries? I see you add another table, which you look up if the "traditional" table does not work. Why you need to add these zeroes?

The zeros are for the maf_id.

The dev_id is the second byte of the 8-byte id data.

thanks
Huang Shijie

Quoted 10 lines

--
Best Regards,
Artem Bityutskiy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 6 lines · Huang Shijie
Quoted 5 lines · Artem Bityutskiy
Quoted 3 lines · Huang Shijie
(quoted diff) +2 -0
+       {"SmartMedia 256MiB 3,3V",      {0, 0x71}, 512, 256, 0x4000 },
+       {"SmartMedia 256MiB 3,3V ROM",  {0, 0x5b}, 512, 256, 0x4000,

NAND_ROM},

Quoted 8 lines
Quoted 4 lines

Sorry for a possibly stupid question, but what does it buy you adding another "0" to all the entries? I see you add another table, which you look up if the "traditional" table does not work. Why you need to add these zeroes?

The zeros are for the maf_id.

The dev_id is the second byte of the 8-byte id data.

It does not really make me understand why we add these zeroes, they still look useless to me... Would you please be a little more verbose about your solution?

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#5 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 10 lines · Artem Bityutskiy
Quoted 9 lines · Huang Shijie
Quoted 8 lines · Artem Bityutskiy
Quoted 3 lines · Huang Shijie
(quoted diff) +2 -0
+       {"SmartMedia 256MiB 3,3V",      {0, 0x71}, 512, 256, 0x4000 },
+       {"SmartMedia 256MiB 3,3V ROM",  {0, 0x5b}, 512, 256, 0x4000,

NAND_ROM},

Sorry for a possibly stupid question, but what does it buy you adding another "0" to all the entries? I see you add another table, which you look up if the "traditional" table does not work. Why you need to add these zeroes?

Quoted 7 lines
Quoted 3 lines

The zeros are for the maf_id.

The dev_id is the second byte of the 8-byte id data.

It does not really make me understand why we add these zeroes, they still look useless to me... Would you please be a little more verbose about your solution?

the 8bytes id data read out by the READ ID command is in the following order:
byte 0(Maker id): such as 0x98 stands for Toshiba, 0xec stands for
Samsung.
byte 1(device id):
byte 2(used to store the chip number,cell type information):
byte 3(used to store the page size, block size information) byte 4(used to store the Plane information).
........................

The current code uses the @id to store the device id(byte 1).
But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array, the device id is the second byte now. All the added zeros are for the Maker id. For example,

    {"SmartMedia 256MiB 3,3V",      {0, 0x71}, 512, 256, 0x4000 },

We really do not use the zeros. All the zeros are added for avoiding the misunderstanding. If we do not add the zero, it will looks like:

     {"SmartMedia 256MiB 3,3V",      {0x71}, 512, 256, 0x4000 },

The device id (0x71) becomes the first byte of 8byte id array, people will treat the 0x71 as the Maker code.

thanks
Huang Shijie

#6 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#7 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 5 lines · Artem Bityutskiy
Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

Quoted 7 lines

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

If i only add the oob size field. There will be two items with the same Device ID in nand_flash_ids table, one has oob_size, one does not have. such as:

{"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS},
{"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640}, //OOB
size is 640.

How can i distinguish them? In which case, i choose the item with the oob_size, and in which case, i choose the item without the oobsize?

thanks
Huang Shijie

#8 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 10 lines · Huang Shijie
Quoted 9 lines · Artem Bityutskiy
Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

Quoted 8 lines
Quoted 3 lines

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

If i only add the oob size field. There will be two items with the same Device ID in nand_flash_ids table,
one has oob_size, one does not have. such as:

    {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS},

Do you know what is this chip?

Quoted 2 lines
    {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640},   //OOB 

size is 640

So there are really 2 different chips with the same device id and different OOB size? If you had 2 datasheets for me demonstrating this, I'd be grateful.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#9 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 14 lines · Artem Bityutskiy
Quoted 13 lines · Huang Shijie
Quoted 12 lines · Artem Bityutskiy
Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

Quoted 6 lines
Quoted 5 lines

If i only add the oob size field. There will be two items with the same Device ID in nand_flash_ids table,
one has oob_size, one does not have. such as:

     {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS},

Do you know what is this chip?

this maybe not just a nand chip, it may stands for a class of nand chips. Toshiba may uses this device id, Micron may also uses it.

In other word, this item may stands for many nand chips.

Quoted 5 lines
Quoted 2 lines
     {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640},   //OOB

size is 640

So there are really 2 different chips with the same device id and different OOB size? If you had 2 datasheets for me demonstrating this, I'd be grateful.

Please see the http://www.linux-mtd.infradead.org/nand-data/nanddata.html
The ST's NAND08GW3B2C and Numonyx's NAND08GW3F2B share the same device id but with the different oob size.

thanks
Huang Shijie

#10 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 24 lines · Huang Shijie
Quoted 14 lines · Artem Bityutskiy
Quoted 13 lines · Huang Shijie
Quoted 12 lines · Artem Bityutskiy
Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

Quoted 6 lines
Quoted 5 lines

If i only add the oob size field. There will be two items with the same Device ID in nand_flash_ids table,
one has oob_size, one does not have. such as:

     {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS},

Do you know what is this chip?

this maybe not just a nand chip, it may stands for a class of nand chips. Toshiba may uses this device id, Micron may also uses it.

Quoted 8 lines

In other word, this item may stands for many nand chips.

Quoted 5 lines
Quoted 2 lines
     {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640},   //OOB

size is 640

So there are really 2 different chips with the same device id and different OOB size? If you had 2 datasheets for me demonstrating this, I'd be grateful.

Please see the http://www.linux-mtd.infradead.org/nand-data/nanddata.html
The ST's NAND08GW3B2C and Numonyx's NAND08GW3F2B share the same device

Thanks, I forgot we have this great table. BTW, please, do not forget to update it with information about these 4 chip you are adding, irrespective of the solution we end up with.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#11 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 3 lines · Artem Bityutskiy

Thanks, I forgot we have this great table. BTW, please, do not forget to update it with information about these 4 chip you are adding, irrespective of the solution we end up with.

I also want to update the table, but i do not know how to do it.

thanks
Huang Shijie

#12 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 7 lines · Huang Shijie
Quoted 3 lines · Artem Bityutskiy

Thanks, I forgot we have this great table. BTW, please, do not forget to update it with information about these 4 chip you are adding, irrespective of the solution we end up with.

I also want to update the table, but i do not know how to do it.

You can send patches against the mtd-www.git repo. It's just a CSV text-file, so you'd add a few rows. I'll try to review / ack any patches.

Brian

#13 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

In reply to Huang Shijie

Hi Huang,

For some reason, I just noticed your question here. But I think it's important to answer.

Quoted 5 lines · Huang Shijie
Quoted 3 lines · Artem Bityutskiy

Thanks, I forgot we have this great table. BTW, please, do not forget to update it with information about these 4 chip you are adding, irrespective of the solution we end up with.

I also want to update the table, but i do not know how to do it.

You can submit a patch against mtd-www.git. See:

http://www.linux-mtd.infradead.org/faq/general.html#L_mtdwww

You just need to edit the CSV table under nand-data/nanddata.csv.

Brian

#14 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

In reply to Huang Shijie
Quoted 10 lines · Huang Shijie
Quoted 9 lines · Artem Bityutskiy
Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

Quoted 8 lines
Quoted 3 lines

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

If i only add the oob size field. There will be two items with the same Device ID in nand_flash_ids table,
one has oob_size, one does not have. such as:

    {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS},

OK, I guess for this one:

{"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 0},

nand_decode_ext_id() will calculate the OOB size.

Quoted 2 lines
    {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640},   //OOB 

size is 640.

And for this one 'nand_decode_ext_id()' will calculate it too, but _afterwards_ we change OOB size to 640.

Does this sound sane?

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#15 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 23 lines · Artem Bityutskiy
Quoted 10 lines · Huang Shijie
Quoted 9 lines · Artem Bityutskiy
Quoted 4 lines · Huang Shijie

The current code uses the @id to store the device id(byte 1). But if we use the 8 bytes id data as the keyword, and expand the @id field to 8byte array,
the device id is the second byte now. All the added zeros are for the

I do not think you need to store the full array of ID's. Device ID's for all the 4 of above chips are different, which is enough to distinguish between them.

Quoted 8 lines
Quoted 3 lines

The only thing you need to add is the OOB size field to 'struct nand_flash_dev'.

If i only add the oob size field. There will be two items with the same Device ID in nand_flash_ids table,
one has oob_size, one does not have. such as:

     {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS},

OK, I guess for this one:

{"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 0},

Quoted 9 lines

nand_decode_ext_id() will calculate the OOB size.

Quoted 2 lines
     {"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640},   //OOB

size is 640.

And for this one 'nand_decode_ext_id()' will calculate it too, but _afterwards_ we change OOB size to 640.

Does this sound sane?

I think not.

The problem is : we can not know which nand_flash_dev item we should use when the same Device ID occurs. When we meet a nand whose Device ID is 0xDE, the current code will select the first one:
{"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 0}

Could you tell me how can we choose the seconde one? The second same device-id item is
{"NAND 8GIB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS, 640}

thanks
Huang Shijie

#16 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

In reply to Artem Bityutskiy
Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · Huang Shijie
(quoted diff) +2 -0
+       {"SmartMedia 256MiB 3,3V",      {0, 0x71}, 512, 256, 0x4000 },
+       {"SmartMedia 256MiB 3,3V ROM",  {0, 0x5b}, 512, 256, 0x4000,

NAND_ROM},

Sorry for a possibly stupid question, but what does it buy you adding another "0" to all the entries? I see you add another table, which you look up if the "traditional" table does not work. Why you need to add these zeroes?

just a ping.

are we missing the merge window again?

thanks
Huang Shijie

#17 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

In reply to Huang Shijie
Quoted 5 lines · Huang Shijie

As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example. I have 4 Toshiba's nand chips in my hand:

	TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2
Quoted 7 lines

When we read these chips' datasheets, we will get the geometry of these chips:

	TC58NVG2S0F : 4096 + 224
	TC58NVG3S0F : 4096 + 232
	TC58NVG5D2  : 8192 + 640
	TC58NVG6D2  : 8192 + 640

But we can not parse out the correct oob size for these chips from the id data.

Very good start of the commit message - you clearly defined the problem.

Quoted 2 lines

So it is time to add some new fields to the nand_flash_dev{}, and update the detection mechanisms.

But continued with very poor description of how you address the problem. Please, provide a better description.

Quoted 2 lines

This patch just adds some new fields to the nand_flash_dev{}:
@id[8] : the 8 bytes id data.

id[8] = 8 bytes id data, just like password[5] = 5 bytes of password data. Please, provide a better commentary.

Quoted 1 line

@id_len: the valid length of the id data.

What does "valid" mean? Are "invalid" parts?

Quoted 1 line

@oobsize: the oob size.

Try to invent a better comment.

Huang, it is not that I am trying to be difficult, but I truly do not understand how you are solving the issue.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#18 lore raw

Re: [PATCH V3 1/3] mtd: add new fields to nand_flash_dev{}

Quoted 12 lines · Artem Bityutskiy
Quoted 11 lines · Huang Shijie

As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example. I have 4 Toshiba's nand chips in my hand:

	TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2

When we read these chips' datasheets, we will get the geometry of these chips:

	TC58NVG2S0F : 4096 + 224
	TC58NVG3S0F : 4096 + 232
	TC58NVG5D2  : 8192 + 640
	TC58NVG6D2  : 8192 + 640
Quoted 7 lines
Quoted 1 line

But we can not parse out the correct oob size for these chips from the id data.

Very good start of the commit message - you clearly defined the problem.

Quoted 2 lines

So it is time to add some new fields to the nand_flash_dev{}, and update the detection mechanisms.

But continued with very poor description of how you address the problem. Please, provide a better description.

sorry. It's my fault.

I will add more description in the next version.

Quoted 5 lines
Quoted 2 lines

This patch just adds some new fields to the nand_flash_dev{}:
@id[8] : the 8 bytes id data.

id[8] = 8 bytes id data, just like password[5] = 5 bytes of password data. Please, provide a better commentary.

okay.

Quoted 2 lines
Quoted 1 line

@id_len: the valid length of the id data.

What does "valid" mean? Are "invalid" parts?

yes.

some nand chips may only have 5 valid bytes in the 8 bytes id data
which is read
out by the READ ID(0x90) command. for example, the 8 bytes id data may
like this:

    A1, A2, A3, A4, A5, A1, A2, A3

The last three bytes are just the repeat of the first three bytes.

Of course, we can remove this field, in other word, treat the last three bytes as the valid bytes too.

Quoted 4 lines
Quoted 1 line

@oobsize: the oob size.

Try to invent a better comment.

Huang, it is not that I am trying to be difficult, but I truly do not

not at all, it's my fault.

Quoted 2 lines

understand how you are solving the issue.

My method is:
Use the 8 bytes id data (which is read out by READ ID command) as the
keyword.
The 8bytes id data is unique for each nand chip. Do we meet two different nand chips have the same 8 bytes id data? I afraid not.

Since we can not parse out the oob size for these Toshiba nand chips,
we can add a
new field oob_size to store the right oob size for the nand chips. that's why i add the @oobsize field.

Are you clear now?

thanks
Huang Shijie

#19 lore raw

PATCH v3 2/3 mtd: add a new table for the unparsable nand chips

In reply to Huang Shijie

We have 4 Toshiba nand chips which can not be parsed out by the id data. Add a new table for the unparsable nand chips.

It makes mess if we add these entries to the nand_flash_ids table. The entries in the nand_flash_ids stands for a class of nand chips. But the unparsable nand chips are just some singular chips.

---
 drivers/mtd/nand/nand_ids.c |   21 +++++++++++++++++++++
 include/linux/mtd/nand.h    |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)
drivers/mtd/nand/nand_ids.c +21 -0
index 99949f6..4147c78 100644
@@ -12,6 +12,27 @@
 #include <linux/mtd/nand.h>
 #include <linux/sizes.h>
 
+/* This table uses the full ID data as the keyword. */
+struct nand_flash_dev nand_flash_full_ids[] = {
+	/* TOSHIBA */
+	{"TC58NVG2S0F 4G 3.3V 8-bit ",
+		{0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08},
+			SZ_4K, SZ_512, SZ_256K, 0, 8, 224},
+	{"TC58NVG3S0F 8G 3.3V 8-bit ",
+		{0x98, 0xd3, 0x90, 0x26, 0x76, 0x15, 0x02, 0x08},
+			SZ_4K, SZ_1K, SZ_256K, 0, 8, 232},
+	{"TC58NVG5D2 32G 3.3V 8-bit ",
+		{0x98, 0xd7, 0x94, 0x32, 0x76, 0x56, 0x09, 0x00},
+			SZ_8K, SZ_4K, SZ_1M, 0, 8, 640},
+	{"TC58NVG6D2 64G 3.3V 8-bit ",
+		{0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20},
+			SZ_8K, SZ_8K, SZ_2M, 0, 8, 640},
+
+	/* end here */
+	{NULL,}
+};
+
+
 /*
 *	Chip ID list
 *
include/linux/mtd/nand.h +1 -0
index d8fd638..119c8e0 100644
@@ -618,6 +618,7 @@ struct nand_manufacturers {
 };
 
 extern struct nand_flash_dev nand_flash_ids[];
+extern struct nand_flash_dev nand_flash_full_ids[];
 extern struct nand_manufacturers nand_manuf_ids[];
 
 extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
Signature · 1 line
1.7.0.4
#20 lore raw

PATCH v3 3/3 mtd: add the new detection method for the unparsable nand chips

In reply to Huang Shijie

Add the new detection method find_nand_type_by_fullid() for the unparsable nand chips. The new detection method is called firstly before all the other detection methods.

---
 drivers/mtd/nand/nand_base.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
drivers/mtd/nand/nand_base.c +32 -1
index 0e80ec4..7f0431d 100644
@@ -3152,6 +3152,29 @@ static void nand_decode_bbm_options(struct mtd_info *mtd,
 		chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
 }
 
+static struct nand_flash_dev *find_nand_type_by_fullid(struct mtd_info *mtd,
+				struct nand_chip *chip, u8 *id_data, int *busw)
+{
+	struct nand_flash_dev *type = nand_flash_full_ids;
+
+	for (; type->name != NULL; type++) {
+		if (!strncmp(type->id, id_data, type->id_len)) {
+			mtd->writesize = type->pagesize;
+			mtd->erasesize = type->erasesize;
+			mtd->oobsize = type->oobsize;
+
+			chip->cellinfo = id_data[2];
+			chip->chipsize = (uint64_t)type->chipsize << 20;
+			chip->options |= type->options;
+
+			*busw = type->options & NAND_BUSWIDTH_16;
+
+			break;
+		}
+	}
+	return type;
+}
+
 /*
  * Get the flash and manufacturer id and lookup if the type is supported.
  */
@@ -3200,8 +3223,16 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 		return ERR_PTR(-ENODEV);
 	}
 
-	if (!type)
+	if (!type) {
+		/*
+		 * Some nand chips's information can not be paresed out
+		 * from the id data. So, try your luck in the full-id table.
+		 */
+		type = find_nand_type_by_fullid(mtd, chip, id_data, &busw);
+		if (type->name != NULL)
+			goto ident_done;
 		type = nand_flash_ids;
+	}
 
 	for (; type->name != NULL; type++)
 		if (*dev_id == type->id[1])
Signature · 1 line
1.7.0.4