amdfwtool: Take a config file instead of command line parameters

To verify the consistency, see if timeless builds with and without
this patch result in identical coreboot.rom files.

BUG=b:154032833
TEST=Build & boot on mandolin

Change-Id: Icae73d0730106aab687486e555ba947796e5e757
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/42859
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Vyssotski <nikolai.vyssotski@amd.corp-partner.google.com>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
diff --git a/src/soc/amd/picasso/Kconfig b/src/soc/amd/picasso/Kconfig
index 6a5b932..7e03a41 100644
--- a/src/soc/amd/picasso/Kconfig
+++ b/src/soc/amd/picasso/Kconfig
@@ -446,9 +446,9 @@
 comment "AMD Firmware Directory Table set to location for 16MB ROM"
 	depends on AMD_FWM_POSITION_INDEX = 5
 
-config AMD_PUBKEY_FILE
+config AMDFW_CONFIG_FILE
 	string
-	default "3rdparty/amd_blobs/picasso/PSP/AmdPubKeyRV.bin"
+	default "src/soc/amd/picasso/fw.cfg"
 
 config USE_PSPSECUREOS
 	bool
@@ -487,16 +487,6 @@
 	depends on HAVE_PSP_WHITELIST_FILE
 	default "3rdparty/amd_blobs/picasso/PSP/wtl-rvn.sbin"
 
-config PSP_BOOTLOADER_FILE
-	string "Specify the PSP Bootloader file path"
-	default "3rdparty/amd_blobs/picasso/PSP/PspBootLoader_WL_RV.sbin" if HAVE_PSP_WHITELIST_FILE
-	default "3rdparty/amd_blobs/picasso/PSP/PspBootLoader_prod_RV.sbin"
-	help
-	  Supply the name of the PSP bootloader file.
-
-	  Note that this option may conflict with the whitelist file if a
-	  different PSP bootloader binary is specified.
-
 config PSP_SHAREDMEM_SIZE
 	hex "Maximum size of shared memory area"
 	default 0x3000 if VBOOT
diff --git a/src/soc/amd/picasso/Makefile.inc b/src/soc/amd/picasso/Makefile.inc
index 514b313..7ec695a 100644
--- a/src/soc/amd/picasso/Makefile.inc
+++ b/src/soc/amd/picasso/Makefile.inc
@@ -125,77 +125,35 @@
 # Design Guide for AMD Family 17h Processors" (PID #55758, NDA only).
 #
 
-# type = 0x0
-FIRMWARE_LOCATE=$(realpath $(dir $(call strip_quotes, $(CONFIG_AMD_PUBKEY_FILE))))
-
-# type = 0x1
-ifeq ($(CONFIG_PSP_BOOTLOADER_FILE),)
-$(error CONFIG_PSP_BOOTLOADER_FILE was not defined)
-endif
-PSPBTLDR_FILE=$(realpath $(call strip_quotes, $(CONFIG_PSP_BOOTLOADER_FILE)))
-$(info Adding PSP $(shell dd if=$(PSPBTLDR_FILE) | md5sum))
-
-# types = 0x8 and 0x12
-PSP_SMUFW1_SUB1_FILE=$(FIRMWARE_LOCATE)/SmuFirmwareRV2.csbin
-PSP_SMUFW1_SUB2_FILE=$(FIRMWARE_LOCATE)/SmuFirmwarePCO.csbin
-PSP_SMUFW2_SUB1_FILE=$(FIRMWARE_LOCATE)/SmuFirmware2RV2.csbin
-PSP_SMUFW2_SUB2_FILE=$(FIRMWARE_LOCATE)/SmuFirmware2PCO.csbin
+FIRMWARE_LOCATE=$(shell grep -e FIRMWARE_LOCATE $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}')
 
 ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
-# type = 0x9
-PSP_SEC_DBG_KEY_FILE=$(FIRMWARE_LOCATE)/RavenSecureDebug_PublicKey.bin
-# type = 0x13
-PSP_SEC_DEBUG_FILE=$(FIRMWARE_LOCATE)/secure_unlock_prod_RV.sbin
 # Enable secure debug unlock
 PSP_SOFTFUSE_BITS += 0
-PSP_TOKEN_UNLOCK="--token-unlock"
+OPT_TOKEN_UNLOCK="--token-unlock"
 endif
 
 ifeq ($(CONFIG_USE_PSPSECUREOS),y)
 # types = 0x2
-PSPSECUREOS_FILE=$(FIRMWARE_LOCATE)/psp_os_combined_prod_RV.sbin
+OPT_PSP_USE_PSPSECUREOS="--use-pspsecureos"
 endif
 
-# type = 0x21
-PSP_IKEK_FILE=$(FIRMWARE_LOCATE)/PspIkekRV.bin
-
-# type = 0x24
-PSP_SECG1_FILE=$(FIRMWARE_LOCATE)/security_policy_RV2_FP5_AM4.sbin
-PSP_SECG2_FILE=$(FIRMWARE_LOCATE)/security_policy_PCO_FP5_AM4.sbin
 
 ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y)
-# type = 0x25
-PSP_MP2FW1_FILE=$(FIRMWARE_LOCATE)/MP2I2CFWRV2.sbin
-PSP_MP2FW2_FILE=$(FIRMWARE_LOCATE)/MP2I2CFWPCO.sbin
-# BIOS type = 0x6a
-PSP_MP2CFG_FILE=$(FIRMWARE_LOCATE)/MP2FWConfig.sbin
+OPT_PSP_LOAD_MP2_FW="--load-mp2-fw"
 else
 # Disable MP2 firmware loading
 PSP_SOFTFUSE_BITS += 29
 endif
 
-# type = 0x28
-PSP_DRIVERS_FILE=$(FIRMWARE_LOCATE)/drv_sys_prod_RV.sbin
-
 ifeq ($(CONFIG_PSP_LOAD_S0I3_FW),y)
-PSP_S0I3_FILE=$(FIRMWARE_LOCATE)/dr_agesa_prod_RV.sbin
+OPT_PSP_LOAD_S0I3_FW="--load-s0i3"
 endif
 
-# types = 0x30 - 0x37
-PSP_ABL0_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader0_prod_RV.csbin
-PSP_ABL1_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader1_prod_RV.csbin
-PSP_ABL2_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader2_prod_RV.csbin
-PSP_ABL3_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader3_prod_RV.csbin
-PSP_ABL4_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader4_prod_RV.csbin
-PSP_ABL5_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader5_prod_RV.csbin
-PSP_ABL6_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader6_prod_RV.csbin
-PSP_ABL7_FILE=$(FIRMWARE_LOCATE)/AgesaBootloader7_prod_RV.csbin
-
 # type = 0x3a
 ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
 PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
 endif
-
 #
 # BIOS Directory Table items - proper ordering is managed by amdfwtool
 #
@@ -216,16 +174,6 @@
 APOB_NV_SIZE=$(shell grep "FMAP_SECTION_RW_MRC_CACHE_SIZE" $(obj)/fmap_config.h | awk '{print $$(NF)}')
 APOB_NV_BASE=$(shell grep "FMAP_SECTION_RW_MRC_CACHE_START" $(obj)/fmap_config.h | awk '{print $$(NF)}')
 
-# type2 = 0x64, 0x65
-PSP_PMUI_FILE1=$(FIRMWARE_LOCATE)/Appb_Rv_1D_Ddr4_Udimm_Imem.csbin
-PSP_PMUI_FILE2=$(FIRMWARE_LOCATE)/Appb_Rv_2D_Ddr4_Imem.csbin
-PSP_PMUI_FILE3=$(FIRMWARE_LOCATE)/Appb_Rv2_1D_ddr4_Udimm_Imem.csbin
-PSP_PMUI_FILE4=$(FIRMWARE_LOCATE)/Appb_Rv2_2D_ddr4_Udimm_Imem.csbin
-PSP_PMUD_FILE1=$(FIRMWARE_LOCATE)/Appb_Rv_1D_Ddr4_Udimm_Dmem.csbin
-PSP_PMUD_FILE2=$(FIRMWARE_LOCATE)/Appb_Rv_2D_Ddr4_Dmem.csbin
-PSP_PMUD_FILE3=$(FIRMWARE_LOCATE)/Appb_Rv2_1D_ddr4_Udimm_Dmem.csbin
-PSP_PMUD_FILE4=$(FIRMWARE_LOCATE)/Appb_Rv2_2D_ddr4_Udimm_Dmem.csbin
-
 # type = 0x66
 PSP_UCODE_FILE1=$(FIRMWARE_LOCATE)/UcodePatch_PCO_B1.bin
 PSP_UCODE_FILE2=$(FIRMWARE_LOCATE)/UcodePatch_PCO_B0.bin
@@ -259,33 +207,6 @@
 
 add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
 
-OPT_AMD_PUBKEY_FILE=$(call add_opt_prefix, $(CONFIG_AMD_PUBKEY_FILE), --pubkey)
-OPT_PSPBTLDR_FILE=$(call add_opt_prefix, $(PSPBTLDR_FILE), --bootloader)
-OPT_SMUFW1_SUB1_FILE=$(call add_opt_prefix, $(PSP_SMUFW1_SUB1_FILE), --subprogram 1 --smufirmware)
-OPT_SMUFW1_SUB2_FILE=$(call add_opt_prefix, $(PSP_SMUFW1_SUB2_FILE), --subprogram 2 --smufirmware)
-OPT_SMUFW2_SUB1_FILE=$(call add_opt_prefix, $(PSP_SMUFW2_SUB1_FILE), --subprogram 1 --smufirmware2)
-OPT_SMUFW2_SUB2_FILE=$(call add_opt_prefix, $(PSP_SMUFW2_SUB2_FILE), --subprogram 2 --smufirmware2)
-OPT_PSP_SEC_DBG_KEY_FILE=$(call add_opt_prefix, $(PSP_SEC_DBG_KEY_FILE), --securedebug)
-OPT_TOKEN_UNLOCK=$(call add_opt_prefix, $(PSP_TOKEN_UNLOCK), "")
-OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
-OPT_PSPSECUREOS_FILE=$(call add_opt_prefix, $(PSPSECUREOS_FILE), --secureos)
-OPT_SEC_DEBUG_FILE=$(call add_opt_prefix, $(PSP_SEC_DEBUG_FILE), --secdebug)
-OPT_IKEK_FILE=$(call add_opt_prefix, $(PSP_IKEK_FILE), --ikek)
-OPT_SECG1_FILE=$(call add_opt_prefix, $(PSP_SECG1_FILE), --subprog 1 --sec-gasket)
-OPT_SECG2_FILE=$(call add_opt_prefix, $(PSP_SECG2_FILE), --subprog 2 --sec-gasket)
-OPT_MP2FW1_FILE=$(call add_opt_prefix, $(PSP_MP2FW1_FILE), --subprog 1 --mp2-fw)
-OPT_MP2FW2_FILE=$(call add_opt_prefix, $(PSP_MP2FW2_FILE), --subprog 2 --mp2-fw)
-OPT_DRIVERS_FILE=$(call add_opt_prefix, $(PSP_DRIVERS_FILE), --drv-entry-pts)
-OPT_PSP_S0I3_FILE=$(call add_opt_prefix, $(PSP_S0I3_FILE), --s0i3drv)
-OPT_ABL0_FILE=$(call add_opt_prefix,  $(PSP_ABL0_FILE), --abl-image)
-OPT_ABL1_FILE=$(call add_opt_prefix,  $(PSP_ABL1_FILE), --abl-image)
-OPT_ABL2_FILE=$(call add_opt_prefix,  $(PSP_ABL2_FILE), --abl-image)
-OPT_ABL3_FILE=$(call add_opt_prefix,  $(PSP_ABL3_FILE), --abl-image)
-OPT_ABL4_FILE=$(call add_opt_prefix,  $(PSP_ABL4_FILE), --abl-image)
-OPT_ABL5_FILE=$(call add_opt_prefix,  $(PSP_ABL5_FILE), --abl-image)
-OPT_ABL6_FILE=$(call add_opt_prefix,  $(PSP_ABL6_FILE), --abl-image)
-OPT_ABL7_FILE=$(call add_opt_prefix,  $(PSP_ABL7_FILE), --abl-image)
-OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
 OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
 OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
 
@@ -297,15 +218,7 @@
 OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
 OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
 OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
-OPT_PSP_PMUI_FILE1=$(call add_opt_prefix, $(PSP_PMUI_FILE1), --subprogram 0 --instance 1 --pmu-inst)
-OPT_PSP_PMUI_FILE2=$(call add_opt_prefix, $(PSP_PMUI_FILE2), --subprogram 0 --instance 4 --pmu-inst)
-OPT_PSP_PMUI_FILE3=$(call add_opt_prefix, $(PSP_PMUI_FILE3), --subprogram 1 --instance 1 --pmu-inst)
-OPT_PSP_PMUI_FILE4=$(call add_opt_prefix, $(PSP_PMUI_FILE4), --subprogram 1 --instance 4 --pmu-inst)
-OPT_PSP_PMUD_FILE1=$(call add_opt_prefix, $(PSP_PMUD_FILE1), --subprogram 0 --instance 1 --pmu-data)
-OPT_PSP_PMUD_FILE2=$(call add_opt_prefix, $(PSP_PMUD_FILE2), --subprogram 0 --instance 4 --pmu-data)
-OPT_PSP_PMUD_FILE3=$(call add_opt_prefix, $(PSP_PMUD_FILE3), --subprogram 1 --instance 1 --pmu-data)
-OPT_PSP_PMUD_FILE4=$(call add_opt_prefix, $(PSP_PMUD_FILE4), --subprogram 1 --instance 4 --pmu-data)
-OPT_MP2CFG_FILE=$(call add_opt_prefix, $(PSP_MP2CFG_FILE), --mp2-config)
+
 OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
 OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
 OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
@@ -314,49 +227,28 @@
 OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
 OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
 
+OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
+
 ifeq ($(CONFIG_VBOOT),)
 OPT_APOB0_NV_SIZE=$(OPT_APOB_NV_SIZE)
 OPT_APOB0_NV_BASE=$(OPT_APOB_NV_BASE)
 endif
 
-AMDFW_COMMON_ARGS=$(OPT_AMD_PUBKEY_FILE) \
-		$(OPT_PSPSECUREOS_FILE) \
-		$(OPT_PSP_SEC_DBG_KEY_FILE) \
-		$(OPT_SMUFW1_SUB2_FILE) \
-		$(OPT_SMUFW2_SUB2_FILE) \
-		$(OPT_SMUFW1_SUB1_FILE) \
-		$(OPT_SMUFW2_SUB1_FILE) \
-		$(OPT_PSP_APCB_FILES) \
+OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
+
+# Add all the files listed in the config file
+DEP_FILES=$(shell $(AMDFWTOOL) --config $(CONFIG_AMDFW_CONFIG_FILE) --depend)
+
+AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
 		$(OPT_APOB_ADDR) \
 		$(OPT_PSP_BIOSBIN_FILE) \
 		$(OPT_PSP_BIOSBIN_DEST) \
 		$(OPT_PSP_BIOSBIN_SIZE) \
 		$(OPT_PSP_SOFTFUSE) \
-		$(OPT_PSP_PMUI_FILE1) \
-		$(OPT_PSP_PMUI_FILE2) \
-		$(OPT_PSP_PMUI_FILE3) \
-		$(OPT_PSP_PMUI_FILE4) \
-		$(OPT_PSP_PMUD_FILE1) \
-		$(OPT_PSP_PMUD_FILE2) \
-		$(OPT_PSP_PMUD_FILE3) \
-		$(OPT_PSP_PMUD_FILE4) \
-		$(OPT_MP2CFG_FILE) \
-		$(OPT_ABL0_FILE) \
-		$(OPT_ABL1_FILE) \
-		$(OPT_ABL2_FILE) \
-		$(OPT_ABL3_FILE) \
-		$(OPT_ABL4_FILE) \
-		$(OPT_ABL5_FILE) \
-		$(OPT_ABL6_FILE) \
-		$(OPT_ABL7_FILE) \
+		$(OPT_PSP_USE_PSPSECUREOS) \
+		$(OPT_PSP_LOAD_MP2_FW) \
+		$(OPT_PSP_LOAD_S0I3_FW) \
 		$(OPT_WHITELIST_FILE) \
-		$(OPT_SECG1_FILE) \
-		$(OPT_SECG2_FILE) \
-		$(OPT_MP2FW1_FILE) \
-		$(OPT_MP2FW2_FILE) \
-		$(OPT_DRIVERS_FILE) \
-		$(OPT_PSP_S0I3_FILE) \
-		$(OPT_IKEK_FILE) \
 		$(OPT_SEC_DEBUG_FILE) \
 		$(OPT_PSP_SHAREDMEM_BASE) \
 		$(OPT_PSP_SHAREDMEM_SIZE) \
@@ -365,45 +257,15 @@
 		$(OPT_EFS_SPI_READ_MODE) \
 		$(OPT_EFS_SPI_SPEED) \
 		$(OPT_EFS_SPI_MICRON_FLAG) \
+		--config $(CONFIG_AMDFW_CONFIG_FILE) \
 		--soc-name "Picasso" \
 		--flashsize $(CONFIG_ROM_SIZE)
 
-$(obj)/amdfw.rom:	$(call strip_quotes, $(CONFIG_AMD_PUBKEY_FILE)) \
-			$(call strip_quotes, $(PSPBTLDR_FILE)) \
-			$(call strip_quotes, $(PSPSECUREOS_FILE)) \
-			$(call strip_quotes, $(PSP_SEC_DBG_KEY_FILE)) \
-			$(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
-			$(call strip_quotes, $(PSP_PMUI_FILE1)) \
-			$(call strip_quotes, $(PSP_PMUI_FILE2)) \
-			$(call strip_quotes, $(PSP_PMUI_FILE3)) \
-			$(call strip_quotes, $(PSP_PMUI_FILE4)) \
-			$(call strip_quotes, $(PSP_PMUD_FILE1)) \
-			$(call strip_quotes, $(PSP_PMUD_FILE2)) \
-			$(call strip_quotes, $(PSP_PMUD_FILE3)) \
-			$(call strip_quotes, $(PSP_PMUD_FILE4)) \
-			$(call strip_quotes, $(PSP_MP2CFG_FILE)) \
-			$(call strip_quotes, $(PSP_SMUFW1_SUB1_FILE)) \
-			$(call strip_quotes, $(PSP_SMUFW1_SUB2_FILE)) \
-			$(call strip_quotes, $(PSP_SMUFW2_SUB1_FILE)) \
-			$(call strip_quotes, $(PSP_SMUFW2_SUB2_FILE)) \
-			$(call strip_quotes, $(PSP_ABL0_FILE)) \
-			$(call strip_quotes, $(PSP_ABL1_FILE)) \
-			$(call strip_quotes, $(PSP_ABL2_FILE)) \
-			$(call strip_quotes, $(PSP_ABL3_FILE)) \
-			$(call strip_quotes, $(PSP_ABL4_FILE)) \
-			$(call strip_quotes, $(PSP_ABL5_FILE)) \
-			$(call strip_quotes, $(PSP_ABL6_FILE)) \
-			$(call strip_quotes, $(PSP_ABL7_FILE)) \
-			$(call strip_quotes, $(PSP_WHITELIST_FILE)) \
-			$(call strip_quotes, $(PSP_SECG1_FILE)) \
-			$(call strip_quotes, $(PSP_SECG2_FILE)) \
-			$(call_strip_quotes, $(PSP_DRIVERS_FILE)) \
-			$(call_strip_quotes, $(PSP_S0I3_FILE)) \
-			$(call_strip_quotes, $(PSP_IKEK_FILE)) \
-			$(call_strip_quotes, $(PSP_SEC_DEBUG_FILE)) \
+$(obj)/amdfw.rom:	$(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
 			$(PSP_VERSTAGE_FILE) \
 			$(PSP_VERSTAGE_SIG_FILE) \
 			$$(PSP_APCB_FILES) \
+			$(DEP_FILES) \
 			$(AMDFWTOOL) \
 			$(obj)/fmap_config.h
 	$(if $(PSP_APCB_FILES), ,$(error APCB_SOURCES is not set))
diff --git a/src/soc/amd/picasso/fw.cfg b/src/soc/amd/picasso/fw.cfg
new file mode 100644
index 0000000..e746d1e
--- /dev/null
+++ b/src/soc/amd/picasso/fw.cfg
@@ -0,0 +1,39 @@
+# PSP fw config file
+
+FIRMWARE_LOCATE        3rdparty/amd_blobs/picasso/PSP
+
+# type                    file
+AMD_PUBKEY_FILE        AmdPubKeyRV.bin
+PSPBTLDR_FILE          PspBootLoader_prod_RV.sbin
+PSPBTLDR_WL_FILE       PspBootLoader_WL_RV.sbin
+PSP_SMUFW1_SUB1_FILE   SmuFirmwareRV2.csbin
+PSP_SMUFW1_SUB2_FILE   SmuFirmwarePCO.csbin
+PSP_SMUFW2_SUB1_FILE   SmuFirmware2RV2.csbin
+PSP_SMUFW2_SUB2_FILE   SmuFirmware2PCO.csbin
+PSPSECUREOS_FILE       psp_os_combined_prod_RV.sbin
+PSP_SEC_DBG_KEY_FILE   RavenSecureDebug_PublicKey.bin
+PSP_SEC_DEBUG_FILE     secure_unlock_prod_RV.sbin
+PSP_ABL0_FILE          AgesaBootloader0_prod_RV.csbin
+PSP_ABL1_FILE          AgesaBootloader1_prod_RV.csbin
+PSP_ABL2_FILE          AgesaBootloader2_prod_RV.csbin
+PSP_ABL3_FILE          AgesaBootloader3_prod_RV.csbin
+PSP_ABL4_FILE          AgesaBootloader4_prod_RV.csbin
+PSP_ABL5_FILE          AgesaBootloader5_prod_RV.csbin
+PSP_ABL6_FILE          AgesaBootloader6_prod_RV.csbin
+PSP_ABL7_FILE          AgesaBootloader7_prod_RV.csbin
+PSP_IKEK_FILE          PspIkekRV.bin
+PSP_SECG1_FILE         security_policy_RV2_FP5_AM4.sbin
+PSP_SECG2_FILE         security_policy_PCO_FP5_AM4.sbin
+PSP_MP2FW1_FILE        MP2I2CFWRV2.sbin
+PSP_MP2FW2_FILE        MP2I2CFWPCO.sbin
+PSP_MP2CFG_FILE        MP2FWConfig.sbin
+PSP_DRIVERS_FILE       drv_sys_prod_RV.sbin
+# BDT
+PSP_PMUI_FILE1         Appb_Rv_1D_Ddr4_Udimm_Imem.csbin
+PSP_PMUI_FILE2         Appb_Rv_2D_Ddr4_Imem.csbin
+PSP_PMUI_FILE3         Appb_Rv2_1D_ddr4_Udimm_Imem.csbin
+PSP_PMUI_FILE4         Appb_Rv2_2D_ddr4_Udimm_Imem.csbin
+PSP_PMUD_FILE1         Appb_Rv_1D_Ddr4_Udimm_Dmem.csbin
+PSP_PMUD_FILE2         Appb_Rv_2D_Ddr4_Dmem.csbin
+PSP_PMUD_FILE3         Appb_Rv2_1D_ddr4_Udimm_Dmem.csbin
+PSP_PMUD_FILE4         Appb_Rv2_2D_ddr4_Udimm_Dmem.csbin
diff --git a/src/soc/amd/stoneyridge/Kconfig b/src/soc/amd/stoneyridge/Kconfig
index 2ef90eb..0e32005 100644
--- a/src/soc/amd/stoneyridge/Kconfig
+++ b/src/soc/amd/stoneyridge/Kconfig
@@ -190,12 +190,13 @@
 	string "GEC firmware path and filename"
 	depends on STONEYRIDGE_GEC_FWM
 
-config AMD_PUBKEY_FILE
-	string "AMD public Key"
+config AMDFW_CONFIG_FILE
+	string
+	string "AMD PSP Firmware config file"
 	default "" if !USE_AMD_BLOBS
-	default "3rdparty/amd_blobs/stoneyridge/PSP/CZ/AmdPubKeyCZ.bin" if AMD_APU_MERLINFALCON
-	default "3rdparty/amd_blobs/stoneyridge/PSP/ST/AmdPubKeyST.bin" if AMD_APU_PRAIRIEFALCON
-	default "3rdparty/amd_blobs/stoneyridge/PSP/ST/AmdPubKeyST.bin" if AMD_APU_STONEYRIDGE
+	default "src/soc/amd/stoneyridge/fw_cz.cfg" if AMD_APU_MERLINFALCON
+	default "src/soc/amd/stoneyridge/fw_st.cfg" if AMD_APU_PRAIRIEFALCON
+	default "src/soc/amd/stoneyridge/fw_st.cfg" if AMD_APU_STONEYRIDGE
 
 config STONEYRIDGE_SATA_MODE
 	int "SATA Mode"
diff --git a/src/soc/amd/stoneyridge/Makefile.inc b/src/soc/amd/stoneyridge/Makefile.inc
index 16597e1..9211e81 100644
--- a/src/soc/amd/stoneyridge/Makefile.inc
+++ b/src/soc/amd/stoneyridge/Makefile.inc
@@ -101,7 +101,9 @@
 	0x80000 $(CONFIG_AMD_FWM_POSITION_INDEX))) 0x20000 1)
 
 ### 0
-FIRMWARE_LOCATE=$(dir $(call strip_quotes, $(CONFIG_AMD_PUBKEY_FILE)))
+
+FIRMWARE_LOCATE=$(shell grep -e FIRMWARE_LOCATE $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}')
+
 ifneq ($(FIRMWARE_LOCATE),)
 
 ifeq ($(CONFIG_AMD_APU_STONEYRIDGE),y)
@@ -119,134 +121,47 @@
 endif # CONFIG_AMD_APU_MERLINFALCON
 endif # CONFIG_AMD_APU_STONEYRIDGE
 
-###5
-PUBSIGNEDKEY_FILE=$(top)/$(FIRMWARE_LOCATE)/RtmPubSigned$(FIRMWARE_TYPE).key
+add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
 
-###1
-PSPBTLDR_FILE=$(top)/$(FIRMWARE_LOCATE)/PspBootLoader_prod_$(FIRMWARE_TYPE).sbin
+OPT_STONEYRIDGE_XHCI_FWM_FILE=$(call add_opt_prefix, $(CONFIG_STONEYRIDGE_XHCI_FWM_FILE), --xhci)
+OPT_STONEYRIDGE_GEC_FWM_FILE=$(call add_opt_prefix, $(CONFIG_STONEYRIDGE_GEC_FWM_FILE), --gec)
 
-###3
-PSPRCVR_FILE=$(top)/$(FIRMWARE_LOCATE)/PspRecoveryBootLoader_prod_$(FIRMWARE_TYPE).sbin
+SMUFWM_FILE=$(top)/$(FIRMWARE_LOCATE)/$(shell awk '($$1=="PSP_SMUFW1_SUB0_FILE") {print $$2}' $(CONFIG_AMDFW_CONFIG_FILE))
+SMUFWM_FN_FILE=$(top)/$(FIRMWARE_LOCATE)/$(shell awk '($$1=="PSP_SMUFW1_SUB1_FILE") {print $$2}' $(CONFIG_AMDFW_CONFIG_FILE))
 
-###4
-PSPNVRAM_FILE=$(top)/$(FIRMWARE_LOCATE)/PspNvram$(FIRMWARE_TYPE).bin
-
-###8 - Check for SMU firmware named either *.sbin or *.csbin.  Both "signed" and
-###    "compressed signed" are used by generations supported by this file.
-SMUFWM_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware_$(FIRMWARE_TYPE).csbin
-SMUFWM_FN_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware_$(FIRMWARE_TYPE)_FN.csbin
-ifeq ("$(wildcard $(SMUFWM_FILE))","")
-SMUFWM_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware$(FIRMWARE_TYPE).sbin
-SMUFWM_FN_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware$(FIRMWARE_TYPE)_FN.sbin
-endif
-
-###95
-SMUSCS_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuScs$(FIRMWARE_TYPE).bin
-
-###9
-PSPSECUREDEBUG_FILE=$(top)/$(FIRMWARE_LOCATE)/PspSecureDebug$(FIRMWARE_TYPE).Key
-
-ifeq ($(CONFIG_USE_PSPSECUREOS),y)
-###2
-PSPSECUREOS_FILE=$(top)/$(FIRMWARE_LOCATE)/PspSecureOs_prod_$(FIRMWARE_TYPE).csbin
-
-###12
-PSPTRUSTLETS_FILE=$(wildcard $(top)/$(FIRMWARE_LOCATE)/PspTrustlets*_prod_$(FIRMWARE_TYPE).cbin)
-
-###13
-TRUSTLETKEY_FILE=$(top)/$(FIRMWARE_LOCATE)/TrustletKey_prod_$(FIRMWARE_TYPE).sbin
-endif
-
-###18- Check for SMU firmware2 named either *.sbin or *.csbin
-###    TODO: Remove *.sbin section after the blobs repo is updated.
-SMUFIRMWARE2_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware2_prod_$(FIRMWARE_TYPE).csbin
-SMUFIRMWARE2_FN_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware2_prod_$(FIRMWARE_TYPE)_FN.csbin
-ifeq ("$(wildcard $(SMUFIRMWARE2_FILE))","")
-SMUFIRMWARE2_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware2_prod_$(FIRMWARE_TYPE).sbin
-SMUFIRMWARE2_FN_FILE=$(top)/$(FIRMWARE_LOCATE)/SmuFirmware2_prod_$(FIRMWARE_TYPE)_FN.sbin
-endif
+SMUFIRMWARE2_FILE=$(top)/$(FIRMWARE_LOCATE)/$(shell awk '($$1=="PSP_SMUFW2_SUB0_FILE") {print $$2}' $(CONFIG_AMDFW_CONFIG_FILE))
+SMUFIRMWARE2_FN_FILE=$(top)/$(FIRMWARE_LOCATE)/$(shell awk '($$1=="PSP_SMUFW2_SUB1_FILE") {print $$2}' $(CONFIG_AMDFW_CONFIG_FILE))
 
 ifeq ("$(wildcard $(SMUFWM_FN_FILE))","")
 SMUFWM_FN_FILE=
 SMUFIRMWARE2_FN_FILE=
 endif
 
-add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
-
-OPT_STONEYRIDGE_XHCI_FWM_FILE=$(call add_opt_prefix, $(CONFIG_STONEYRIDGE_XHCI_FWM_FILE), --xhci)
-OPT_STONEYRIDGE_GEC_FWM_FILE=$(call add_opt_prefix, $(CONFIG_STONEYRIDGE_GEC_FWM_FILEddd), --gec)
-
-OPT_AMD_PUBKEY_FILE=$(call add_opt_prefix, $(CONFIG_AMD_PUBKEY_FILE), --pubkey)
-OPT_PSPBTLDR_FILE=$(call add_opt_prefix, $(PSPBTLDR_FILE), --bootloader)
-OPT_SMUFWM_FILE=$(call add_opt_prefix, $(SMUFWM_FILE), --smufirmware)
-OPT_PSPRCVR_FILE=$(call add_opt_prefix, $(PSPRCVR_FILE), --recovery)
-OPT_PUBSIGNEDKEY_FILE=$(call add_opt_prefix, $(PUBSIGNEDKEY_FILE), --rtmpubkey)
-OPT_PSPNVRAM_FILE=$(call add_opt_prefix, $(PSPNVRAM_FILE), --nvram)
-OPT_PSPSECUREDEBUG_FILE=$(call add_opt_prefix, $(PSPSECUREDEBUG_FILE), --securedebug)
-ifeq ($(CONFIG_USE_PSPSECUREOS),y)
-OPT_PSPSECUREOS_FILE=$(call add_opt_prefix, $(PSPSECUREOS_FILE), --secureos)
-OPT_PSPTRUSTLETS_FILE=$(call add_opt_prefix, $(PSPTRUSTLETS_FILE), --trustlets)
-OPT_TRUSTLETKEY_FILE=$(call add_opt_prefix, $(TRUSTLETKEY_FILE), --trustletkey)
-endif
-OPT_SMUFIRMWARE2_FILE=$(call add_opt_prefix, $(SMUFIRMWARE2_FILE), --smufirmware2)
-OPT_SMUSCS_FILE=$(call add_opt_prefix, $(SMUSCS_FILE), --smuscs)
-SUBPROG_FN_SMU_FW=1
-OPT_SMUFWM_FN_FILE=$(call add_opt_prefix, $(SMUFWM_FN_FILE), --subprogram $(SUBPROG_FN_SMU_FW) --smufirmware)
-OPT_SMUFIRMWARE2_FN_FILE=$(call add_opt_prefix, $(SMUFIRMWARE2_FN_FILE), --subprogram $(SUBPROG_FN_SMU_FW) --smufirmware2)
-
 ifeq ($(FIRMWARE_TYPE),ST)
 OPT_COMBOCAPABLE=--combo-capable
 endif
 
+ifeq ($(CONFIG_USE_PSPSECUREOS),y)
+PSP_USE_PSPSECUREOS="--use-pspsecureos"
+endif
+
+OPT_PSP_USE_PSPSECUREOS=$(call strip_quotes, $(PSP_USE_PSPSECUREOS))
+
+# Add all the files listed in the config file
+DEP_FILES=$(shell $(AMDFWTOOL) --config $(CONFIG_AMDFW_CONFIG_FILE) --depend)
+
 $(obj)/amdfw.rom:	$(call strip_quotes, $(CONFIG_STONEYRIDGE_XHCI_FWM_FILE)) \
 			$(call strip_quotes, $(CONFIG_STONEYRIDGE_GEC_FWM_FILE)) \
-			$(call strip_quotes, $(CONFIG_AMD_PUBKEY_FILE)) \
-			$(call strip_quotes, $(PUBSIGNEDKEY_FILE)) \
-			$(call strip_quotes, $(PSPBTLDR_FILE)) \
-			$(call strip_quotes, $(PSPRCVR_FILE)) \
-			$(call strip_quotes, $(PSPSECUREOS_FILE)) \
-			$(call strip_quotes, $(PSPNVRAM_FILE)) \
-			$(call strip_quotes, $(SMUFWM_FILE)) \
-			$(call strip_quotes, $(SMUFWM_FN_FILE)) \
-			$(call strip_quotes, $(SMUSCS_FILE)) \
-			$(call strip_quotes, $(PSPSECUREDEBUG_FILE)) \
-			$(call strip_quotes, $(PSPTRUSTLETS_FILE)) \
-			$(call strip_quotes, $(TRUSTLETKEY_FILE)) \
-			$(call strip_quotes, $(SMUFIRMWARE2_FILE)) \
-			$(call strip_quotes, $(SMUFIRMWARE2_FN_FILE)) \
+			$(DEP_FILES) \
 			$(AMDFWTOOL)
 	rm -f $@
 	@printf "    AMDFWTOOL  $(subst $(obj)/,,$(@))\n"
 	$(AMDFWTOOL) \
 		$(OPT_STONEYRIDGE_XHCI_FWM_FILE) \
 		$(OPT_STONEYRIDGE_GEC_FWM_FILE) \
-		$(OPT_AMD_PUBKEY_FILE) \
-		$(OPT_PSPBTLDR_FILE) \
-		$(OPT_SMUFWM_FILE) \
-		$(OPT_PSPRCVR_FILE) \
-		$(OPT_PUBSIGNEDKEY_FILE) \
-		$(OPT_PSPSECUREOS_FILE) \
-		$(OPT_PSPNVRAM_FILE) \
-		$(OPT_PSPSECUREDEBUG_FILE) \
-		$(OPT_PSPTRUSTLETS_FILE) \
-		$(OPT_TRUSTLETKEY_FILE) \
-		$(OPT_SMUFIRMWARE2_FILE) \
-		$(OPT_SMUSCS_FILE) \
-		$(OPT_AMD_PUBKEY_FILE) \
-		$(OPT_PSPBTLDR_FILE) \
-		$(OPT_SMUFWM_FILE) \
-		$(OPT_SMUFWM_FN_FILE) \
-		$(OPT_PSPRCVR_FILE) \
-		$(OPT_PUBSIGNEDKEY_FILE) \
-		$(OPT_PSPSECUREOS_FILE) \
-		$(OPT_PSPNVRAM_FILE) \
-		$(OPT_PSPSECUREDEBUG_FILE) \
-		$(OPT_PSPTRUSTLETS_FILE) \
-		$(OPT_TRUSTLETKEY_FILE) \
-		$(OPT_SMUFIRMWARE2_FILE) \
-		$(OPT_SMUFIRMWARE2_FN_FILE) \
-		$(OPT_SMUSCS_FILE) \
 		$(OPT_COMBOCAPABLE)\
+		$(OPT_PSP_USE_PSPSECUREOS) \
+		--config $(CONFIG_AMDFW_CONFIG_FILE) \
 		--flashsize $(CONFIG_ROM_SIZE) \
 		--location $(shell printf "0x%x" $(STONEYRIDGE_FWM_POSITION)) \
 		--output	$@
diff --git a/src/soc/amd/stoneyridge/fw_cz.cfg b/src/soc/amd/stoneyridge/fw_cz.cfg
new file mode 100644
index 0000000..acbf136
--- /dev/null
+++ b/src/soc/amd/stoneyridge/fw_cz.cfg
@@ -0,0 +1,18 @@
+# PSP fw config file
+
+FIRMWARE_LOCATE        3rdparty/amd_blobs/stoneyridge/PSP/CZ
+#PSP
+AMD_PUBKEY_FILE        AmdPubKeyCZ.bin
+PSPBTLDR_FILE          PspBootLoader_prod_CZ.sbin
+PSP_SMUFW1_SUB0_FILE   SmuFirmwareCZ.sbin
+#PSP_SMUFW1_SUB1_FILE   SmuFirmware_CZ_FN.csbin
+PSP_SMUFW2_SUB0_FILE   SmuFirmware2_prod_CZ.sbin
+#PSP_SMUFW2_SUB1_FILE   SmuFirmware2_prod_CZ_FN.sbin
+PSPRCVR_FILE           PspRecoveryBootLoader_prod_CZ.sbin
+PUBSIGNEDKEY_FILE      RtmPubSignedCZ.key
+PSPNVRAM_FILE          PspNvramCZ.bin
+PSPSECUREOS_FILE       PspSecureOs_prod_CZ.csbin
+SMUSCS_FILE            SmuScsCZ.bin
+PSPTRUSTLETS_FILE      PspTrustlets_prod_CZ.cbin
+TRUSTLETKEY_FILE       TrustletKey_prod_CZ.sbin
+PSPSECUREDEBUG_FILE    PspSecureDebugCZ.Key
diff --git a/src/soc/amd/stoneyridge/fw_st.cfg b/src/soc/amd/stoneyridge/fw_st.cfg
new file mode 100644
index 0000000..aa02668
--- /dev/null
+++ b/src/soc/amd/stoneyridge/fw_st.cfg
@@ -0,0 +1,20 @@
+# PSP fw config file
+
+FIRMWARE_LOCATE        3rdparty/amd_blobs/stoneyridge/PSP/ST
+
+#XHCI_FWM_FILE          xhci.bin
+#PSP
+AMD_PUBKEY_FILE        AmdPubKeyST.bin
+PSPBTLDR_FILE          PspBootLoader_prod_ST.sbin
+PSP_SMUFW1_SUB0_FILE   SmuFirmware_ST.csbin
+PSP_SMUFW1_SUB1_FILE   SmuFirmware_ST_FN.csbin
+PSP_SMUFW2_SUB0_FILE   SmuFirmware2_prod_ST.csbin
+PSP_SMUFW2_SUB1_FILE   SmuFirmware2_prod_ST_FN.sbin
+PSPRCVR_FILE           PspRecoveryBootLoader_prod_ST.sbin
+PUBSIGNEDKEY_FILE      RtmPubSignedST.key
+PSPNVRAM_FILE          PspNvramST.bin
+PSPSECUREOS_FILE       PspSecureOs_prod_ST.csbin
+SMUSCS_FILE            SmuScsST.bin
+PSPTRUSTLETS_FILE      PspTrustlets_prod_ST.cbin
+TRUSTLETKEY_FILE       TrustletKey_prod_ST.sbin
+PSPSECUREDEBUG_FILE    PspSecureDebugST.Key