Improve DIMM detection for AMCC Yucca 440SPe board

Improved the memory DIMM detection for the Yucca 440SPe board for
the case where a memory DIMM is falsely detected as present.

This issue is seen on some AMCC Yucca 440SPe validation boards if
only one 512MB memory DIMM is installed, i.e. DIMM slot 0 is
populated and DIMM slot 1 is empty.  In this case, U-Boot does
not correctly detect that there is only one DIMM memory module
installed and will falsely detect two DIMM memory modules are
present and therefore U-Boot will not calculate the correct amount
of total memory and u-boot will not booting up.

Patch by Adam Graham, 24 Aug 2006
diff --git a/board/amcc/yucca/yucca.c b/board/amcc/yucca/yucca.c
index af12839..65f7575 100644
--- a/board/amcc/yucca/yucca.c
+++ b/board/amcc/yucca/yucca.c
@@ -562,10 +562,11 @@
 
 static long int yucca_probe_for_dimms(void)
 {
-	long int 	dimm_installed[MAXDIMMS];
-	long int	dimm_num, probe_result;
-	long int	dimms_found = 0;
-	uchar		dimm_addr = IIC0_DIMM0_ADDR;
+	int 	dimm_installed[MAXDIMMS];
+	int	dimm_num, result;
+	int	dimms_found = 0;
+	uchar	dimm_addr = IIC0_DIMM0_ADDR;
+	uchar   dimm_spd_data[MAX_SPD_BYTES];
 
 	for (dimm_num = 0; dimm_num < MAXDIMMS; dimm_num++) {
 		/* check if there is a chip at the dimm address	*/
@@ -577,12 +578,28 @@
 				dimm_addr = IIC0_DIMM1_ADDR;
 				break;
 		}
-		probe_result = i2c_probe(dimm_addr);
 
-		if (probe_result == 0) {
+		result = i2c_probe(dimm_addr);
+
+		memset(dimm_spd_data, 0, MAX_SPD_BYTES * sizeof(char));
+		if (result == 0) {
+			/* read first byte of SPD data, if there is any data */ 
+			result = i2c_read(dimm_addr, 0, 1, dimm_spd_data, 1);
+
+			if (result == 0) {
+				result = dimm_spd_data[0];
+				result = result > MAX_SPD_BYTES ? 
+						MAX_SPD_BYTES : result;
+				result = i2c_read(dimm_addr, 0, 1,
+							dimm_spd_data, result);
+			}
+		}
+
+		if ((result == 0) &&
+		    (dimm_spd_data[64] == MICRON_SPD_JEDEC_ID)) {	
 			dimm_installed[dimm_num] = TRUE;
 			dimms_found++;
-			debug("DIMM slot %d: DDR2 SDRAM detected\n",dimm_num);
+			debug("DIMM slot %d: DDR2 SDRAM detected\n", dimm_num);
 		} else {
 			dimm_installed[dimm_num] = FALSE;
 			debug("DIMM slot %d: Not populated or cannot sucessfully probe the DIMM\n", dimm_num);
diff --git a/board/amcc/yucca/yucca.h b/board/amcc/yucca/yucca.h
index 66f7584..4d13021 100644
--- a/board/amcc/yucca/yucca.h
+++ b/board/amcc/yucca/yucca.h
@@ -60,6 +60,9 @@
 
 #define NUM_TLB_ENTRIES          64
 
+/* MICRON SPD JEDEC ID Code (first byte) - SPD data byte [64] */
+#define MICRON_SPD_JEDEC_ID 0x2c
+
 /*----------------------------------------------------------------------------+
 | TLB specific defines.
 +----------------------------------------------------------------------------*/