drivers/intel/fsp2_0: add option to compress FSP-S in cbfs

Allow the ability for chipset or mainboard to choose to
compress FSP-S in cbfs using LZMA or LZ4 routines. To accomplish
this fsp_load_component() is added as an assist for performing
the necessary logic and allow the caller to provide the destination
selection. Since the main cbfs decompression paths are utilized add
the appropriate checks for including compression algorithms under
the FSP-S compression options.

On picasso FSP-S (debug builds) the following savings were measured:

no-compression:
	fsps.bin	327680	none
FSP_COMPRESS_FSP_S_LZ4:
	fsps.bin	98339	LZ4 (327680 decompressed)	-70%
FSP_COMPRESS_FSP_S_LZMA:
	fsps.bin	71275 	LZMA (327680 decompressed)	-78%

BUG=b:155322763,b:150746858,b:152909132

Change-Id: I8aa5d8c1cbaf4d08f38a918a9031a2570bc5247e
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41449
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index e05ea80..ec5156c 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -91,8 +91,19 @@
 	return ret;
 }
 
+static inline bool fsps_env(void)
+{
+	/* FSP-S is assumed to be loaded in ramstage. */
+	if (ENV_RAMSTAGE)
+		return true;
+	return false;
+}
+
 static inline bool cbfs_lz4_enabled(void)
 {
+	if (fsps_env() && CONFIG(FSP_COMPRESS_FSP_S_LZ4))
+		return true;
+
 	if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && !CONFIG(COMPRESS_PRERAM_STAGES))
 		return false;
 
@@ -101,6 +112,8 @@
 
 static inline bool cbfs_lzma_enabled(void)
 {
+	if (fsps_env() && CONFIG(FSP_COMPRESS_FSP_S_LZMA))
+		return true;
 	/* We assume here romstage and postcar are never compressed. */
 	if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE)
 		return false;