Patchwork [3/6] mtd: cfi_probe: enable Auto Select Mode for SST39VF160x/39VF320x chips

login
register
mail settings
Submitter Guillaume LECERF
Date Feb. 20, 2010, 12:57 p.m.
Message ID <20100220125759.14843.46780.stgit@shiryu.yomgui.biz>
Download mbox | patch
Permalink /patch/45916/
State New
Headers show

Comments

Guillaume LECERF - Feb. 20, 2010, 12:57 p.m.
SST 39VF160x/39VF320x chips differ from the CFI specifications, they need
the 0xAA / 0x55 / 0x90 sequence to be sent to 0x5555 / 0x2AAA / 0x5555 to
enter Auto Select Mode.
Trying this sequence and testing for (cfi->mfr != CFI_MFR_SST) then fallback
to the standard sequence seems to work and to add no regressions.

Signed-off-by: Guillaume Lecerf <glecerf@gmail.com>
---
 drivers/mtd/chips/cfi_probe.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

Patch

diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index e63e674..05207f7 100644
--- a/drivers/mtd/chips/cfi_probe.c
+++ b/drivers/mtd/chips/cfi_probe.c
@@ -189,12 +189,31 @@  static int __xipram cfi_chip_setup(struct map_info *map,
 	 * back into Read Mode, which is a nop in this case).
 	 */
 	cfi_send_gen_cmd(0xf0,     0, base, map, cfi, cfi->device_type, NULL);
-	cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL);
-	cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL);
-	cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL);
+
+	/* SST 39VF160x/39VF320x chips differ from the CFI specifications, they need
+	 * the 0xAA / 0x55 / 0x90 sequence to be sent to 0x5555 / 0x2AAA / 0x5555 to
+	 * enter Auto Select Mode.
+	 * Trying this sequence and testing for (cfi->mfr != CFI_MFR_SST) then fallback
+	 * to the standard sequence seems to work and to add no regressions.
+	 */
+	cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x90, 0x5555, base, map, cfi, cfi->device_type, NULL);
+
 	cfi->mfr = cfi_read_query16(map, base);
 	cfi->id = cfi_read_query16(map, base + ofs_factor);
 
+	if(cfi->mfr != CFI_MFR_SST) {
+		cfi_send_gen_cmd(0xF0,     0, base, map, cfi, cfi->device_type, NULL);
+
+		cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL);
+		cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL);
+		cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL);
+
+		cfi->mfr = cfi_read_query16(map, base);
+		cfi->id = cfi_read_query16(map, base + ofs_factor);
+	}
+
 	/* Get AMD/Spansion extended JEDEC ID */
 	if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e)
 		cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 |