fit: Add overlay support

This patch adds support to boot FIT image configurations consisting of
a base device tree and one or more overlays. Since extracting the right
compatible string from overlay FDTs is problematic, we'll only support
this for FIT images that have the compatible string pulled out into the
config node.

This patch was adapted from depthcharge's http://crosreview.com/1555293

Change-Id: I0943f9a1869c9e416887c7ff16e33f7d91b74989
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/32873
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index b049188..8e75915 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -206,6 +206,15 @@
 		return;
 	}
 
+	struct fit_overlay_chain *chain;
+	list_for_each(chain, config->overlays, list_node) {
+		struct device_tree *overlay = unpack_fdt(chain->overlay);
+		if (!overlay || dt_apply_overlay(dt, overlay)) {
+			printk(BIOS_ERR, "ERROR: Failed to apply overlay %s!\n",
+			       chain->overlay->name);
+		}
+	}
+
 	dt_apply_fixups(dt);
 
 	/* Insert coreboot specific information */