baytrail: handle MRC being an ELF file

Provide the option to embed MRC as an ELF file and not just
binary blob. This allows for MRC to be relocated.

BUG=chrome-os-partner:27654
BRANCH=rambi
TEST=Built and booted rambi.

Change-Id: I2e177c155a3074e4e1d450b1a73b7299aebd5286
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/192893
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
(cherry picked from commit 89c97d5e2023b8c5cc780e1b1d532d0a586512f9)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Reviewed-on: http://review.coreboot.org/7214
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Tested-by: build bot (Jenkins)
diff --git a/src/soc/intel/baytrail/romstage/raminit.c b/src/soc/intel/baytrail/romstage/raminit.c
index d5ee031..72d8e51 100644
--- a/src/soc/intel/baytrail/romstage/raminit.c
+++ b/src/soc/intel/baytrail/romstage/raminit.c
@@ -146,13 +146,20 @@
 #endif
 	}
 
-	mrc_entry = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, "mrc.bin", 0xab,
-					  NULL);
-
-	if (mrc_entry == NULL) {
+	/* Determine if mrc.bin is in the cbfs. */
+	if (cbfs_get_file_content(CBFS_DEFAULT_MEDIA, "mrc.bin", 0xab, NULL) ==
+	    NULL) {
 		printk(BIOS_DEBUG, "Couldn't find mrc.bin\n");
 		return;
 	}
+
+	/*
+	 * The entry point is currently the first instruction. Handle the
+	 * case of an ELF file being put in the cbfs by setting the entry
+	 * to the CONFIG_MRC_BIN_ADDRESS.
+	 */
+	mrc_entry = (void *)(uintptr_t)CONFIG_MRC_BIN_ADDRESS;
+
 	if (mp->mainboard.dram_info_location == DRAM_INFO_SPD_SMBUS)
 		enable_smbus();