blob: 66fbd2636c1732ea9bd59c0b4690e1f110c8a51b [file] [log] [blame]
Martin Roth9231f0b2022-10-28 22:39:23 -06001## SPDX-License-Identifier: GPL-2.0-only
Felix Heldea340222020-11-14 01:58:47 +01002ifeq ($(CONFIG_SOC_AMD_COMMON),y)
3subdirs-y += block
Felix Helde04a18f2020-12-10 16:49:28 +01004subdirs-y += fsp
Felix Heldc9737c5c2021-09-23 17:16:32 +02005subdirs-y += pi
Felix Heldea340222020-11-14 01:58:47 +01006subdirs-y += vboot
Zheng Baoe47bff82022-03-08 14:59:27 +08007
8ifneq ($(CONFIG_AMDFW_CONFIG_FILE), )
9FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}')
10
Martin Rothd729df02023-03-08 15:33:13 -070011# Add all the files listed in the config file to the dependency list
Zheng Baoe47bff82022-03-08 14:59:27 +080012POUND_SIGN=$(call strip_quotes, "\#")
Martin Rothd729df02023-03-08 15:33:13 -070013REMOVE_MP2 =
14# If the MP2 file is not being loaded, remove it as a dependency
15ifneq ($(CONFIG_PSP_LOAD_MP2_FW),y)
16REMOVE_MP2 = /MP2/d
17endif
18
19# Steps below to generate the dependency list
20# 1a: Delete any line that starts with #, FIRMWARE_LOCATION, or SOC_NAME
Martin Roth44217212023-03-10 15:10:08 -070021# 1b: Filter out lines containing MP2 or not, decided above.
22# 1c: Use awk to return only field 2, the filename
Martin Rothd729df02023-03-08 15:33:13 -070023# 2: Gather filenames with no path to add the firmware location later
24# 3: Gather filenames with a path
25# 4a: Add the firmware location to any files without a path to the dependencies
26# 4b: add the lines containing a path to the dependencies
27AMDFW_CFG_FILES = $(shell sed "/^$(POUND_SIGN)\|^FIRMWARE_LOCATION\|^SOC_NAME/d; \
Martin Rothd729df02023-03-08 15:33:13 -070028 $(REMOVE_MP2)" $(CONFIG_AMDFW_CONFIG_FILE) | \
29 awk '{print $$2}')
30AMDFW_CFG_IN_FW_LOC = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep -v "/")
31AMDFW_CFG_WITH_PATH = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep "/")
32DEP_FILES = $(patsubst %,$(FIRMWARE_LOCATION)/%, $(AMDFW_CFG_IN_FW_LOC)) \
33 $(AMDFW_CFG_WITH_PATH)
Zheng Baoe47bff82022-03-08 14:59:27 +080034
35amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*UcodePatch_*.bin)
36
Karthikeyan Ramasubramanian8d66fb12022-09-20 23:53:40 -060037ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y)
38$(objcbfs)/bootblock.bin: $(obj)/amdfw.rom
39 cp $< $@
40
41add_bootblock = \
42 $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \
43 -b $(call int-add, \
44 $(call int-subtract, 0xffffffff \
45 $(call int-shift-left, \
46 0x80000 $(CONFIG_AMD_FWM_POSITION_INDEX))) 0x20000 1)
47endif # ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y)
48
Karthikeyan Ramasubramanian78358612022-08-16 17:30:06 -060049ifeq ($(CONFIG_VBOOT_GSCVD),y)
Fred Reitberger552d2872023-02-10 12:31:22 -050050build_complete:: $(obj)/ro-amdfw-list
Karthikeyan Ramasubramaniand1130b72022-08-16 17:42:57 -060051
Fred Reitberger552d2872023-02-10 12:31:22 -050052$(obj)/ro-amdfw-list: $(AMDFWREAD)
53 $(AMDFWREAD) --ro-list $(obj)/coreboot.rom > $@
54
55amdfwread-offset-size-cmd = grep '$(1)' $(obj)/ro-amdfw-list | \
56 sed 's/^.* 0x0*\(.*\) 0x0*\(.*\)$$/\1:\2/'
Karthikeyan Ramasubramaniand1130b72022-08-16 17:42:57 -060057
58amdfwread-range-cmd = $(shell ( \
59 range=$$($(call amdfwread-offset-size-cmd,$(1))) ;\
60 if [ -n "$$range" ]; then \
61 printf $$range ;\
62 else \
63 printf "error" ;\
64 fi ;\
65))
Karthikeyan Ramasubramanian78358612022-08-16 17:30:06 -060066endif # ifeq ($(CONFIG_VBOOT_GSCVD),y)
67
Fred Reitbergere814b262022-12-01 08:49:44 -050068endif # ifneq ($(CONFIG_AMDFW_CONFIG_FILE), )
Fred Reitberger81908402022-11-07 13:21:48 -050069
70MAINBOARD_BLOBS_DIR := $(call strip_quotes, $(CONFIG_APCB_BLOBS_DIR))
Fred Reitbergere814b262022-12-01 08:49:44 -050071
Fred Reitbergera63fac32023-02-13 11:06:15 -050072PHONY+=warn_no_apcb
73warn_no_apcb:
74 printf "\n\t** WARNING **\n"
75 printf "coreboot has been built without an APCB.\n"
76 printf "This image will not boot.\n\n"
77
Fred Reitberger38954e22023-02-13 15:22:02 -050078PHONY+=die_no_apcb
79die_no_apcb: warn_no_apcb
80 $(error This board requires the APCB to build correctly)
81
Fred Reitbergere814b262022-12-01 08:49:44 -050082endif # ifeq ($(CONFIG_SOC_AMD_COMMON),y)