blob: 86fe0514c5db0693c3b564c902b2ab728bffc185 [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
21# 1b: Delete any line containing a *
22# 1c: Filter out lines containing MP2 or not, decided above.
23# 1d: Use awk to return only field 2, the filename
24# 2: Gather filenames with no path to add the firmware location later
25# 3: Gather filenames with a path
26# 4a: Add the firmware location to any files without a path to the dependencies
27# 4b: add the lines containing a path to the dependencies
28AMDFW_CFG_FILES = $(shell sed "/^$(POUND_SIGN)\|^FIRMWARE_LOCATION\|^SOC_NAME/d; \
29 /*/d; \
30 $(REMOVE_MP2)" $(CONFIG_AMDFW_CONFIG_FILE) | \
31 awk '{print $$2}')
32AMDFW_CFG_IN_FW_LOC = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep -v "/")
33AMDFW_CFG_WITH_PATH = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep "/")
34DEP_FILES = $(patsubst %,$(FIRMWARE_LOCATION)/%, $(AMDFW_CFG_IN_FW_LOC)) \
35 $(AMDFW_CFG_WITH_PATH)
Zheng Baoe47bff82022-03-08 14:59:27 +080036
37amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*UcodePatch_*.bin)
38
Karthikeyan Ramasubramanian8d66fb12022-09-20 23:53:40 -060039ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y)
40$(objcbfs)/bootblock.bin: $(obj)/amdfw.rom
41 cp $< $@
42
43add_bootblock = \
44 $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \
45 -b $(call int-add, \
46 $(call int-subtract, 0xffffffff \
47 $(call int-shift-left, \
48 0x80000 $(CONFIG_AMD_FWM_POSITION_INDEX))) 0x20000 1)
49endif # ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y)
50
Karthikeyan Ramasubramanian78358612022-08-16 17:30:06 -060051ifeq ($(CONFIG_VBOOT_GSCVD),y)
Fred Reitberger552d2872023-02-10 12:31:22 -050052build_complete:: $(obj)/ro-amdfw-list
Karthikeyan Ramasubramaniand1130b72022-08-16 17:42:57 -060053
Fred Reitberger552d2872023-02-10 12:31:22 -050054$(obj)/ro-amdfw-list: $(AMDFWREAD)
55 $(AMDFWREAD) --ro-list $(obj)/coreboot.rom > $@
56
57amdfwread-offset-size-cmd = grep '$(1)' $(obj)/ro-amdfw-list | \
58 sed 's/^.* 0x0*\(.*\) 0x0*\(.*\)$$/\1:\2/'
Karthikeyan Ramasubramaniand1130b72022-08-16 17:42:57 -060059
60amdfwread-range-cmd = $(shell ( \
61 range=$$($(call amdfwread-offset-size-cmd,$(1))) ;\
62 if [ -n "$$range" ]; then \
63 printf $$range ;\
64 else \
65 printf "error" ;\
66 fi ;\
67))
Karthikeyan Ramasubramanian78358612022-08-16 17:30:06 -060068endif # ifeq ($(CONFIG_VBOOT_GSCVD),y)
69
Fred Reitbergere814b262022-12-01 08:49:44 -050070endif # ifneq ($(CONFIG_AMDFW_CONFIG_FILE), )
Fred Reitberger81908402022-11-07 13:21:48 -050071
72MAINBOARD_BLOBS_DIR := $(call strip_quotes, $(CONFIG_APCB_BLOBS_DIR))
Fred Reitbergere814b262022-12-01 08:49:44 -050073
Fred Reitbergera63fac32023-02-13 11:06:15 -050074PHONY+=warn_no_apcb
75warn_no_apcb:
76 printf "\n\t** WARNING **\n"
77 printf "coreboot has been built without an APCB.\n"
78 printf "This image will not boot.\n\n"
79
Fred Reitberger38954e22023-02-13 15:22:02 -050080PHONY+=die_no_apcb
81die_no_apcb: warn_no_apcb
82 $(error This board requires the APCB to build correctly)
83
Fred Reitbergere814b262022-12-01 08:49:44 -050084endif # ifeq ($(CONFIG_SOC_AMD_COMMON),y)