[coreboot] [PATCH] flashrom: Introduce SPI REMS probing function

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Fri Nov 28 00:07:29 CET 2008


Flashrom already has the following probe functions:
- probe_spi_rdid with opcode 0x9f, usually 3 bytes ID
- probe_spi_res with opcode 0xab, usually 1 byte ID
We are missing the following probe function:
- probe_spi_rems with opcode 0x90, usually 2 bytes ID

RDID provides best specifity (manufacturer, device class and device) and
RES is supported by quite a few old chips. However, RES only returns one
byte and there are multiple flash chips with different sizes on the
market and all of them have the same RES ID.
REMS is from the same age as RES, but it provides a manufacturer and a
device ID. It is therefore on par with the probing for parallel flash
chips and specific enough.

The order in which chips should be detected is as follows:
1. RDID
2. REMS
3. RES

I have a few chip definitions in the queue where REMS is required.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: flashrom-spi_rems/flash.h
===================================================================
--- flashrom-spi_rems/flash.h	(Revision 3774)
+++ flashrom-spi_rems/flash.h	(Arbeitskopie)
@@ -449,6 +449,7 @@
 /* spi.c */
 int probe_spi_rdid(struct flashchip *flash);
 int probe_spi_rdid4(struct flashchip *flash);
+int probe_spi_rems(struct flashchip *flash);
 int probe_spi_res(struct flashchip *flash);
 int spi_command(unsigned int writecnt, unsigned int readcnt,
 		const unsigned char *writearr, unsigned char *readarr);
Index: flashrom-spi_rems/spi.c
===================================================================
--- flashrom-spi_rems/spi.c	(Revision 3774)
+++ flashrom-spi_rems/spi.c	(Arbeitskopie)
@@ -61,6 +61,16 @@
 	return 0;
 }
 
+static int spi_rems(unsigned char *readarr)
+{
+	const unsigned char cmd[JEDEC_REMS_OUTSIZE] = { JEDEC_REMS, 0, 0, 0 };
+
+	if (spi_command(sizeof(cmd), JEDEC_REMS_INSIZE, cmd, readarr))
+		return 1;
+	printf_debug("REMS returned %02x %02x.\n", readarr[0], readarr[1]);
+	return 0;
+}
+
 static int spi_res(unsigned char *readarr)
 {
 	const unsigned char cmd[JEDEC_RES_OUTSIZE] = { JEDEC_RES, 0, 0, 0 };
@@ -155,6 +165,37 @@
 	return 0;
 }
 
+int probe_spi_rems(struct flashchip *flash)
+{
+	unsigned char readarr[JEDEC_REMS_INSIZE];
+	uint32_t manuf_id, model_id;
+
+	if (spi_rems(readarr))
+		return 0;
+
+	manuf_id = readarr[0];
+	model_id = readarr[1];
+
+	printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id,
+		     model_id);
+
+	if (manuf_id == flash->manufacture_id && model_id == flash->model_id) {
+		/* Print the status register to tell the
+		 * user about possible write protection.
+		 */
+		spi_prettyprint_status_register(flash);
+
+		return 1;
+	}
+
+	/* Test if this is a pure vendor match. */
+	if (manuf_id == flash->manufacture_id &&
+	    GENERIC_DEVICE_ID == flash->model_id)
+		return 1;
+
+	return 0;
+}
+
 int probe_spi_res(struct flashchip *flash)
 {
 	unsigned char readarr[3];
Index: flashrom-spi_rems/spi.h
===================================================================
--- flashrom-spi_rems/spi.h	(Revision 3774)
+++ flashrom-spi_rems/spi.h	(Arbeitskopie)
@@ -29,6 +29,11 @@
 #define JEDEC_RDID_OUTSIZE	0x01
 #define JEDEC_RDID_INSIZE	0x03
 
+/* Read Electronic Manufacturer Signature */
+#define JEDEC_REMS		0x90
+#define JEDEC_REMS_OUTSIZE	0x04
+#define JEDEC_REMS_INSIZE	0x02
+
 /* Read Electronic Signature */
 #define JEDEC_RES		0xab
 #define JEDEC_RES_OUTSIZE	0x04


-- 
http://www.hailfinger.org/





More information about the coreboot mailing list