blob: 27e5abcbf9b0d91d88ed3d9b8daee9885cb5ab89 [file] [log] [blame]
Martin Roth1a3de8e2022-10-06 15:57:21 -06001# SPDX-License-Identifier: BSD-3-Clause
2
3# TODO: Move as much as possible to common
Martin Roth20646cd2023-01-04 21:27:06 -07004# TODO: Update for Phoenix
Martin Roth1a3de8e2022-10-06 15:57:21 -06005
Martin Roth20646cd2023-01-04 21:27:06 -07006ifeq ($(CONFIG_SOC_AMD_PHOENIX),y)
Martin Roth1a3de8e2022-10-06 15:57:21 -06007
8subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage
9
10# Beware that all-y also adds the compilation unit to verstage on PSP
Martin Roth1a3de8e2022-10-06 15:57:21 -060011all-y += aoac.c
Felix Held46cd1b52023-04-01 01:21:27 +020012all-y += config.c
13all-y += i2c.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060014
Martin Roth1a3de8e2022-10-06 15:57:21 -060015bootblock-y += early_fch.c
16bootblock-y += espi_util.c
17bootblock-y += gpio.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060018bootblock-y += uart.c
19
Martin Roth1a3de8e2022-10-06 15:57:21 -060020verstage-y += espi_util.c
21verstage_x86-y += gpio.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060022verstage_x86-y += uart.c
23
24romstage-y += fsp_m_params.c
25romstage-y += gpio.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060026romstage-y += romstage.c
Felix Held8f705b92023-02-06 19:56:35 +010027romstage-y += soc_util.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060028romstage-y += uart.c
29
30ramstage-y += acpi.c
31ramstage-y += agesa_acpi.c
32ramstage-y += chip.c
33ramstage-y += cpu.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060034ramstage-y += fch.c
35ramstage-y += fsp_s_params.c
36ramstage-y += gpio.c
Ritul Guru4843ded2023-02-20 00:45:11 +053037ramstage-y += graphics.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060038ramstage-y += mca.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060039ramstage-y += root_complex.c
Felix Held8f705b92023-02-06 19:56:35 +010040ramstage-y += soc_util.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060041ramstage-y += uart.c
42ramstage-y += xhci.c
43
44smm-y += gpio.c
45smm-y += smihandler.c
Martin Roth1a3de8e2022-10-06 15:57:21 -060046smm-$(CONFIG_DEBUG_SMI) += uart.c
47
Martin Roth20646cd2023-01-04 21:27:06 -070048CPPFLAGS_common += -I$(src)/soc/amd/phoenix/include
49CPPFLAGS_common += -I$(src)/soc/amd/phoenix/acpi
50CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/phoenix
Martin Roth1a3de8e2022-10-06 15:57:21 -060051CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/common
52
Martin Roth1a3de8e2022-10-06 15:57:21 -060053# ROMSIG Normally At ROMBASE + 0x20000
54# Overridden by CONFIG_AMD_FWM_POSITION_INDEX
55# +-----------+---------------+----------------+------------+
56# |0x55AA55AA | | | |
57# +-----------+---------------+----------------+------------+
58# | | PSPDIR ADDR | BIOSDIR ADDR |
59# +-----------+---------------+----------------+
60
61$(if $(CONFIG_AMD_FWM_POSITION_INDEX), ,\
62 $(error Invalid AMD firmware position index. Check if the board sets a valid ROM size))
63
Martin Rothb486fe92023-01-09 21:21:48 -070064# Fixed EFS location
65PHOENIX_FWM_POSITION=0xff020000
Martin Roth1a3de8e2022-10-06 15:57:21 -060066
67# 0x40 accounts for the cbfs_file struct + filename + metadata structs, aligned to 64 bytes
68# Building the cbfs image will fail if the offset isn't large enough
69AMD_FW_AB_POSITION := 0x40
70
Martin Roth20646cd2023-01-04 21:27:06 -070071PHOENIX_FW_A_POSITION=$(call int-add, \
Martin Roth1a3de8e2022-10-06 15:57:21 -060072 $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_A_START" {print $$3}' $(obj)/fmap_config.h) \
73 $(AMD_FW_AB_POSITION))
74
Martin Roth20646cd2023-01-04 21:27:06 -070075PHOENIX_FW_B_POSITION=$(call int-add, \
Martin Roth1a3de8e2022-10-06 15:57:21 -060076 $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_B_START" {print $$3}' $(obj)/fmap_config.h) \
77 $(AMD_FW_AB_POSITION))
78#
79# PSP Directory Table items
80#
81# Certain ordering requirements apply, however these are ensured by amdfwtool.
82# For more information see "AMD Platform Security Processor BIOS Architecture
83# Design Guide for AMD Family 17h Processors" (PID #55758, NDA only).
84#
85
86ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y)
87PSP_SOFTFUSE_BITS += 7
88endif
89
90ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
91# Enable secure debug unlock
92PSP_SOFTFUSE_BITS += 0
93OPT_TOKEN_UNLOCK="--token-unlock"
94endif
95
96ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y)
97OPT_PSP_LOAD_MP2_FW="--load-mp2-fw"
98else
99# Disable MP2 firmware loading
100PSP_SOFTFUSE_BITS += 29
101endif
102
103# Use additional Soft Fuse bits specified in Kconfig
104PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS))
105
106# type = 0x3a
107ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
108PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
109endif
110
111# type = 0x55
112ifeq ($(CONFIG_HAVE_SPL_FILE),y)
113SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
114ifeq ($(CONFIG_HAVE_SPL_RW_AB_FILE),y)
115SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_RW_AB_TABLE_FILE)
116else
117SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
118endif
119endif
120
121#
122# BIOS Directory Table items - proper ordering is managed by amdfwtool
123#
124
125# type = 0x60
126PSP_APCB_FILES=$(APCB_SOURCES) $(APCB_SOURCES_RECOVERY)
127
128# type = 0x61
129PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS)
130
131# type = 0x62
132PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img
133PSP_ELF_FILE=$(objcbfs)/bootblock.elf
Felix Held3b89c952022-11-22 20:02:46 +0100134PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}')
135PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}')
Martin Roth1a3de8e2022-10-06 15:57:21 -0600136
137# type = 0x63 - construct APOB NV base/size from flash map
138# The flashmap section used for this is expected to be named RW_MRC_CACHE
139APOB_NV_SIZE=$(shell awk '$$2 == "FMAP_SECTION_RW_MRC_CACHE_SIZE" {print $$3}' $(obj)/fmap_config.h)
140APOB_NV_BASE=$(shell awk '$$2 == "FMAP_SECTION_RW_MRC_CACHE_START" {print $$3}' $(obj)/fmap_config.h)
141
Zheng Baoa4284b02023-02-01 13:16:52 +0800142ifeq ($(CONFIG_AMDFW_SPLIT),y)
143FMAP_AMDFW_BODY_LOCATION=$(shell awk '$$2 == "FMAP_SECTION_AMDFWBODY_START" {print $$3}' $(obj)/fmap_config.h)
144endif
145
Martin Roth1a3de8e2022-10-06 15:57:21 -0600146ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
147# type = 0x6B - PSP Shared memory location
148ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0)
149PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE)
150PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map)
151endif
152
153# type = 0x52 - PSP Bootloader Userspace Application (verstage)
154PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE))
155PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN))
156endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK
157
158ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
159SIGNED_AMDFW_A_POSITION=$(call int-subtract, \
160 $(shell awk '$$2 == "FMAP_SECTION_SIGNED_AMDFW_A_START" {print $$3}' $(obj)/fmap_config.h) \
161 $(shell awk '$$2 == "FMAP_SECTION_FLASH_START" {print $$3}' $(obj)/fmap_config.h))
162SIGNED_AMDFW_B_POSITION=$(call int-subtract, \
163 $(shell awk '$$2 == "FMAP_SECTION_SIGNED_AMDFW_B_START" {print $$3}' $(obj)/fmap_config.h) \
164 $(shell awk '$$2 == "FMAP_SECTION_FLASH_START" {print $$3}' $(obj)/fmap_config.h))
165SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.signed
166SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.signed
167endif # CONFIG_SEPARATE_SIGNED_PSPFW
168
169# Helper function to return a value with given bit set
170# Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions.
171set-bit=$(call int-shift-left, 1 $(call _toint,$1))
172PSP_SOFTFUSE=$(shell A=$(call int-add, \
173 $(foreach bit,$(PSP_SOFTFUSE_BITS),$(call set-bit,$(bit)))); printf "0x%x" $$A)
174
175#
176# Build the arguments to amdfwtool (order is unimportant). Missing file names
177# result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
178#
179
180add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
181
182OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
183OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
184
185OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
186 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
187 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
188
189OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
190OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
191OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
192OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
193
194OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
195OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
196OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
197OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base)
198OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
199OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
200OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
201
202OPT_SIGNED_AMDFW_A_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_A_POSITION), --signed-addr)
203OPT_SIGNED_AMDFW_A_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_A_FILE), --signed-output)
204OPT_SIGNED_AMDFW_B_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_B_POSITION), --signed-addr)
205OPT_SIGNED_AMDFW_B_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_B_FILE), --signed-output)
206
207OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
208
209OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
210OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
211OPT_SPL_RW_AB_TABLE_FILE=$(call add_opt_prefix, $(SPL_RW_AB_TABLE_FILE), --spl-table)
212
213# If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant
214OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy)
215
Zheng Baoa4284b02023-02-01 13:16:52 +0800216OPT_AMDFW_BODY_LOCATION=$(call add_opt_prefix, $(FMAP_AMDFW_BODY_LOCATION), --body-location)
217
Martin Roth1a3de8e2022-10-06 15:57:21 -0600218AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
219 $(OPT_APOB_ADDR) \
Martin Roth0acf59d2023-03-08 15:18:24 -0700220 $(OPT_DEBUG_AMDFWTOOL) \
Martin Roth1a3de8e2022-10-06 15:57:21 -0600221 $(OPT_PSP_BIOSBIN_FILE) \
222 $(OPT_PSP_BIOSBIN_DEST) \
223 $(OPT_PSP_BIOSBIN_SIZE) \
224 $(OPT_PSP_SOFTFUSE) \
225 $(OPT_PSP_LOAD_MP2_FW) \
226 --use-pspsecureos \
227 --load-s0i3 \
Martin Roth1a3de8e2022-10-06 15:57:21 -0600228 $(OPT_TOKEN_UNLOCK) \
229 $(OPT_WHITELIST_FILE) \
230 $(OPT_PSP_SHAREDMEM_BASE) \
231 $(OPT_PSP_SHAREDMEM_SIZE) \
232 $(OPT_EFS_SPI_READ_MODE) \
233 $(OPT_EFS_SPI_SPEED) \
234 $(OPT_EFS_SPI_MICRON_FLAG) \
235 --config $(CONFIG_AMDFW_CONFIG_FILE) \
Martin Roth1a3de8e2022-10-06 15:57:21 -0600236 --flashsize $(CONFIG_ROM_SIZE) \
Zheng Baoa4284b02023-02-01 13:16:52 +0800237 $(OPT_RECOVERY_AB_SINGLE_COPY) \
238 $(OPT_AMDFW_BODY_LOCATION)
Martin Roth1a3de8e2022-10-06 15:57:21 -0600239
240$(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
241 $(PSP_VERSTAGE_FILE) \
242 $(PSP_VERSTAGE_SIG_FILE) \
243 $$(PSP_APCB_FILES) \
244 $(DEP_FILES) \
245 $(AMDFWTOOL) \
246 $(obj)/fmap_config.h \
247 $(objcbfs)/bootblock.elf # this target also creates the .map file
Martin Roth1a3de8e2022-10-06 15:57:21 -0600248 rm -f $@
249 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
250 $(AMDFWTOOL) \
251 $(AMDFW_COMMON_ARGS) \
252 $(OPT_APOB_NV_SIZE) \
253 $(OPT_APOB_NV_BASE) \
254 $(OPT_VERSTAGE_FILE) \
255 $(OPT_VERSTAGE_SIG_FILE) \
256 $(OPT_SPL_TABLE_FILE) \
Martin Roth20646cd2023-01-04 21:27:06 -0700257 --location $(shell printf "%#x" $(PHOENIX_FWM_POSITION)) \
Martin Roth1a3de8e2022-10-06 15:57:21 -0600258 --output $@
259
Zheng Baoa4284b02023-02-01 13:16:52 +0800260ifeq ($(CONFIG_AMDFW_SPLIT),y)
261$(obj)/amdfw.rom.body: $(obj)/amdfw.rom
262$(call add_intermediate, add_amdfwbody, $(obj)/amdfw.rom.body)
263 $(CBFSTOOL) $(obj)/coreboot.pre write -r AMDFWBODY -f $(obj)/amdfw.rom.body --fill-upward
264endif
265
Martin Roth1a3de8e2022-10-06 15:57:21 -0600266$(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
267 rm -f $@
268 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
269 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
270 --maxsize $(PSP_BIOSBIN_SIZE)
271
272$(obj)/amdfw_a.rom: $(obj)/amdfw.rom
273 rm -f $@
274 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
275 $(AMDFWTOOL) \
276 $(AMDFW_COMMON_ARGS) \
277 $(OPT_APOB_NV_SIZE) \
278 $(OPT_APOB_NV_BASE) \
279 $(OPT_SPL_RW_AB_TABLE_FILE) \
280 $(OPT_SIGNED_AMDFW_A_POSITION) \
281 $(OPT_SIGNED_AMDFW_A_FILE) \
Martin Roth20646cd2023-01-04 21:27:06 -0700282 --location $(shell printf "%#x" $(PHOENIX_FW_A_POSITION)) \
Martin Roth1a3de8e2022-10-06 15:57:21 -0600283 --anywhere \
284 --output $@
285
286$(obj)/amdfw_b.rom: $(obj)/amdfw.rom
287 rm -f $@
288 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
289 $(AMDFWTOOL) \
290 $(AMDFW_COMMON_ARGS) \
291 $(OPT_APOB_NV_SIZE) \
292 $(OPT_APOB_NV_BASE) \
293 $(OPT_SPL_RW_AB_TABLE_FILE) \
294 $(OPT_SIGNED_AMDFW_B_POSITION) \
295 $(OPT_SIGNED_AMDFW_B_FILE) \
Martin Roth20646cd2023-01-04 21:27:06 -0700296 --location $(shell printf "%#x" $(PHOENIX_FW_B_POSITION)) \
Martin Roth1a3de8e2022-10-06 15:57:21 -0600297 --anywhere \
298 --output $@
299
300
Martin Roth1a3de8e2022-10-06 15:57:21 -0600301ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
302cbfs-files-y += apu/amdfw_a
303apu/amdfw_a-file := $(obj)/amdfw_a.rom
304apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
305apu/amdfw_a-type := raw
306
307cbfs-files-y += apu/amdfw_b
308apu/amdfw_b-file := $(obj)/amdfw_b.rom
309apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
310apu/amdfw_b-type := raw
311
312ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
313build_complete:: $(obj)/amdfw_a.rom $(obj)/amdfw_b.rom
314 @printf " Adding Signed ROM and HASH\n"
315 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.signed
316 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.signed
317 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.signed.hash \
318 -n apu/amdfw_a_hash -t raw
319 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.signed.hash \
320 -n apu/amdfw_b_hash -t raw
321endif # CONFIG_SEPARATE_SIGNED_PSPFW
322endif
323
Martin Roth20646cd2023-01-04 21:27:06 -0700324endif # ($(CONFIG_SOC_AMD_PHOENIX),y)