[flashrom] [commit] r717 - trunk

svn at flashrom.org svn at flashrom.org
Sat Sep 5 03:16:30 CEST 2009


Author: hailfinger
Date: 2009-09-05 03:16:30 +0200 (Sat, 05 Sep 2009)
New Revision: 717

Modified:
   trunk/82802ab.c
   trunk/stm50flw0x0x.c
   trunk/w39v040c.c
   trunk/w39v080fa.c
Log:
Quite a few probe functions in flashrom are copies of probe_jedec with
additional lock bit printing or other glue. Make them call probe_jedec
instead.

Use the correct reset sequence for 82802AB. Detailed explanation:
The reset sequence before ID reading was correct, so ID always
worked. But the reset sequence after ID reading was a copy-paste
leftover from probe_jedec and didn't have any effect. I dug up
flash_and_burn from the freebios-v1 tree and found out that 82802ab.c
was indeed a copy of jedec.c with lots of experimental unannotated #if 0
and #if 1.
About the wait_82802ab change:
Before the patch, wait_82802ab entered read status mode, switched to ID
mode, then tried an incorrect and unsupported JEDEC command to exit ID
mode. Nobody ever saw that this failed because all subsequent function
calls had the correct reset sequence at the beginning.
With the patch, wait_82802ab enters read status mode, then switches back
to read mode with the official reset command.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: Stefan Reinauer <stepan at coresystems.de>


Modified: trunk/82802ab.c
===================================================================
--- trunk/82802ab.c	2009-09-05 01:12:07 UTC (rev 716)
+++ trunk/82802ab.c	2009-09-05 01:16:30 UTC (rev 717)
@@ -47,14 +47,11 @@
 	chipaddr bios = flash->virtual_memory;
 	uint8_t id1, id2;
 
-#if 0
-	chip_writeb(0xAA, bios + 0x5555);
-	chip_writeb(0x55, bios + 0x2AAA);
-	chip_writeb(0x90, bios + 0x5555);
-#endif
-
-	chip_writeb(0xff, bios);
+	/* Reset to get a clean state */
+	chip_writeb(0xFF, bios);
 	programmer_delay(10);
+
+	/* Enter ID mode */
 	chip_writeb(0x90, bios);
 	programmer_delay(10);
 
@@ -62,9 +59,7 @@
 	id2 = chip_readb(bios + 0x01);
 
 	/* Leave ID mode */
-	chip_writeb(0xAA, bios + 0x5555);
-	chip_writeb(0x55, bios + 0x2AAA);
-	chip_writeb(0xF0, bios + 0x5555);
+	chip_writeb(0xFF, bios);
 
 	programmer_delay(10);
 
@@ -81,7 +76,6 @@
 uint8_t wait_82802ab(chipaddr bios)
 {
 	uint8_t status;
-	uint8_t id1, id2;
 
 	chip_writeb(0x70, bios);
 	if ((chip_readb(bios) & 0x80) == 0) {	// it's busy
@@ -90,19 +84,9 @@
 
 	status = chip_readb(bios);
 
-	// put another command to get out of status register mode
+	/* Reset to get a clean state */
+	chip_writeb(0xFF, bios);
 
-	chip_writeb(0x90, bios);
-	programmer_delay(10);
-
-	id1 = chip_readb(bios);
-	id2 = chip_readb(bios + 0x01);
-
-	// this is needed to jam it out of "read id" mode
-	chip_writeb(0xAA, bios + 0x5555);
-	chip_writeb(0x55, bios + 0x2AAA);
-	chip_writeb(0xF0, bios + 0x5555);
-
 	return status;
 }
 

Modified: trunk/stm50flw0x0x.c
===================================================================
--- trunk/stm50flw0x0x.c	2009-09-05 01:12:07 UTC (rev 716)
+++ trunk/stm50flw0x0x.c	2009-09-05 01:16:30 UTC (rev 717)
@@ -42,50 +42,11 @@
 
 int probe_stm50flw0x0x(struct flashchip *flash)
 {
-	chipaddr bios = flash->virtual_memory;
-	uint8_t id1, id2;
-	uint32_t largeid1, largeid2;
+	int result = probe_jedec(flash);
 
-	/* Issue JEDEC Product ID Entry command */
-	chip_writeb(0xAA, bios + 0x5555);
-	programmer_delay(10);
-	chip_writeb(0x55, bios + 0x2AAA);
-	programmer_delay(10);
-	chip_writeb(0x90, bios + 0x5555);
-	programmer_delay(40);
+	if (!result)
+		return result;
 
-	/* Read product ID */
-	id1 = chip_readb(bios);
-	id2 = chip_readb(bios + 0x01);
-	largeid1 = id1;
-	largeid2 = id2;
-
-	/* Check if it is a continuation ID, this should be a while loop. */
-	if (id1 == 0x7F) {
-		largeid1 <<= 8;
-		id1 = chip_readb(bios + 0x100);
-		largeid1 |= id1;
-	}
-	if (id2 == 0x7F) {
-		largeid2 <<= 8;
-		id2 = chip_readb(bios + 0x101);
-		largeid2 |= id2;
-	}
-
-	/* Issue JEDEC Product ID Exit command */
-	chip_writeb(0xAA, bios + 0x5555);
-	programmer_delay(10);
-	chip_writeb(0x55, bios + 0x2AAA);
-	programmer_delay(10);
-	chip_writeb(0xF0, bios + 0x5555);
-	programmer_delay(40);
-
-	printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __func__, largeid1,
-		     largeid2);
-
-	if (largeid1 != flash->manufacture_id || largeid2 != flash->model_id)
-		return 0;
-
 	map_flash_registers(flash);
 
 	return 1;

Modified: trunk/w39v040c.c
===================================================================
--- trunk/w39v040c.c	2009-09-05 01:12:07 UTC (rev 716)
+++ trunk/w39v040c.c	2009-09-05 01:16:30 UTC (rev 717)
@@ -23,8 +23,12 @@
 int probe_w39v040c(struct flashchip *flash)
 {
 	chipaddr bios = flash->virtual_memory;
-	uint8_t id1, id2, lock;
+	int result = probe_jedec(flash);
+	uint8_t lock;
 
+	if (!result)
+		return result;
+
 	chip_writeb(0xAA, bios + 0x5555);
 	programmer_delay(10);
 	chip_writeb(0x55, bios + 0x2AAA);
@@ -32,8 +36,6 @@
 	chip_writeb(0x90, bios + 0x5555);
 	programmer_delay(10);
 
-	id1 = chip_readb(bios);
-	id2 = chip_readb(bios + 1);
 	lock = chip_readb(bios + 0xfff2);
 
 	chip_writeb(0xAA, bios + 0x5555);
@@ -43,17 +45,9 @@
 	chip_writeb(0xF0, bios + 0x5555);
 	programmer_delay(40);
 
-	printf_debug("%s: id1 0x%02x, id2 0x%02x", __func__, id1, id2);
-	if (!oddparity(id1))
-		printf_debug(", id1 parity violation");
-	printf_debug("\n");
-	if (flash->manufacture_id == id1 && flash->model_id == id2) {
-		printf("%s: Boot block #TBL is %slocked, rest of chip #WP is %slocked.\n",
-			__func__, lock & 0x4 ? "" : "un", lock & 0x8 ? "" : "un");
-		return 1;
-	}
-
-	return 0;
+	printf("%s: Boot block #TBL is %slocked, rest of chip #WP is %slocked.\n",
+		__func__, lock & 0x4 ? "" : "un", lock & 0x8 ? "" : "un");
+	return 1;
 }
 
 int erase_w39v040c(struct flashchip *flash)

Modified: trunk/w39v080fa.c
===================================================================
--- trunk/w39v080fa.c	2009-09-05 01:12:07 UTC (rev 716)
+++ trunk/w39v080fa.c	2009-09-05 01:16:30 UTC (rev 717)
@@ -22,30 +22,11 @@
 
 int probe_winbond_fwhub(struct flashchip *flash)
 {
-	chipaddr bios = flash->virtual_memory;
-	uint8_t id1, id2;
+	int result = probe_jedec(flash);
 
-	/* Product Identification Entry */
-	chip_writeb(0xAA, bios + 0x5555);
-	chip_writeb(0x55, bios + 0x2AAA);
-	chip_writeb(0x90, bios + 0x5555);
-	programmer_delay(10);
+	if (!result)
+		return result;
 
-	/* Read product ID */
-	id1 = chip_readb(bios);
-	id2 = chip_readb(bios + 0x01);
-
-	/* Product Identifixation Exit */
-	chip_writeb(0xAA, bios + 0x5555);
-	chip_writeb(0x55, bios + 0x2AAA);
-	chip_writeb(0xF0, bios + 0x5555);
-	programmer_delay(10);
-
-	printf_debug("%s: id1 0x%x, id2 0x%x\n", __func__, id1, id2);
-
-	if (id1 != flash->manufacture_id || id2 != flash->model_id)
-		return 0;
-
 	map_flash_registers(flash);
 
 	return 1;





More information about the flashrom mailing list