blob: efbd3b1275674ddc1bc18acf011b3f739cb73c8e [file] [log] [blame]
Arthur Heymans6d3682e2023-07-13 12:34:04 +02001## SPDX-License-Identifier: GPL-2.0-only
2ifeq ($(CONFIG_SOC_AMD_GENOA),y)
3
Arthur Heymanse4eba132023-07-13 14:02:42 +02004all-y += mmap_boot.c
Arthur Heymansb4aaa6f2023-07-13 14:11:18 +02005all-y += reset.c
Arthur Heymansc5c35ce2023-07-13 14:05:08 +02006all-y += config.c
Arthur Heymanse4eba132023-07-13 14:02:42 +02007
Arthur Heymans6d3682e2023-07-13 12:34:04 +02008bootblock-y += early_fch.c
9
10romstage-y += romstage.c
11
12ramstage-y += chip.c
Arthur Heymans6d3682e2023-07-13 12:34:04 +020013
14CPPFLAGS_common += -I$(src)/soc/amd/genoa/include
15
Arthur Heymans926d55c2023-07-13 12:50:45 +020016ifeq ($(call int-gt, $(CONFIG_ROM_SIZE) 0x1000000), 1)
17CBFSTOOL_ADD_CMD_OPTIONS+= --mmap 0:0xff000000:0x1000000
18endif
19
Arthur Heymans8f1c7072023-07-13 12:52:49 +020020#
21# PSP Directory Table items
22#
23# Certain ordering requirements apply, however these are ensured by amdfwtool.
24# For more information see "AMD Platform Security Processor BIOS Implementation
25# Guide for Server EPYC Processors" #57299
26#
27
28FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}')
29
30ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y)
31PSP_SOFTFUSE_BITS += 7
32endif
33
34ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
35# Enable secure debug unlock
36PSP_SOFTFUSE_BITS += 0
37OPT_TOKEN_UNLOCK="--token-unlock"
38endif
39
40# Use additional Soft Fuse bits specified in Kconfig
41PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS))
42
43# type = 0x3a
44ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
45PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
46endif
47
48# type = 0x55
49ifeq ($(CONFIG_HAVE_SPL_FILE),y)
50SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
51endif
52
53#
54# BIOS Directory Table items - proper ordering is managed by amdfwtool
55#
56
57# type = 0x60
58PSP_APCB_FILES=$(APCB_SOURCES) $(APCB1_SOURCES) $(APCB_SOURCES_RECOVERY) $(APCB_SOURCES_RECOVERY1) $(APCB_SOURCES_RECOVERY2)
59
60# type = 0x61
61PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS)
62
63# type = 0x62
64PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img
65PSP_ELF_FILE=$(objcbfs)/bootblock.elf
66PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}')
67PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}')
68
69# Helper function to return a value with given bit set
70# Soft Fuse type = 0xb - See #57299 (NDA) for bit definitions.
71set-bit=$(call int-shift-left, 1 $(call _toint,$1))
72PSP_SOFTFUSE=$(shell A=$(call int-add, \
73 $(foreach bit,$(PSP_SOFTFUSE_BITS),$(call set-bit,$(bit)))); printf "0x%x" $$A)
74
75#
76# Build the arguments to amdfwtool (order is unimportant). Missing file names
77# result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
78#
79
80add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
81
82OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
83 $(if $(APCB_SOURCES1), --instance 1 --apcb $(APCB_SOURCES1)) \
84 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
85 $(if $(APCB_SOURCES_RECOVERY1), --instance 18 --apcb $(APCB_SOURCES_RECOVERY1)) \
86 $(if $(APCB_SOURCES_RECOVERY2), --instance 19 --apcb $(APCB_SOURCES_RECOVERY2)) \
87 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
88
89OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
90OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
91OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
92OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
93
94OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
95OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
96OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
97OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
98
99OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
100OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
101
102AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
103 $(OPT_APOB_ADDR) \
104 $(OPT_DEBUG_AMDFWTOOL) \
105 $(OPT_PSP_BIOSBIN_FILE) \
106 $(OPT_PSP_BIOSBIN_DEST) \
107 $(OPT_PSP_BIOSBIN_SIZE) \
108 $(OPT_PSP_SOFTFUSE) \
109 --use-pspsecureos \
110 $(OPT_TOKEN_UNLOCK) \
111 $(OPT_WHITELIST_FILE) \
112 $(OPT_SPL_TABLE_FILE) \
113 $(OPT_EFS_SPI_READ_MODE) \
114 $(OPT_EFS_SPI_SPEED) \
115 $(OPT_EFS_SPI_MICRON_FLAG) \
116 --config $(CONFIG_AMDFW_CONFIG_FILE) \
117 --flashsize 0x1000000
118
119$(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
120 $$(PSP_APCB_FILES) \
121 $(DEP_FILES) \
122 $(AMDFWTOOL) \
123 $(obj)/fmap_config.h \
124 $(objcbfs)/bootblock.elf # this target also creates the .map file
125 $(if $(PSP_APCB_FILES), ,$(error APCB_SOURCES is not set))
126 rm -f $@
127 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
128 $(AMDFWTOOL) \
129 $(AMDFW_COMMON_ARGS) \
130 --location $(CONFIG_AMD_FWM_POSITION) \
131 --multilevel \
132 --output $@
133
134$(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
135 rm -f $@
136 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
137 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
138 --maxsize $(PSP_BIOSBIN_SIZE)
139
Arthur Heymans6d3682e2023-07-13 12:34:04 +0200140endif