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