amdfwtool: Use command line option use-combo to decide if use combo

The macro PSP_COMBO is removed and instead use the flag use_combo. As
long as this flag is false, the amdfwtool behaves the same way as the
macro does.

Change-Id: Ief0d78ae1e94b8183d6cf3195935ff9774fee426
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55455
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index f09a5a8..3273b72 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -89,7 +89,6 @@
  *
  * TODO: Future work may require fully implementing the PSP_COMBO feature.
  */
-#define PSP_COMBO 0
 
 /*
  * Creates the OSI Fletcher checksum. See 8473-1, Appendix C, section C.3.
@@ -155,6 +154,7 @@
 	printf("--combo-capable                Place PSP directory pointer at Embedded\n");
 	printf("                               Firmware\n");
 	printf("                               offset able to support combo directory\n");
+	printf("--use-combo                    Use the COMBO layout\n");
 	printf("--multilevel                   Generate primary and secondary tables\n");
 	printf("--nvram <FILE>                 Add nvram binary\n");
 	printf("--soft-fuse                    Set soft fuse\n");
@@ -430,7 +430,6 @@
 	return ptr;
 }
 
-#if PSP_COMBO
 static void *new_combo_dir(context *ctx)
 {
 	void *ptr;
@@ -441,7 +440,6 @@
 			+ MAX_COMBO_ENTRIES * sizeof(psp_combo_entry);
 	return ptr;
 }
-#endif
 
 static void fill_dir_header(void *directory, uint32_t count, uint32_t cookie, context *ctx)
 {
@@ -1207,6 +1205,7 @@
 	AMDFW_OPT_COMBO,
 	AMDFW_OPT_RECOVERY_AB,
 	AMDFW_OPT_RECOVERY_AB_SINGLE_COPY,
+	AMDFW_OPT_USE_COMBO,
 	AMDFW_OPT_MULTILEVEL,
 	AMDFW_OPT_NVRAM,
 
@@ -1256,6 +1255,7 @@
 	{"combo-capable",          no_argument, 0, AMDFW_OPT_COMBO },
 	{"recovery-ab",            no_argument, 0, AMDFW_OPT_RECOVERY_AB },
 	{"recovery-ab-single-copy", no_argument, 0, AMDFW_OPT_RECOVERY_AB_SINGLE_COPY },
+	{"use-combo",              no_argument, 0, AMDFW_OPT_USE_COMBO },
 	{"multilevel",             no_argument, 0, AMDFW_OPT_MULTILEVEL },
 	{"nvram",            required_argument, 0, AMDFW_OPT_NVRAM },
 	{"soft-fuse",        required_argument, 0, AMDFW_OPT_FUSE },
@@ -1539,6 +1539,7 @@
 	cb_config.recovery_ab = false;
 	cb_config.need_ish = false;
 	cb_config.recovery_ab_single_copy = false;
+	cb_config.use_combo = false;
 
 	while (1) {
 		int optindex = 0;
@@ -1571,6 +1572,9 @@
 			cb_config.recovery_ab = true;
 			cb_config.recovery_ab_single_copy = true;
 			break;
+		case AMDFW_OPT_USE_COMBO:
+			cb_config.use_combo = true;
+			break;
 		case AMDFW_OPT_MULTILEVEL:
 			cb_config.multi_level = true;
 			break;
@@ -1904,17 +1908,17 @@
 	else
 		amd_romsig->psp_directory = BUFF_TO_RUN(ctx, pspdir);
 
-#if PSP_COMBO
-	psp_combo_directory *combo_dir = new_combo_dir(&ctx);
-	amd_romsig->combo_psp_directory = BUFF_TO_RUN(ctx, combo_dir);
-	/* 0 -Compare PSP ID, 1 -Compare chip family ID */
-	combo_dir->entries[0].id_sel = 0;
-	combo_dir->entries[0].id = get_psp_id(soc_id);
-	combo_dir->entries[0].lvl2_addr = BUFF_TO_RUN(ctx, pspdir);
+	if (cb_config.use_combo) {
+		psp_combo_directory *combo_dir = new_combo_dir(&ctx);
+		amd_romsig->combo_psp_directory = BUFF_TO_RUN(ctx, combo_dir);
+		/* 0 -Compare PSP ID, 1 -Compare chip family ID */
+		combo_dir->entries[0].id_sel = 0;
+		combo_dir->entries[0].id = get_psp_id(soc_id);
+		combo_dir->entries[0].lvl2_addr = BUFF_TO_RUN(ctx, pspdir);
 
-	combo_dir->header.lookup = 1;
-	fill_dir_header(combo_dir, 1, PSP2_COOKIE, &ctx);
-#endif
+		combo_dir->header.lookup = 1;
+		fill_dir_header(combo_dir, 1, PSP2_COOKIE, &ctx);
+	}
 
 	if (have_bios_tables(amd_bios_table)) {
 		bios_directory_table *biosdir = NULL;
diff --git a/util/amdfwtool/amdfwtool.h b/util/amdfwtool/amdfwtool.h
index dbce392..cc0a3b1 100644
--- a/util/amdfwtool/amdfwtool.h
+++ b/util/amdfwtool/amdfwtool.h
@@ -281,6 +281,7 @@
 	bool recovery_ab;
 	bool recovery_ab_single_copy;
 	bool need_ish;
+	bool use_combo;
 } amd_cb_config;
 
 void register_fw_fuse(char *str);