blob: a94e19693f636cb0261bbb666b5490b83670ee75 [file] [log] [blame]
Felix Held3c44c622022-01-10 20:57:29 +01001# SPDX-License-Identifier: BSD-3-Clause
2
3# TODO: Check if this is still correct
4
5ifeq ($(CONFIG_SOC_AMD_SABRINA),y)
6
7subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage
8
9# Beware that all-y also adds the compilation unit to verstage on PSP
10all-y += config.c
11all-y += aoac.c
12
13bootblock-y += bootblock.c
14bootblock-y += early_fch.c
Raul E Rangeld0b059f2022-03-24 17:04:11 -060015bootblock-y += espi_util.c
Felix Held3c44c622022-01-10 20:57:29 +010016bootblock-y += gpio.c
17bootblock-y += i2c.c
18bootblock-y += reset.c
19bootblock-y += uart.c
20
21verstage-y += i2c.c
22verstage_x86-y += gpio.c
23verstage_x86-y += reset.c
24verstage_x86-y += uart.c
25
26romstage-y += fsp_m_params.c
27romstage-y += gpio.c
28romstage-y += i2c.c
29romstage-y += reset.c
30romstage-y += romstage.c
31romstage-y += uart.c
32
33ramstage-y += acpi.c
34ramstage-y += agesa_acpi.c
35ramstage-y += chip.c
Felix Held3c44c622022-01-10 20:57:29 +010036ramstage-y += cpu.c
37ramstage-y += data_fabric.c
38ramstage-y += fch.c
39ramstage-y += fsp_s_params.c
40ramstage-y += gpio.c
Felix Held3c44c622022-01-10 20:57:29 +010041ramstage-y += i2c.c
42ramstage-y += mca.c
43ramstage-y += preload.c
44ramstage-y += reset.c
45ramstage-y += root_complex.c
46ramstage-y += uart.c
47ramstage-y += xhci.c
48
49smm-y += gpio.c
50smm-y += smihandler.c
51smm-y += smu.c
52smm-$(CONFIG_DEBUG_SMI) += uart.c
53
54CPPFLAGS_common += -I$(src)/soc/amd/sabrina/include
55CPPFLAGS_common += -I$(src)/soc/amd/sabrina/acpi
56CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/sabrina
57
58MAINBOARD_BLOBS_DIR:=$(top)/3rdparty/blobs/mainboard/$(MAINBOARDDIR)
59
60# ROMSIG Normally At ROMBASE + 0x20000
61# Overridden by CONFIG_AMD_FWM_POSITION_INDEX
62# +-----------+---------------+----------------+------------+
63# |0x55AA55AA | | | |
64# +-----------+---------------+----------------+------------+
65# | | PSPDIR ADDR | BIOSDIR ADDR |
66# +-----------+---------------+----------------+
67
68$(if $(CONFIG_AMD_FWM_POSITION_INDEX), ,\
69 $(error Invalid AMD firmware position index. Check if the board sets a valid ROM size))
70
71SABRINA_FWM_POSITION=$(call int-add, \
72 $(call int-subtract, 0xffffffff \
73 $(call int-shift-left, \
74 0x80000 $(CONFIG_AMD_FWM_POSITION_INDEX))) 0x20000 1)
75
Robert Ziebab26d0052022-01-24 16:37:47 -070076# 0x40 accounts for the cbfs_file struct + filename + metadata structs, aligned to 64 bytes
77# Building the cbfs image will fail if the offset isn't large enough
78AMD_FW_AB_POSITION := 0x40
79
Felix Held3c44c622022-01-10 20:57:29 +010080SABRINA_FW_A_POSITION=$(call int-add, \
81 $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_A_START" {print $$3}' $(obj)/fmap_config.h) \
Robert Ziebab26d0052022-01-24 16:37:47 -070082 $(AMD_FW_AB_POSITION))
Felix Held3c44c622022-01-10 20:57:29 +010083
84SABRINA_FW_B_POSITION=$(call int-add, \
85 $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_B_START" {print $$3}' $(obj)/fmap_config.h) \
Robert Ziebab26d0052022-01-24 16:37:47 -070086 $(AMD_FW_AB_POSITION))
Felix Held3c44c622022-01-10 20:57:29 +010087#
88# PSP Directory Table items
89#
90# Certain ordering requirements apply, however these are ensured by amdfwtool.
91# For more information see "AMD Platform Security Processor BIOS Architecture
92# Design Guide for AMD Family 17h Processors" (PID #55758, NDA only).
93#
94
95FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}')
96
97ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y)
98PSP_SOFTFUSE_BITS += 7
99endif
100
Felix Held3c44c622022-01-10 20:57:29 +0100101ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
102# Enable secure debug unlock
103PSP_SOFTFUSE_BITS += 0
104OPT_TOKEN_UNLOCK="--token-unlock"
105endif
106
107ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y)
108OPT_PSP_LOAD_MP2_FW="--load-mp2-fw"
109else
110# Disable MP2 firmware loading
111PSP_SOFTFUSE_BITS += 29
112endif
113
Felix Held3c44c622022-01-10 20:57:29 +0100114# Use additional Soft Fuse bits specified in Kconfig
115PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS))
116
117# type = 0x3a
118ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
119PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
120endif
121
Karthikeyan Ramasubramanian8ee94292022-04-01 17:21:14 -0600122# type = 0x55
123ifeq ($(CONFIG_HAVE_SPL_FILE),y)
124SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
125endif
126
Felix Held3c44c622022-01-10 20:57:29 +0100127#
128# BIOS Directory Table items - proper ordering is managed by amdfwtool
129#
130
131# type = 0x60
132PSP_APCB_FILES=$(APCB_SOURCES) $(APCB_SOURCES_RECOVERY)
133
134# type = 0x61
135PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS)
136
137# type = 0x62
138PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img
139PSP_ELF_FILE=$(objcbfs)/bootblock.elf
140PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -l $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}')
141PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -l $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}')
142
143# type = 0x63 - construct APOB NV base/size from flash map
144# The flashmap section used for this is expected to be named RW_MRC_CACHE
145APOB_NV_SIZE=$(shell awk '$$2 == "FMAP_SECTION_RW_MRC_CACHE_SIZE" {print $$3}' $(obj)/fmap_config.h)
146APOB_NV_BASE=$(shell awk '$$2 == "FMAP_SECTION_RW_MRC_CACHE_START" {print $$3}' $(obj)/fmap_config.h)
147
148ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
149# type = 0x6B - PSP Shared memory location
150ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0)
151PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE)
152PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map)
153endif
154
155# type = 0x52 - PSP Bootloader Userspace Application (verstage)
156PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE))
157PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN))
158endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK
159
160# Helper function to return a value with given bit set
161# Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions.
162set-bit=$(call int-shift-left, 1 $(call _toint,$1))
163PSP_SOFTFUSE=$(shell A=$(call int-add, \
164 $(foreach bit,$(PSP_SOFTFUSE_BITS),$(call set-bit,$(bit)))); printf "0x%x" $$A)
165
166#
167# Build the arguments to amdfwtool (order is unimportant). Missing file names
168# result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
169#
170
171add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
172
173OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
174OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
175
176OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
177 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
178 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
179
180OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
181OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
182OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
183OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
184
185OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
186OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
187OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
188OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base)
189OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
190OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
191OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
192
193OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
194
195OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
Karthikeyan Ramasubramanian8ee94292022-04-01 17:21:14 -0600196OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
Felix Held3c44c622022-01-10 20:57:29 +0100197
Karthikeyan Ramasubramanian176b5632022-04-08 17:40:50 -0600198# If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant
199OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy)
200
Felix Held3c44c622022-01-10 20:57:29 +0100201# Add all the files listed in the config file
202POUND_SIGN=$(call strip_quotes, "\#")
203DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /*/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))
204
205AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
206 $(OPT_APOB_ADDR) \
207 $(OPT_PSP_BIOSBIN_FILE) \
208 $(OPT_PSP_BIOSBIN_DEST) \
209 $(OPT_PSP_BIOSBIN_SIZE) \
210 $(OPT_PSP_SOFTFUSE) \
211 $(OPT_PSP_LOAD_MP2_FW) \
212 --use-pspsecureos \
213 --load-s0i3 \
214 --combo-capable \
215 $(OPT_TOKEN_UNLOCK) \
216 $(OPT_WHITELIST_FILE) \
Karthikeyan Ramasubramanian8ee94292022-04-01 17:21:14 -0600217 $(OPT_SPL_TABLE_FILE) \
Felix Held3c44c622022-01-10 20:57:29 +0100218 $(OPT_PSP_SHAREDMEM_BASE) \
219 $(OPT_PSP_SHAREDMEM_SIZE) \
220 $(OPT_EFS_SPI_READ_MODE) \
221 $(OPT_EFS_SPI_SPEED) \
222 $(OPT_EFS_SPI_MICRON_FLAG) \
223 --config $(CONFIG_AMDFW_CONFIG_FILE) \
Felix Helde3ee9172022-03-30 01:01:46 +0200224 --soc-name "Sabrina" \
Karthikeyan Ramasubramanian176b5632022-04-08 17:40:50 -0600225 --flashsize $(CONFIG_ROM_SIZE) \
226 $(OPT_RECOVERY_AB_SINGLE_COPY)
Felix Held3c44c622022-01-10 20:57:29 +0100227
228$(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
229 $(PSP_VERSTAGE_FILE) \
230 $(PSP_VERSTAGE_SIG_FILE) \
231 $$(PSP_APCB_FILES) \
232 $(DEP_FILES) \
233 $(AMDFWTOOL) \
234 $(obj)/fmap_config.h \
235 $(objcbfs)/bootblock.elf # this target also creates the .map file
236 $(if $(PSP_APCB_FILES), ,$(error APCB_SOURCES is not set))
237 rm -f $@
238 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
239 $(AMDFWTOOL) \
240 $(AMDFW_COMMON_ARGS) \
241 $(OPT_APOB_NV_SIZE) \
242 $(OPT_APOB_NV_BASE) \
243 $(OPT_VERSTAGE_FILE) \
244 $(OPT_VERSTAGE_SIG_FILE) \
245 --location $(shell printf "%#x" $(SABRINA_FWM_POSITION)) \
Felix Held3c44c622022-01-10 20:57:29 +0100246 --output $@
247
248$(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
249 rm -f $@
250 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
251 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
252 --maxsize $(PSP_BIOSBIN_SIZE)
253
254$(obj)/amdfw_a.rom: $(obj)/amdfw.rom
255 rm -f $@
256 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
257 $(AMDFWTOOL) \
258 $(AMDFW_COMMON_ARGS) \
259 $(OPT_APOB_NV_SIZE) \
260 $(OPT_APOB_NV_BASE) \
261 --location $(shell printf "%#x" $(SABRINA_FW_A_POSITION)) \
262 --anywhere \
Felix Held3c44c622022-01-10 20:57:29 +0100263 --output $@
264
265$(obj)/amdfw_b.rom: $(obj)/amdfw.rom
266 rm -f $@
267 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
268 $(AMDFWTOOL) \
269 $(AMDFW_COMMON_ARGS) \
270 $(OPT_APOB_NV_SIZE) \
271 $(OPT_APOB_NV_BASE) \
272 --location $(shell printf "%#x" $(SABRINA_FW_B_POSITION)) \
273 --anywhere \
Felix Held3c44c622022-01-10 20:57:29 +0100274 --output $@
275
276
277cbfs-files-y += apu/amdfw
278apu/amdfw-file := $(obj)/amdfw.rom
279apu/amdfw-position := $(SABRINA_FWM_POSITION)
280apu/amdfw-type := raw
281
282ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
283cbfs-files-y += apu/amdfw_a
284apu/amdfw_a-file := $(obj)/amdfw_a.rom
Robert Ziebab26d0052022-01-24 16:37:47 -0700285apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
Felix Held3c44c622022-01-10 20:57:29 +0100286apu/amdfw_a-type := raw
287
288cbfs-files-y += apu/amdfw_b
289apu/amdfw_b-file := $(obj)/amdfw_b.rom
Robert Ziebab26d0052022-01-24 16:37:47 -0700290apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
Felix Held3c44c622022-01-10 20:57:29 +0100291apu/amdfw_b-type := raw
292endif
293
Fred Reitbergerceccfa22022-06-09 11:08:07 -0400294amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*UcodePatch_*.bin)
Felix Held3c44c622022-01-10 20:57:29 +0100295
296endif # ($(CONFIG_SOC_AMD_SABRINA),y)