blob: 626260f93ee0426b85be9698b0894b766fabdf51 [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
Martin Roth8fc68812023-08-18 16:28:29 -06008CPPFLAGS_common += -I$(src)/soc/amd/common/vboot/include
9
Martin Roth0acf59d2023-03-08 15:18:24 -070010ifneq ($(V),)
11OPT_DEBUG_AMDFWTOOL = --debug
12endif
13
Zheng Baoe47bff82022-03-08 14:59:27 +080014ifneq ($(CONFIG_AMDFW_CONFIG_FILE), )
15FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}')
16
Martin Rothd729df02023-03-08 15:33:13 -070017# Add all the files listed in the config file to the dependency list
Zheng Baoe47bff82022-03-08 14:59:27 +080018POUND_SIGN=$(call strip_quotes, "\#")
Martin Rothd729df02023-03-08 15:33:13 -070019REMOVE_MP2 =
20# If the MP2 file is not being loaded, remove it as a dependency
21ifneq ($(CONFIG_PSP_LOAD_MP2_FW),y)
22REMOVE_MP2 = /MP2/d
23endif
24
25# Steps below to generate the dependency list
Zheng Bao730c3ba2023-08-25 19:20:37 +080026# 1a: Delete any line that starts with #, FIRMWARE_LOCATION, SOC_NAME, or AMD_FUSE_CHAIN
Martin Roth44217212023-03-10 15:10:08 -070027# 1b: Filter out lines containing MP2 or not, decided above.
28# 1c: Use awk to return only field 2, the filename
Martin Rothd729df02023-03-08 15:33:13 -070029# 2: Gather filenames with no path to add the firmware location later
30# 3: Gather filenames with a path
31# 4a: Add the firmware location to any files without a path to the dependencies
32# 4b: add the lines containing a path to the dependencies
Zheng Bao730c3ba2023-08-25 19:20:37 +080033AMDFW_CFG_FILES = $(shell sed "/^$(POUND_SIGN)\|^FIRMWARE_LOCATION\|^AMD_FUSE_CHAIN\|^SOC_NAME/d; \
Martin Rothd729df02023-03-08 15:33:13 -070034 $(REMOVE_MP2)" $(CONFIG_AMDFW_CONFIG_FILE) | \
35 awk '{print $$2}')
36AMDFW_CFG_IN_FW_LOC = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep -v "/")
37AMDFW_CFG_WITH_PATH = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep "/")
38DEP_FILES = $(patsubst %,$(FIRMWARE_LOCATION)/%, $(AMDFW_CFG_IN_FW_LOC)) \
39 $(AMDFW_CFG_WITH_PATH)
Zheng Baoe47bff82022-03-08 14:59:27 +080040
Arthur Heymans5ee1d232023-07-14 23:16:22 +020041amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*U?odePatch*.bin)
Zheng Baoe47bff82022-03-08 14:59:27 +080042
Karthikeyan Ramasubramanian8d66fb12022-09-20 23:53:40 -060043ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y)
Zheng Bao69cef8e2023-02-11 16:27:16 +080044$(objcbfs)/bootblock.bin: $(obj)/amdfw.rom $(obj)/fmap_config.h
Karthikeyan Ramasubramanian8d66fb12022-09-20 23:53:40 -060045 cp $< $@
46
Zheng Bao69cef8e2023-02-11 16:27:16 +080047amdfw_region_start=$(subst $(spc),,FMAP_SECTION_$(call regions-for-file,apu/amdfw)_START)
48amdfw_offset=$(call int-subtract, \
49 $(CONFIG_AMD_FWM_POSITION) \
50 $(call int-subtract, \
51 $(call get_fmap_value,$(amdfw_region_start)) \
52 $(call get_fmap_value,FMAP_SECTION_FLASH_START)))
53
Karthikeyan Ramasubramanian8d66fb12022-09-20 23:53:40 -060054add_bootblock = \
55 $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \
Arthur Heymans926d55c2023-07-13 12:50:45 +020056 -b $(amdfw_offset) -r $(call regions-for-file,apu/amdfw) \
57 $(CBFSTOOL_ADD_CMD_OPTIONS)
Zheng Bao6bc06982023-02-14 13:26:31 +080058
Karthikeyan Ramasubramanian8d66fb12022-09-20 23:53:40 -060059endif # ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y)
60
Karthikeyan Ramasubramanian78358612022-08-16 17:30:06 -060061ifeq ($(CONFIG_VBOOT_GSCVD),y)
Fred Reitberger552d2872023-02-10 12:31:22 -050062build_complete:: $(obj)/ro-amdfw-list
Karthikeyan Ramasubramaniand1130b72022-08-16 17:42:57 -060063
Fred Reitberger552d2872023-02-10 12:31:22 -050064$(obj)/ro-amdfw-list: $(AMDFWREAD)
65 $(AMDFWREAD) --ro-list $(obj)/coreboot.rom > $@
66
67amdfwread-offset-size-cmd = grep '$(1)' $(obj)/ro-amdfw-list | \
68 sed 's/^.* 0x0*\(.*\) 0x0*\(.*\)$$/\1:\2/'
Karthikeyan Ramasubramaniand1130b72022-08-16 17:42:57 -060069
70amdfwread-range-cmd = $(shell ( \
71 range=$$($(call amdfwread-offset-size-cmd,$(1))) ;\
72 if [ -n "$$range" ]; then \
73 printf $$range ;\
74 else \
75 printf "error" ;\
76 fi ;\
77))
Karthikeyan Ramasubramanian78358612022-08-16 17:30:06 -060078endif # ifeq ($(CONFIG_VBOOT_GSCVD),y)
79
Fred Reitbergere814b262022-12-01 08:49:44 -050080endif # ifneq ($(CONFIG_AMDFW_CONFIG_FILE), )
Fred Reitberger81908402022-11-07 13:21:48 -050081
82MAINBOARD_BLOBS_DIR := $(call strip_quotes, $(CONFIG_APCB_BLOBS_DIR))
Fred Reitbergere814b262022-12-01 08:49:44 -050083
Fred Reitbergera63fac32023-02-13 11:06:15 -050084PHONY+=warn_no_apcb
85warn_no_apcb:
86 printf "\n\t** WARNING **\n"
87 printf "coreboot has been built without an APCB.\n"
88 printf "This image will not boot.\n\n"
89
Fred Reitberger38954e22023-02-13 15:22:02 -050090PHONY+=die_no_apcb
91die_no_apcb: warn_no_apcb
92 $(error This board requires the APCB to build correctly)
93
Fred Reitbergere814b262022-12-01 08:49:44 -050094endif # ifeq ($(CONFIG_SOC_AMD_COMMON),y)