blob: ade2ee887a79d442d97ef0acb7e8cf2c8b17944e [file] [log] [blame]
Martin Rothf95a11e2022-10-21 16:43:08 -06001# SPDX-License-Identifier: BSD-3-Clause
2
3# TODO: Move as much as possible to common
4# TODO: Update for Glinda
5
6ifeq ($(CONFIG_SOC_AMD_GLINDA),y)
7
8subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage
9
10# Beware that all-y also adds the compilation unit to verstage on PSP
11all-y += config.c
12all-y += aoac.c
13
14bootblock-y += early_fch.c
15bootblock-y += espi_util.c
16bootblock-y += gpio.c
17bootblock-y += i2c.c
Martin Rothf95a11e2022-10-21 16:43:08 -060018bootblock-y += uart.c
19
20verstage-y += i2c.c
21verstage-y += espi_util.c
22verstage_x86-y += gpio.c
Martin Rothf95a11e2022-10-21 16:43:08 -060023verstage_x86-y += uart.c
24
25romstage-y += fsp_m_params.c
26romstage-y += gpio.c
27romstage-y += i2c.c
Martin Rothf95a11e2022-10-21 16:43:08 -060028romstage-y += romstage.c
29romstage-y += uart.c
30
31ramstage-y += acpi.c
32ramstage-y += agesa_acpi.c
33ramstage-y += chip.c
34ramstage-y += cpu.c
Martin Rothf95a11e2022-10-21 16:43:08 -060035ramstage-y += fch.c
36ramstage-y += fsp_s_params.c
37ramstage-y += gpio.c
38ramstage-y += i2c.c
39ramstage-y += mca.c
Martin Rothf95a11e2022-10-21 16:43:08 -060040ramstage-y += root_complex.c
41ramstage-y += uart.c
42ramstage-y += xhci.c
43
44smm-y += gpio.c
45smm-y += smihandler.c
Martin Rothf95a11e2022-10-21 16:43:08 -060046smm-$(CONFIG_DEBUG_SMI) += uart.c
47
48CPPFLAGS_common += -I$(src)/soc/amd/glinda/include
49CPPFLAGS_common += -I$(src)/soc/amd/glinda/acpi
50CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/glinda
51CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/common
52
Martin Rothf95a11e2022-10-21 16:43:08 -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
65GLINDA_FWM_POSITION=0xff020000
Martin Rothf95a11e2022-10-21 16:43:08 -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
71GLINDA_FW_A_POSITION=$(call int-add, \
72 $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_A_START" {print $$3}' $(obj)/fmap_config.h) \
73 $(AMD_FW_AB_POSITION))
74
75GLINDA_FW_B_POSITION=$(call int-add, \
76 $(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 Rothf95a11e2022-10-21 16:43:08 -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
142ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
143# type = 0x6B - PSP Shared memory location
144ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0)
145PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE)
146PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map)
147endif
148
149# type = 0x52 - PSP Bootloader Userspace Application (verstage)
150PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE))
151PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN))
152endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK
153
154ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
155SIGNED_AMDFW_A_POSITION=$(call int-subtract, \
156 $(shell awk '$$2 == "FMAP_SECTION_SIGNED_AMDFW_A_START" {print $$3}' $(obj)/fmap_config.h) \
157 $(shell awk '$$2 == "FMAP_SECTION_FLASH_START" {print $$3}' $(obj)/fmap_config.h))
158SIGNED_AMDFW_B_POSITION=$(call int-subtract, \
159 $(shell awk '$$2 == "FMAP_SECTION_SIGNED_AMDFW_B_START" {print $$3}' $(obj)/fmap_config.h) \
160 $(shell awk '$$2 == "FMAP_SECTION_FLASH_START" {print $$3}' $(obj)/fmap_config.h))
161SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.signed
162SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.signed
163endif # CONFIG_SEPARATE_SIGNED_PSPFW
164
165# Helper function to return a value with given bit set
166# Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions.
167set-bit=$(call int-shift-left, 1 $(call _toint,$1))
168PSP_SOFTFUSE=$(shell A=$(call int-add, \
169 $(foreach bit,$(PSP_SOFTFUSE_BITS),$(call set-bit,$(bit)))); printf "0x%x" $$A)
170
171#
172# Build the arguments to amdfwtool (order is unimportant). Missing file names
173# result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
174#
175
176add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
177
178OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
179OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
180
181OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
182 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
183 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
184
185OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
186OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
187OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
188OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
189
190OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
191OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
192OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
193OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base)
194OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
195OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
196OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
197
198OPT_SIGNED_AMDFW_A_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_A_POSITION), --signed-addr)
199OPT_SIGNED_AMDFW_A_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_A_FILE), --signed-output)
200OPT_SIGNED_AMDFW_B_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_B_POSITION), --signed-addr)
201OPT_SIGNED_AMDFW_B_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_B_FILE), --signed-output)
202
203OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
204
205OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
206OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
207OPT_SPL_RW_AB_TABLE_FILE=$(call add_opt_prefix, $(SPL_RW_AB_TABLE_FILE), --spl-table)
208
209# If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant
210OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy)
211
212AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
213 $(OPT_APOB_ADDR) \
214 $(OPT_PSP_BIOSBIN_FILE) \
215 $(OPT_PSP_BIOSBIN_DEST) \
216 $(OPT_PSP_BIOSBIN_SIZE) \
217 $(OPT_PSP_SOFTFUSE) \
218 $(OPT_PSP_LOAD_MP2_FW) \
219 --use-pspsecureos \
220 --load-s0i3 \
Martin Rothf95a11e2022-10-21 16:43:08 -0600221 $(OPT_TOKEN_UNLOCK) \
222 $(OPT_WHITELIST_FILE) \
223 $(OPT_PSP_SHAREDMEM_BASE) \
224 $(OPT_PSP_SHAREDMEM_SIZE) \
225 $(OPT_EFS_SPI_READ_MODE) \
226 $(OPT_EFS_SPI_SPEED) \
227 $(OPT_EFS_SPI_MICRON_FLAG) \
228 --config $(CONFIG_AMDFW_CONFIG_FILE) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600229 --flashsize $(CONFIG_ROM_SIZE) \
230 $(OPT_RECOVERY_AB_SINGLE_COPY)
231
232$(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
233 $(PSP_VERSTAGE_FILE) \
234 $(PSP_VERSTAGE_SIG_FILE) \
235 $$(PSP_APCB_FILES) \
236 $(DEP_FILES) \
237 $(AMDFWTOOL) \
238 $(obj)/fmap_config.h \
239 $(objcbfs)/bootblock.elf # this target also creates the .map file
240 $(if $(PSP_APCB_FILES), ,$(error APCB_SOURCES is not set))
241 rm -f $@
242 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
243 $(AMDFWTOOL) \
244 $(AMDFW_COMMON_ARGS) \
245 $(OPT_APOB_NV_SIZE) \
246 $(OPT_APOB_NV_BASE) \
247 $(OPT_VERSTAGE_FILE) \
248 $(OPT_VERSTAGE_SIG_FILE) \
249 $(OPT_SPL_TABLE_FILE) \
250 --location $(shell printf "%#x" $(GLINDA_FWM_POSITION)) \
251 --output $@
252
253$(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
254 rm -f $@
255 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
256 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
257 --maxsize $(PSP_BIOSBIN_SIZE)
258
259$(obj)/amdfw_a.rom: $(obj)/amdfw.rom
260 rm -f $@
261 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
262 $(AMDFWTOOL) \
263 $(AMDFW_COMMON_ARGS) \
264 $(OPT_APOB_NV_SIZE) \
265 $(OPT_APOB_NV_BASE) \
266 $(OPT_SPL_RW_AB_TABLE_FILE) \
267 $(OPT_SIGNED_AMDFW_A_POSITION) \
268 $(OPT_SIGNED_AMDFW_A_FILE) \
269 --location $(shell printf "%#x" $(GLINDA_FW_A_POSITION)) \
270 --anywhere \
271 --output $@
272
273$(obj)/amdfw_b.rom: $(obj)/amdfw.rom
274 rm -f $@
275 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
276 $(AMDFWTOOL) \
277 $(AMDFW_COMMON_ARGS) \
278 $(OPT_APOB_NV_SIZE) \
279 $(OPT_APOB_NV_BASE) \
280 $(OPT_SPL_RW_AB_TABLE_FILE) \
281 $(OPT_SIGNED_AMDFW_B_POSITION) \
282 $(OPT_SIGNED_AMDFW_B_FILE) \
283 --location $(shell printf "%#x" $(GLINDA_FW_B_POSITION)) \
284 --anywhere \
285 --output $@
286
287
Martin Rothf95a11e2022-10-21 16:43:08 -0600288ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
289cbfs-files-y += apu/amdfw_a
290apu/amdfw_a-file := $(obj)/amdfw_a.rom
291apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
292apu/amdfw_a-type := raw
293
294cbfs-files-y += apu/amdfw_b
295apu/amdfw_b-file := $(obj)/amdfw_b.rom
296apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
297apu/amdfw_b-type := raw
298
299ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
300build_complete:: $(obj)/amdfw_a.rom $(obj)/amdfw_b.rom
301 @printf " Adding Signed ROM and HASH\n"
302 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.signed
303 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.signed
304 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.signed.hash \
305 -n apu/amdfw_a_hash -t raw
306 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.signed.hash \
307 -n apu/amdfw_b_hash -t raw
308endif # CONFIG_SEPARATE_SIGNED_PSPFW
309endif
310
311endif # ($(CONFIG_SOC_AMD_GLINDA),y)