Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: BSD-3-Clause |
| 2 | |
| 3 | # TODO: Check if this is still correct |
| 4 | |
| 5 | ifeq ($(CONFIG_SOC_AMD_SABRINA),y) |
| 6 | |
| 7 | subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage |
| 8 | |
| 9 | # Beware that all-y also adds the compilation unit to verstage on PSP |
| 10 | all-y += config.c |
| 11 | all-y += aoac.c |
| 12 | |
| 13 | bootblock-y += bootblock.c |
| 14 | bootblock-y += early_fch.c |
Raul E Rangel | d0b059f | 2022-03-24 17:04:11 -0600 | [diff] [blame] | 15 | bootblock-y += espi_util.c |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 16 | bootblock-y += gpio.c |
| 17 | bootblock-y += i2c.c |
| 18 | bootblock-y += reset.c |
| 19 | bootblock-y += uart.c |
| 20 | |
| 21 | verstage-y += i2c.c |
| 22 | verstage_x86-y += gpio.c |
| 23 | verstage_x86-y += reset.c |
| 24 | verstage_x86-y += uart.c |
| 25 | |
| 26 | romstage-y += fsp_m_params.c |
| 27 | romstage-y += gpio.c |
| 28 | romstage-y += i2c.c |
| 29 | romstage-y += reset.c |
| 30 | romstage-y += romstage.c |
| 31 | romstage-y += uart.c |
| 32 | |
| 33 | ramstage-y += acpi.c |
| 34 | ramstage-y += agesa_acpi.c |
| 35 | ramstage-y += chip.c |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 36 | ramstage-y += cpu.c |
| 37 | ramstage-y += data_fabric.c |
| 38 | ramstage-y += fch.c |
| 39 | ramstage-y += fsp_s_params.c |
| 40 | ramstage-y += gpio.c |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 41 | ramstage-y += i2c.c |
| 42 | ramstage-y += mca.c |
| 43 | ramstage-y += preload.c |
| 44 | ramstage-y += reset.c |
| 45 | ramstage-y += root_complex.c |
| 46 | ramstage-y += uart.c |
| 47 | ramstage-y += xhci.c |
| 48 | |
| 49 | smm-y += gpio.c |
| 50 | smm-y += smihandler.c |
| 51 | smm-y += smu.c |
| 52 | smm-$(CONFIG_DEBUG_SMI) += uart.c |
| 53 | |
| 54 | CPPFLAGS_common += -I$(src)/soc/amd/sabrina/include |
| 55 | CPPFLAGS_common += -I$(src)/soc/amd/sabrina/acpi |
| 56 | CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/sabrina |
| 57 | |
| 58 | MAINBOARD_BLOBS_DIR:=$(top)/3rdparty/blobs/mainboard/$(MAINBOARDDIR) |
| 59 | |
| 60 | # ROMSIG Normally At ROMBASE + 0x20000 |
| 61 | # Overridden by CONFIG_AMD_FWM_POSITION_INDEX |
| 62 | # +-----------+---------------+----------------+------------+ |
| 63 | # |0x55AA55AA | | | | |
| 64 | # +-----------+---------------+----------------+------------+ |
| 65 | # | | PSPDIR ADDR | BIOSDIR ADDR | |
| 66 | # +-----------+---------------+----------------+ |
| 67 | |
| 68 | $(if $(CONFIG_AMD_FWM_POSITION_INDEX), ,\ |
| 69 | $(error Invalid AMD firmware position index. Check if the board sets a valid ROM size)) |
| 70 | |
| 71 | SABRINA_FWM_POSITION=$(call int-add, \ |
| 72 | $(call int-subtract, 0xffffffff \ |
| 73 | $(call int-shift-left, \ |
| 74 | 0x80000 $(CONFIG_AMD_FWM_POSITION_INDEX))) 0x20000 1) |
| 75 | |
Robert Zieba | b26d005 | 2022-01-24 16:37:47 -0700 | [diff] [blame] | 76 | # 0x40 accounts for the cbfs_file struct + filename + metadata structs, aligned to 64 bytes |
| 77 | # Building the cbfs image will fail if the offset isn't large enough |
| 78 | AMD_FW_AB_POSITION := 0x40 |
| 79 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 80 | SABRINA_FW_A_POSITION=$(call int-add, \ |
| 81 | $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_A_START" {print $$3}' $(obj)/fmap_config.h) \ |
Robert Zieba | b26d005 | 2022-01-24 16:37:47 -0700 | [diff] [blame] | 82 | $(AMD_FW_AB_POSITION)) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 83 | |
| 84 | SABRINA_FW_B_POSITION=$(call int-add, \ |
| 85 | $(shell awk '$$2 == "FMAP_SECTION_FW_MAIN_B_START" {print $$3}' $(obj)/fmap_config.h) \ |
Robert Zieba | b26d005 | 2022-01-24 16:37:47 -0700 | [diff] [blame] | 86 | $(AMD_FW_AB_POSITION)) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 87 | # |
| 88 | # PSP Directory Table items |
| 89 | # |
| 90 | # Certain ordering requirements apply, however these are ensured by amdfwtool. |
| 91 | # For more information see "AMD Platform Security Processor BIOS Architecture |
| 92 | # Design Guide for AMD Family 17h Processors" (PID #55758, NDA only). |
| 93 | # |
| 94 | |
| 95 | FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}') |
| 96 | |
| 97 | ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y) |
| 98 | PSP_SOFTFUSE_BITS += 7 |
| 99 | endif |
| 100 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 101 | ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y) |
| 102 | # Enable secure debug unlock |
| 103 | PSP_SOFTFUSE_BITS += 0 |
| 104 | OPT_TOKEN_UNLOCK="--token-unlock" |
| 105 | endif |
| 106 | |
| 107 | ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y) |
| 108 | OPT_PSP_LOAD_MP2_FW="--load-mp2-fw" |
| 109 | else |
| 110 | # Disable MP2 firmware loading |
| 111 | PSP_SOFTFUSE_BITS += 29 |
| 112 | endif |
| 113 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 114 | # Use additional Soft Fuse bits specified in Kconfig |
| 115 | PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS)) |
| 116 | |
| 117 | # type = 0x3a |
| 118 | ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y) |
| 119 | PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE) |
| 120 | endif |
| 121 | |
Karthikeyan Ramasubramanian | 8ee9429 | 2022-04-01 17:21:14 -0600 | [diff] [blame] | 122 | # type = 0x55 |
| 123 | ifeq ($(CONFIG_HAVE_SPL_FILE),y) |
| 124 | SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE) |
| 125 | endif |
| 126 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 127 | # |
| 128 | # BIOS Directory Table items - proper ordering is managed by amdfwtool |
| 129 | # |
| 130 | |
| 131 | # type = 0x60 |
| 132 | PSP_APCB_FILES=$(APCB_SOURCES) $(APCB_SOURCES_RECOVERY) |
| 133 | |
| 134 | # type = 0x61 |
| 135 | PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS) |
| 136 | |
| 137 | # type = 0x62 |
| 138 | PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img |
| 139 | PSP_ELF_FILE=$(objcbfs)/bootblock.elf |
| 140 | PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -l $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}') |
| 141 | PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -l $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}') |
| 142 | |
| 143 | # type = 0x63 - construct APOB NV base/size from flash map |
| 144 | # The flashmap section used for this is expected to be named RW_MRC_CACHE |
| 145 | APOB_NV_SIZE=$(shell awk '$$2 == "FMAP_SECTION_RW_MRC_CACHE_SIZE" {print $$3}' $(obj)/fmap_config.h) |
| 146 | APOB_NV_BASE=$(shell awk '$$2 == "FMAP_SECTION_RW_MRC_CACHE_START" {print $$3}' $(obj)/fmap_config.h) |
| 147 | |
| 148 | ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y) |
| 149 | # type = 0x6B - PSP Shared memory location |
| 150 | ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0) |
| 151 | PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE) |
| 152 | PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map) |
| 153 | endif |
| 154 | |
| 155 | # type = 0x52 - PSP Bootloader Userspace Application (verstage) |
| 156 | PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE)) |
| 157 | PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN)) |
| 158 | endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK |
| 159 | |
| 160 | # Helper function to return a value with given bit set |
| 161 | # Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions. |
| 162 | set-bit=$(call int-shift-left, 1 $(call _toint,$1)) |
| 163 | PSP_SOFTFUSE=$(shell A=$(call int-add, \ |
| 164 | $(foreach bit,$(PSP_SOFTFUSE_BITS),$(call set-bit,$(bit)))); printf "0x%x" $$A) |
| 165 | |
| 166 | # |
| 167 | # Build the arguments to amdfwtool (order is unimportant). Missing file names |
| 168 | # result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool. |
| 169 | # |
| 170 | |
| 171 | add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), ) |
| 172 | |
| 173 | OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage) |
| 174 | OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig) |
| 175 | |
| 176 | OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \ |
| 177 | $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \ |
| 178 | $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68)) |
| 179 | |
| 180 | OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base) |
| 181 | OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin) |
| 182 | OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest) |
| 183 | OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size) |
| 184 | |
| 185 | OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem) |
| 186 | OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size) |
| 187 | OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size) |
| 188 | OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base) |
| 189 | OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode) |
| 190 | OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed) |
| 191 | OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag) |
| 192 | |
| 193 | OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse) |
| 194 | |
| 195 | OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist) |
Karthikeyan Ramasubramanian | 8ee9429 | 2022-04-01 17:21:14 -0600 | [diff] [blame] | 196 | OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 197 | |
Karthikeyan Ramasubramanian | 176b563 | 2022-04-08 17:40:50 -0600 | [diff] [blame] | 198 | # If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant |
| 199 | OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy) |
| 200 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 201 | # Add all the files listed in the config file |
| 202 | POUND_SIGN=$(call strip_quotes, "\#") |
| 203 | DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /*/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' )) |
| 204 | |
| 205 | AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \ |
| 206 | $(OPT_APOB_ADDR) \ |
| 207 | $(OPT_PSP_BIOSBIN_FILE) \ |
| 208 | $(OPT_PSP_BIOSBIN_DEST) \ |
| 209 | $(OPT_PSP_BIOSBIN_SIZE) \ |
| 210 | $(OPT_PSP_SOFTFUSE) \ |
| 211 | $(OPT_PSP_LOAD_MP2_FW) \ |
| 212 | --use-pspsecureos \ |
| 213 | --load-s0i3 \ |
| 214 | --combo-capable \ |
| 215 | $(OPT_TOKEN_UNLOCK) \ |
| 216 | $(OPT_WHITELIST_FILE) \ |
Karthikeyan Ramasubramanian | 8ee9429 | 2022-04-01 17:21:14 -0600 | [diff] [blame] | 217 | $(OPT_SPL_TABLE_FILE) \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 218 | $(OPT_PSP_SHAREDMEM_BASE) \ |
| 219 | $(OPT_PSP_SHAREDMEM_SIZE) \ |
| 220 | $(OPT_EFS_SPI_READ_MODE) \ |
| 221 | $(OPT_EFS_SPI_SPEED) \ |
| 222 | $(OPT_EFS_SPI_MICRON_FLAG) \ |
| 223 | --config $(CONFIG_AMDFW_CONFIG_FILE) \ |
Felix Held | e3ee917 | 2022-03-30 01:01:46 +0200 | [diff] [blame] | 224 | --soc-name "Sabrina" \ |
Karthikeyan Ramasubramanian | 176b563 | 2022-04-08 17:40:50 -0600 | [diff] [blame] | 225 | --flashsize $(CONFIG_ROM_SIZE) \ |
| 226 | $(OPT_RECOVERY_AB_SINGLE_COPY) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 227 | |
| 228 | $(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \ |
| 229 | $(PSP_VERSTAGE_FILE) \ |
| 230 | $(PSP_VERSTAGE_SIG_FILE) \ |
| 231 | $$(PSP_APCB_FILES) \ |
| 232 | $(DEP_FILES) \ |
| 233 | $(AMDFWTOOL) \ |
| 234 | $(obj)/fmap_config.h \ |
| 235 | $(objcbfs)/bootblock.elf # this target also creates the .map file |
| 236 | $(if $(PSP_APCB_FILES), ,$(error APCB_SOURCES is not set)) |
| 237 | rm -f $@ |
| 238 | @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n" |
| 239 | $(AMDFWTOOL) \ |
| 240 | $(AMDFW_COMMON_ARGS) \ |
| 241 | $(OPT_APOB_NV_SIZE) \ |
| 242 | $(OPT_APOB_NV_BASE) \ |
| 243 | $(OPT_VERSTAGE_FILE) \ |
| 244 | $(OPT_VERSTAGE_SIG_FILE) \ |
| 245 | --location $(shell printf "%#x" $(SABRINA_FWM_POSITION)) \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 246 | --output $@ |
| 247 | |
| 248 | $(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS) |
| 249 | rm -f $@ |
| 250 | @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n" |
| 251 | $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \ |
| 252 | --maxsize $(PSP_BIOSBIN_SIZE) |
| 253 | |
| 254 | $(obj)/amdfw_a.rom: $(obj)/amdfw.rom |
| 255 | rm -f $@ |
| 256 | @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n" |
| 257 | $(AMDFWTOOL) \ |
| 258 | $(AMDFW_COMMON_ARGS) \ |
| 259 | $(OPT_APOB_NV_SIZE) \ |
| 260 | $(OPT_APOB_NV_BASE) \ |
| 261 | --location $(shell printf "%#x" $(SABRINA_FW_A_POSITION)) \ |
| 262 | --anywhere \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 263 | --output $@ |
| 264 | |
| 265 | $(obj)/amdfw_b.rom: $(obj)/amdfw.rom |
| 266 | rm -f $@ |
| 267 | @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n" |
| 268 | $(AMDFWTOOL) \ |
| 269 | $(AMDFW_COMMON_ARGS) \ |
| 270 | $(OPT_APOB_NV_SIZE) \ |
| 271 | $(OPT_APOB_NV_BASE) \ |
| 272 | --location $(shell printf "%#x" $(SABRINA_FW_B_POSITION)) \ |
| 273 | --anywhere \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 274 | --output $@ |
| 275 | |
| 276 | |
| 277 | cbfs-files-y += apu/amdfw |
| 278 | apu/amdfw-file := $(obj)/amdfw.rom |
| 279 | apu/amdfw-position := $(SABRINA_FWM_POSITION) |
| 280 | apu/amdfw-type := raw |
| 281 | |
| 282 | ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy) |
| 283 | cbfs-files-y += apu/amdfw_a |
| 284 | apu/amdfw_a-file := $(obj)/amdfw_a.rom |
Robert Zieba | b26d005 | 2022-01-24 16:37:47 -0700 | [diff] [blame] | 285 | apu/amdfw_a-position := $(AMD_FW_AB_POSITION) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 286 | apu/amdfw_a-type := raw |
| 287 | |
| 288 | cbfs-files-y += apu/amdfw_b |
| 289 | apu/amdfw_b-file := $(obj)/amdfw_b.rom |
Robert Zieba | b26d005 | 2022-01-24 16:37:47 -0700 | [diff] [blame] | 290 | apu/amdfw_b-position := $(AMD_FW_AB_POSITION) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 291 | apu/amdfw_b-type := raw |
| 292 | endif |
| 293 | |
Fred Reitberger | ceccfa2 | 2022-06-09 11:08:07 -0400 | [diff] [blame] | 294 | amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*UcodePatch_*.bin) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 295 | |
| 296 | endif # ($(CONFIG_SOC_AMD_SABRINA),y) |