Martin Roth | 9231f0b | 2022-10-28 22:39:23 -0600 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Felix Held | ea34022 | 2020-11-14 01:58:47 +0100 | [diff] [blame] | 2 | ifeq ($(CONFIG_SOC_AMD_COMMON),y) |
| 3 | subdirs-y += block |
Felix Held | e04a18f | 2020-12-10 16:49:28 +0100 | [diff] [blame] | 4 | subdirs-y += fsp |
Felix Held | c9737c5c | 2021-09-23 17:16:32 +0200 | [diff] [blame] | 5 | subdirs-y += pi |
Felix Held | ea34022 | 2020-11-14 01:58:47 +0100 | [diff] [blame] | 6 | subdirs-y += vboot |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 7 | |
Martin Roth | 8fc6881 | 2023-08-18 16:28:29 -0600 | [diff] [blame] | 8 | CPPFLAGS_common += -I$(src)/soc/amd/common/vboot/include |
| 9 | |
Martin Roth | 0acf59d | 2023-03-08 15:18:24 -0700 | [diff] [blame] | 10 | ifneq ($(V),) |
| 11 | OPT_DEBUG_AMDFWTOOL = --debug |
| 12 | endif |
| 13 | |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 14 | ifneq ($(CONFIG_AMDFW_CONFIG_FILE), ) |
| 15 | FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}') |
| 16 | |
Martin Roth | d729df0 | 2023-03-08 15:33:13 -0700 | [diff] [blame] | 17 | # Add all the files listed in the config file to the dependency list |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 18 | POUND_SIGN=$(call strip_quotes, "\#") |
Martin Roth | d729df0 | 2023-03-08 15:33:13 -0700 | [diff] [blame] | 19 | REMOVE_MP2 = |
| 20 | # If the MP2 file is not being loaded, remove it as a dependency |
| 21 | ifneq ($(CONFIG_PSP_LOAD_MP2_FW),y) |
| 22 | REMOVE_MP2 = /MP2/d |
| 23 | endif |
| 24 | |
| 25 | # Steps below to generate the dependency list |
Zheng Bao | 730c3ba | 2023-08-25 19:20:37 +0800 | [diff] [blame] | 26 | # 1a: Delete any line that starts with #, FIRMWARE_LOCATION, SOC_NAME, or AMD_FUSE_CHAIN |
Martin Roth | 4421721 | 2023-03-10 15:10:08 -0700 | [diff] [blame] | 27 | # 1b: Filter out lines containing MP2 or not, decided above. |
| 28 | # 1c: Use awk to return only field 2, the filename |
Martin Roth | d729df0 | 2023-03-08 15:33:13 -0700 | [diff] [blame] | 29 | # 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 Bao | 730c3ba | 2023-08-25 19:20:37 +0800 | [diff] [blame] | 33 | AMDFW_CFG_FILES = $(shell sed "/^$(POUND_SIGN)\|^FIRMWARE_LOCATION\|^AMD_FUSE_CHAIN\|^SOC_NAME/d; \ |
Martin Roth | d729df0 | 2023-03-08 15:33:13 -0700 | [diff] [blame] | 34 | $(REMOVE_MP2)" $(CONFIG_AMDFW_CONFIG_FILE) | \ |
| 35 | awk '{print $$2}') |
| 36 | AMDFW_CFG_IN_FW_LOC = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep -v "/") |
| 37 | AMDFW_CFG_WITH_PATH = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep "/") |
| 38 | DEP_FILES = $(patsubst %,$(FIRMWARE_LOCATION)/%, $(AMDFW_CFG_IN_FW_LOC)) \ |
| 39 | $(AMDFW_CFG_WITH_PATH) |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 40 | |
Arthur Heymans | 5ee1d23 | 2023-07-14 23:16:22 +0200 | [diff] [blame] | 41 | amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*U?odePatch*.bin) |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 42 | |
Karthikeyan Ramasubramanian | 8d66fb1 | 2022-09-20 23:53:40 -0600 | [diff] [blame] | 43 | ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y) |
Zheng Bao | 69cef8e | 2023-02-11 16:27:16 +0800 | [diff] [blame] | 44 | $(objcbfs)/bootblock.bin: $(obj)/amdfw.rom $(obj)/fmap_config.h |
Karthikeyan Ramasubramanian | 8d66fb1 | 2022-09-20 23:53:40 -0600 | [diff] [blame] | 45 | cp $< $@ |
| 46 | |
Zheng Bao | 69cef8e | 2023-02-11 16:27:16 +0800 | [diff] [blame] | 47 | amdfw_region_start=$(subst $(spc),,FMAP_SECTION_$(call regions-for-file,apu/amdfw)_START) |
| 48 | amdfw_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 Ramasubramanian | 8d66fb1 | 2022-09-20 23:53:40 -0600 | [diff] [blame] | 54 | add_bootblock = \ |
| 55 | $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \ |
Arthur Heymans | 926d55c | 2023-07-13 12:50:45 +0200 | [diff] [blame] | 56 | -b $(amdfw_offset) -r $(call regions-for-file,apu/amdfw) \ |
| 57 | $(CBFSTOOL_ADD_CMD_OPTIONS) |
Zheng Bao | 6bc0698 | 2023-02-14 13:26:31 +0800 | [diff] [blame] | 58 | |
Karthikeyan Ramasubramanian | 8d66fb1 | 2022-09-20 23:53:40 -0600 | [diff] [blame] | 59 | endif # ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y) |
| 60 | |
Karthikeyan Ramasubramanian | 7835861 | 2022-08-16 17:30:06 -0600 | [diff] [blame] | 61 | ifeq ($(CONFIG_VBOOT_GSCVD),y) |
Fred Reitberger | 552d287 | 2023-02-10 12:31:22 -0500 | [diff] [blame] | 62 | build_complete:: $(obj)/ro-amdfw-list |
Karthikeyan Ramasubramanian | d1130b7 | 2022-08-16 17:42:57 -0600 | [diff] [blame] | 63 | |
Fred Reitberger | 552d287 | 2023-02-10 12:31:22 -0500 | [diff] [blame] | 64 | $(obj)/ro-amdfw-list: $(AMDFWREAD) |
| 65 | $(AMDFWREAD) --ro-list $(obj)/coreboot.rom > $@ |
| 66 | |
| 67 | amdfwread-offset-size-cmd = grep '$(1)' $(obj)/ro-amdfw-list | \ |
| 68 | sed 's/^.* 0x0*\(.*\) 0x0*\(.*\)$$/\1:\2/' |
Karthikeyan Ramasubramanian | d1130b7 | 2022-08-16 17:42:57 -0600 | [diff] [blame] | 69 | |
| 70 | amdfwread-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 Ramasubramanian | 7835861 | 2022-08-16 17:30:06 -0600 | [diff] [blame] | 78 | endif # ifeq ($(CONFIG_VBOOT_GSCVD),y) |
| 79 | |
Fred Reitberger | e814b26 | 2022-12-01 08:49:44 -0500 | [diff] [blame] | 80 | endif # ifneq ($(CONFIG_AMDFW_CONFIG_FILE), ) |
Fred Reitberger | 8190840 | 2022-11-07 13:21:48 -0500 | [diff] [blame] | 81 | |
| 82 | MAINBOARD_BLOBS_DIR := $(call strip_quotes, $(CONFIG_APCB_BLOBS_DIR)) |
Fred Reitberger | e814b26 | 2022-12-01 08:49:44 -0500 | [diff] [blame] | 83 | |
Fred Reitberger | a63fac3 | 2023-02-13 11:06:15 -0500 | [diff] [blame] | 84 | PHONY+=warn_no_apcb |
| 85 | warn_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 Reitberger | 38954e2 | 2023-02-13 15:22:02 -0500 | [diff] [blame] | 90 | PHONY+=die_no_apcb |
| 91 | die_no_apcb: warn_no_apcb |
| 92 | $(error This board requires the APCB to build correctly) |
| 93 | |
Fred Reitberger | e814b26 | 2022-12-01 08:49:44 -0500 | [diff] [blame] | 94 | endif # ifeq ($(CONFIG_SOC_AMD_COMMON),y) |