[coreboot] r3308 - trunk/util/flashrom

svn at coreboot.org svn at coreboot.org
Wed May 14 14:03:07 CEST 2008


Author: hailfinger
Date: 2008-05-14 14:03:06 +0200 (Wed, 14 May 2008)
New Revision: 3308

Modified:
   trunk/util/flashrom/flash.h
   trunk/util/flashrom/jedec.c
   trunk/util/flashrom/spi.c
Log:
Check the JEDEC vendor ID for correct parity. Flash chips which can be
detected by JEDEC probe routines all have vendor IDs with correct
parity. Use a parity check as additional hint whether a vendor ID makes
sense.
Note: Device IDs have no parity requirements whatsoever.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: Peter Stuge <peter at stuge.se>


Modified: trunk/util/flashrom/flash.h
===================================================================
--- trunk/util/flashrom/flash.h	2008-05-14 11:38:22 UTC (rev 3307)
+++ trunk/util/flashrom/flash.h	2008-05-14 12:03:06 UTC (rev 3308)
@@ -396,6 +396,7 @@
 void it8716f_spi_page_program(int block, uint8_t *buf, uint8_t *bios);
 
 /* jedec.c */
+uint8_t oddparity(uint8_t val);
 void toggle_ready_jedec(volatile uint8_t *dst);
 void data_polling_jedec(volatile uint8_t *dst, uint8_t data);
 void unprotect_jedec(volatile uint8_t *bios);

Modified: trunk/util/flashrom/jedec.c
===================================================================
--- trunk/util/flashrom/jedec.c	2008-05-14 11:38:22 UTC (rev 3307)
+++ trunk/util/flashrom/jedec.c	2008-05-14 12:03:06 UTC (rev 3308)
@@ -27,6 +27,14 @@
 
 #define MAX_REFLASH_TRIES 0x10
 
+/* Check one byte for odd parity */
+uint8_t oddparity(uint8_t val)
+{
+	val = (val ^ (val >> 4)) & 0xf;
+	val = (val ^ (val >> 2)) & 0x3;
+	return (val ^ (val >> 1)) & 0x1;
+}
+
 void toggle_ready_jedec(volatile uint8_t *dst)
 {
 	unsigned int i = 0;
@@ -123,7 +131,10 @@
 	*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
 	myusec_delay(40);
 
-	printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, largeid1, largeid2);
+	printf_debug("%s: id1 0x%x, id2 0x%x", __FUNCTION__, largeid1, largeid2);
+	if (!oddparity(id1))
+		printf_debug(", id1 parity violation");
+	printf_debug("\n");
 	if (largeid1 == flash->manufacture_id && largeid2 == flash->model_id)
 		return 1;
 

Modified: trunk/util/flashrom/spi.c
===================================================================
--- trunk/util/flashrom/spi.c	2008-05-14 11:38:22 UTC (rev 3307)
+++ trunk/util/flashrom/spi.c	2008-05-14 12:03:06 UTC (rev 3308)
@@ -71,8 +71,12 @@
 	uint32_t manuf_id;
 	uint32_t model_id;
 	if (!spi_rdid(readarr)) {
+		if (!oddparity(readarr[0]))
+			printf_debug("RDID byte 0 parity violation.\n");
 		/* Check if this is a continuation vendor ID */
 		if (readarr[0] == 0x7f) {
+			if (!oddparity(readarr[1]))
+				printf_debug("RDID byte 1 parity violation.\n");
 			manuf_id = (readarr[0] << 8) | readarr[1];
 			model_id = readarr[2];
 		} else {





More information about the coreboot mailing list