-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

Mine AMIC flash chip needs 4 bytes RDID. Following patch adds support for that.

Signed-off-by: Rudolf Marek <[EMAIL PROTECTED]>

Thanks,
Rudolf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIaUZb3J9wPJqZRNURAl74AKCIbhYCudIyKL/hJ3aHYEzb1O3O0ACgrEg7
Wr8KvR7+GfSGb3l875Ibk3I=
=9ePr
-----END PGP SIGNATURE-----
Index: coreboot-v2/util/flashrom/flash.h
===================================================================
--- coreboot-v2.orig/util/flashrom/flash.h	2008-06-30 22:32:32.360039004 +0200
+++ coreboot-v2/util/flashrom/flash.h	2008-06-30 22:32:51.904041816 +0200
@@ -403,6 +403,7 @@
 
 /* spi.c */
 int probe_spi_rdid(struct flashchip *flash);
+int probe_spi_rdid4(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);
 void spi_write_enable();
Index: coreboot-v2/util/flashrom/spi.c
===================================================================
--- coreboot-v2.orig/util/flashrom/spi.c	2008-06-30 22:32:36.207042421 +0200
+++ coreboot-v2/util/flashrom/spi.c	2008-06-30 22:34:29.207039069 +0200
@@ -44,11 +44,11 @@
 	return 1;
 }
 
-static int spi_rdid(unsigned char *readarr)
+static int spi_rdid(unsigned char *readarr, int bytes)
 {
 	const unsigned char cmd[JEDEC_RDID_OUTSIZE] = {JEDEC_RDID};
 
-	if (spi_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, cmd, readarr))
+	if (spi_command(JEDEC_RDID_OUTSIZE, bytes, cmd, readarr))
 		return 1;
 	printf_debug("RDID returned %02x %02x %02x.\n", readarr[0], readarr[1], readarr[2]);
 	return 0;
@@ -80,13 +80,13 @@
 	spi_command(JEDEC_WRDI_OUTSIZE, JEDEC_WRDI_INSIZE, cmd, NULL);
 }
 
-int probe_spi_rdid(struct flashchip *flash)
+static int probe_spi_rdid_generic(struct flashchip *flash, int bytes)
 {
-	unsigned char readarr[3];
+	unsigned char readarr[4];
 	uint32_t manuf_id;
 	uint32_t model_id;
 
-	if (spi_rdid(readarr))
+	if (spi_rdid(readarr, bytes))
 		return 0;
 
 	if (!oddparity(readarr[0]))
@@ -97,7 +97,8 @@
 		if (!oddparity(readarr[1]))
 			printf_debug("RDID byte 1 parity violation.\n");
 		manuf_id = (readarr[0] << 8) | readarr[1];
-		model_id = readarr[2];
+		model_id = (bytes == 3) ? readarr[2] :
+						((readarr[2] << 8) | readarr[3]);
 	} else {
 		manuf_id = readarr[0];
 		model_id = (readarr[1] << 8) | readarr[2];
@@ -123,12 +124,25 @@
 	return 0;
 }
 
+int probe_spi_rdid(struct flashchip *flash) {
+	return probe_spi_rdid_generic(flash, 3);
+}
+
+/* support 4 bytes flash ID */
+int probe_spi_rdid4(struct flashchip *flash) {
+
+	/* only some SPI chipsets support 4 bytes commands */
+	if (!((ich7_detected) || (ich9_detected) || (viaspi_detected)))
+		return 0;
+	return probe_spi_rdid_generic(flash, 4);
+}
+
 int probe_spi_res(struct flashchip *flash)
 {
 	unsigned char readarr[3];
 	uint32_t model_id;
 
-	if (spi_rdid(readarr))
+	if (spi_rdid(readarr, 3))
 		/* We couldn't issue RDID, it's pointless to try RES. */
 		return 0;
 

Attachment: spi_4_rdid.patch.sig
Description: Binary data

-- 
coreboot mailing list
[email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to