public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] [MTD] CHIPS: 0xFF intolerance for M29W128G
@ 2009-08-26 15:42 massimo cirillo
  2009-08-26 17:55 ` Jamie Lokier
  0 siblings, 1 reply; 4+ messages in thread
From: massimo cirillo @ 2009-08-26 15:42 UTC (permalink / raw)
  To: linux-mtd; +Cc: augulis.darius, RichardRetanubun

From: Massimo Cirillo <maxcir@gmail.com>

The M29W128G Numonyx flash devices are intolerant to any 0xFF command:
in the Cfi_util.c the function cfi_qry_mode_off() (that resets the device
after the autoselect mode) must have a 0xF0 command after the 0xFF command.
Intel-like devices are not influenced by a 0xF0 command.
This fix solves also the cause of the fixup_M29W128G_write_buffer() fix,
that can be commented out now.
The following patch applies to 2.6.30 kernel.

Signed-off-by: Massimo Cirillo <maxcir@gmail.com>
---
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c
b/drivers/mtd/chips/cfi_cmdset_0002.c
old mode 100644
new mode 100755
index 61ea833..5a65e92
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -308,7 +308,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
 	{ CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors, NULL, },
 	{ CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors, NULL, },
 	{ CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors, NULL, },
-	{ CFI_MFR_ST,  0x227E, fixup_M29W128G_write_buffer, NULL, },
+	/*{ CFI_MFR_ST,  0x227E, fixup_M29W128G_write_buffer, NULL, },*/
 #if !FORCE_WORD_WRITE
 	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
 #endif
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
old mode 100644
new mode 100755
index 34d40e2..9c897f9
--- a/drivers/mtd/chips/cfi_util.c
+++ b/drivers/mtd/chips/cfi_util.c
@@ -61,8 +61,8 @@ int __xipram cfi_qry_mode_on(uint32_t base,
 		return 1;
 	/* QRY not found probably we deal with some odd CFI chips */
 	/* Some revisions of some old Intel chips? */
-	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
 	if (cfi_qry_present(map, base, cfi))
 		return 1;
@@ -79,8 +79,11 @@ EXPORT_SYMBOL_GPL(cfi_qry_mode_on);
 void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map,
 			       struct cfi_private *cfi)
 {
-	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+    /* Numonyx M29W128G requires two 0xF0 to exit succesfully from
+    autoselect mode. No consequences on Intel-like devices. */
+	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 }
 EXPORT_SYMBOL_GPL(cfi_qry_mode_off);

--

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

* Re: [PATCH] [MTD] CHIPS: 0xFF intolerance for M29W128G
  2009-08-26 15:42 [PATCH] [MTD] CHIPS: 0xFF intolerance for M29W128G massimo cirillo
@ 2009-08-26 17:55 ` Jamie Lokier
  2009-08-27 15:59   ` massimo cirillo
  0 siblings, 1 reply; 4+ messages in thread
From: Jamie Lokier @ 2009-08-26 17:55 UTC (permalink / raw)
  To: massimo cirillo; +Cc: augulis.darius, linux-mtd, RichardRetanubun

massimo cirillo wrote:
> From: Massimo Cirillo <maxcir@gmail.com>
> 
> The M29W128G Numonyx flash devices are intolerant to any 0xFF command:
> in the Cfi_util.c the function cfi_qry_mode_off() (that resets the device
> after the autoselect mode) must have a 0xF0 command after the 0xFF command.
> Intel-like devices are not influenced by a 0xF0 command.
> This fix solves also the cause of the fixup_M29W128G_write_buffer() fix,
> that can be commented out now.
> The following patch applies to 2.6.30 kernel.

This change was discussed 1 year ago:

   http://lists.infradead.org/pipermail/linux-mtd/2008-August/022497.html

The conclusion was that 0xf0 after 0xff might not be safe for some
chips ("early revisions of L30"), but nobody could confirm which
chips, so Alexey Korolov suggested staying safe and using fixup
functions.

I'm inclined to think a per-manufacturer (ignoring chip-id) reset
function would be better than the attempt to poke several different
commands at a chip all mixed together in a careful order, knowing that
some commands break some chips but later commands fix them again.

-- Jamie

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

* Re: [PATCH] [MTD] CHIPS: 0xFF intolerance for M29W128G
  2009-08-26 17:55 ` Jamie Lokier
@ 2009-08-27 15:59   ` massimo cirillo
  0 siblings, 0 replies; 4+ messages in thread
From: massimo cirillo @ 2009-08-27 15:59 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: augulis.darius, linux-mtd, RichardRetanubun

2009/8/26 Jamie Lokier <jamie@shareable.org>:
> massimo cirillo wrote:
>> From: Massimo Cirillo <maxcir@gmail.com>
>>
>> The M29W128G Numonyx flash devices are intolerant to any 0xFF command:
>> in the Cfi_util.c the function cfi_qry_mode_off() (that resets the device
>> after the autoselect mode) must have a 0xF0 command after the 0xFF command.
>> Intel-like devices are not influenced by a 0xF0 command.
>> This fix solves also the cause of the fixup_M29W128G_write_buffer() fix,
>> that can be commented out now.
>> The following patch applies to 2.6.30 kernel.
>
> This change was discussed 1 year ago:
>
>   http://lists.infradead.org/pipermail/linux-mtd/2008-August/022497.html
>
> The conclusion was that 0xf0 after 0xff might not be safe for some
> chips ("early revisions of L30"), but nobody could confirm which
> chips, so Alexey Korolov suggested staying safe and using fixup
> functions.
>
> I'm inclined to think a per-manufacturer (ignoring chip-id) reset
> function would be better than the attempt to poke several different
> commands at a chip all mixed together in a careful order, knowing that
> some commands break some chips but later commands fix them again.
>
> -- Jamie
>

Jamie,
I've rewritten the patch: now only the function cfi_qry_mode_off()
has been patched, and only if the device is a M29W128G (16bit or 8bit)
a final 0xF0 is given. The fixup_M29W128G_write_buffer() keeps on being
removed, because the buffer write failure derived from the unstable
state due to the missing 0xF0 command.
Please give comments about this new version.

Signed-off-by: Massimo Cirillo <maxcir@gmail.com>
---
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c
b/drivers/mtd/chips/cfi_cmdset_0002.c
old mode 100644
new mode 100755
index 61ea833..86cc313
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -308,7 +308,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
 	{ CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors, NULL, },
 	{ CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors, NULL, },
 	{ CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors, NULL, },
-	{ CFI_MFR_ST,  0x227E, fixup_M29W128G_write_buffer, NULL, },
+	/* { CFI_MFR_ST,  0x227E, fixup_M29W128G_write_buffer, NULL, }, */
 #if !FORCE_WORD_WRITE
 	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
 #endif
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
old mode 100644
new mode 100755
index 34d40e2..43511ab
--- a/drivers/mtd/chips/cfi_util.c
+++ b/drivers/mtd/chips/cfi_util.c
@@ -81,6 +81,9 @@ void __xipram cfi_qry_mode_off(uint32_t base, struct
map_info *map,
 {
 	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+	/* send a 0xF0 if the device is M29W128G */
+	if ((cfi->mfr == CFI_MFR_ST) && (cfi->id == 0x227E || cfi->id == 0x7E))
+		cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 }
 EXPORT_SYMBOL_GPL(cfi_qry_mode_off);

--
Best Regards,
Massimo Cirillo <maxcir@gmail.com>

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

* Re: [PATCH] [MTD] CHIPS: 0xFF intolerance for M29W128G
  2009-08-31  6:47 Alexey Korolev
@ 2009-09-03 14:34 ` massimo cirillo
  0 siblings, 0 replies; 4+ messages in thread
From: massimo cirillo @ 2009-09-03 14:34 UTC (permalink / raw)
  To: linux-mtd; +Cc: jamie, akorolev

From: Massimo Cirillo <maxcir@gmail.com>

The M29W128G Numonyx flash devices are intolerant to any 0xFF command:
in the Cfi_util.c the function cfi_qry_mode_off() (that resets the device
after the autoselect mode) must have a 0xF0 command after the 0xFF command.
This fix solves also the cause of the fixup_M29W128G_write_buffer() fix,
that can be removed now.
The following patch applies to 2.6.30 kernel.

Signed-off-by: Massimo Cirillo <maxcir@gmail.com>
Acked-by: alexey Korolev <akorolev@infradead.org>
---
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c
b/drivers/mtd/chips/cfi_cmdset_0002.c
old mode 100644
new mode 100755
index 61ea833..94bb61e
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -282,16 +282,6 @@ static void fixup_s29gl032n_sectors(struct mtd_info *mtd,
 	}
 }

-static void fixup_M29W128G_write_buffer(struct mtd_info *mtd, void *param)
-{
-	struct map_info *map = mtd->priv;
-	struct cfi_private *cfi = map->fldrv_priv;
-	if (cfi->cfiq->BufWriteTimeoutTyp) {
-		pr_warning("Don't use write buffer on ST flash M29W128G\n");
-		cfi->cfiq->BufWriteTimeoutTyp = 0;
-	}
-}
-
 static struct cfi_fixup cfi_fixup_table[] = {
 	{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
 #ifdef AMD_BOOTLOC_BUG
@@ -308,7 +298,6 @@ static struct cfi_fixup cfi_fixup_table[] = {
 	{ CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors, NULL, },
 	{ CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors, NULL, },
 	{ CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors, NULL, },
-	{ CFI_MFR_ST,  0x227E, fixup_M29W128G_write_buffer, NULL, },
 #if !FORCE_WORD_WRITE
 	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
 #endif
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
old mode 100644
new mode 100755
index 34d40e2..8b87652
--- a/drivers/mtd/chips/cfi_util.c
+++ b/drivers/mtd/chips/cfi_util.c
@@ -81,6 +81,10 @@ void __xipram cfi_qry_mode_off(uint32_t base,
 {
 	cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+	/* M29W128G flashes require an additional reset command
+	   when exit qry mode */
+	if ((cfi->mfr == CFI_MFR_ST) && (cfi->id == 0x227E || cfi->id == 0x7E))
+		cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
 }
 EXPORT_SYMBOL_GPL(cfi_qry_mode_off);

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

end of thread, other threads:[~2009-09-03 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 15:42 [PATCH] [MTD] CHIPS: 0xFF intolerance for M29W128G massimo cirillo
2009-08-26 17:55 ` Jamie Lokier
2009-08-27 15:59   ` massimo cirillo
  -- strict thread matches above, loose matches on Subject: below --
2009-08-31  6:47 Alexey Korolev
2009-09-03 14:34 ` [PATCH] " massimo cirillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox