xref: /aosp_15_r20/external/coreboot/src/soc/intel/common/block/fast_spi/Makefile.mk (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1## SPDX-License-Identifier: GPL-2.0-only
2bootblock-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi.c
3bootblock-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi_flash.c
4
5verstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi.c
6verstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi_flash.c
7
8romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi.c
9romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi_flash.c
10
11ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi.c
12ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi_flash.c
13
14postcar-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi.c
15postcar-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi_flash.c
16
17smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi.c
18ifeq ($(CONFIG_SPI_FLASH_SMM),y)
19smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_FAST_SPI) += fast_spi_flash.c
20endif
21
22CPPFLAGS_common += -I$(src)/soc/intel/common/block/fast_spi
23
24ifeq ($(CONFIG_FAST_SPI_SUPPORTS_EXT_BIOS_WINDOW),y)
25
26# mmap_boot.c provides a custom boot media device for the platforms that support
27# additional window for BIOS regions greater than 16MiB. This is used instead of
28# the default boot media device in arch/x86/mmap_boot.c
29bootblock-y += mmap_boot.c
30verstage-y += mmap_boot.c
31romstage-y += mmap_boot.c
32postcar-y += mmap_boot.c
33ramstage-y += mmap_boot.c
34smm-y += mmap_boot.c
35
36# When using extended BIOS window, no sub-region within the BIOS region must
37# cross 16MiB boundary from the end of the BIOS region. This is because the
38# top 16MiB of the BIOS region are decoded by the standard window from
39# (4G - 16M) to 4G. There is no standard section name that identifies the BIOS
40# region in flashmap. This check assumes that BIOS region is placed at the top
41# of SPI flash and hence calculates the boundary as flash_size - 16M. If any
42# region within the SPI flash crosses this boundary, then the check complains
43# and exits.
44
45$(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h)
46	fmap_get() { awk "/$$1/ { print \$$NF }" < $<; };		\
47									\
48	flash_offset=$$(fmap_get FMAP_SECTION_FLASH_START);		\
49	flash_size=$$(fmap_get FMAP_SECTION_FLASH_SIZE);		\
50	if [ $$((flash_size)) -le $$((0x1000000)) ]; then		\
51	   exit;							\
52	fi;								\
53	bios_16M_boundary=$$((flash_size-0x1000000));			\
54	for x in $$(grep "FMAP_TERMINAL_SECTIONS" < $< | cut -d\" -f2);	\
55	do								\
56	    start=$$(fmap_get "FMAP_SECTION_$${x}_START");		\
57	    size=$$(fmap_get "FMAP_SECTION_$${x}_SIZE");		\
58	    start=$$((start-flash_offset));				\
59	    end=$$((start+size-1));					\
60	    if [ $$((start)) -lt $$((bios_16M_boundary)) ] &&		\
61			[ $$((end)) -ge $$((bios_16M_boundary)) ];	\
62	    then							\
63	        echo "ERROR: $$x crosses 16MiB boundary";		\
64	        fail=1;							\
65	        break;							\
66	    fi;								\
67	done;								\
68	exit $$fail
69
70# If the platform supports extended window and the SPI flash size is greater
71# than 16MiB, then create a mapping for the extended window as well.
72# The assumptions here are:
73# 1. Top 16MiB is still decoded in the fixed decode window just below 4G
74# boundary.
75# 2. Rest of the SPI flash below the top 16MiB is mapped at the top of extended
76# window. Even though the platform might support a larger extended window, the
77# SPI flash part used by the mainboard might not be large enough to be mapped
78# in the entire window. In such cases, the mapping is assumed to be in the top
79# part of the extended window with the bottom part remaining unused.
80#
81# Example:
82# ext_win_base = 0xF8000000
83# ext_win_size = 32 # MiB
84# ext_win_limit = ext_win_base + ext_win_size - 1 = 0xF9FFFFFF
85#
86# If SPI flash is 32MiB, then top 16MiB is mapped from 0xFF000000 - 0xFFFFFFFF
87# whereas the bottom 16MiB is mapped from 0xF9000000 - 0xF9FFFFFF. The extended
88# window 0xF8000000 - 0xF8FFFFFF remains unused.
89#
90
91ifeq ($(call int-gt, $(CONFIG_ROM_SIZE) 0x1000000), 1)
92DEFAULT_WINDOW_SIZE=0x1000000
93DEFAULT_WINDOW_FLASH_BASE=$(call int-subtract, $(CONFIG_ROM_SIZE) $(DEFAULT_WINDOW_SIZE))
94DEFAULT_WINDOW_MMIO_BASE=0xff000000
95EXT_WINDOW_FLASH_BASE=0
96EXT_WINDOW_SIZE=$(DEFAULT_WINDOW_FLASH_BASE)
97EXT_WINDOW_MMIO_BASE=$(call int-subtract, $(call int-add, $(CONFIG_EXT_BIOS_WIN_BASE) $(CONFIG_EXT_BIOS_WIN_SIZE)) \
98	$(EXT_WINDOW_SIZE))
99CBFSTOOL_ADD_CMD_OPTIONS += --mmap $(DEFAULT_WINDOW_FLASH_BASE):$(DEFAULT_WINDOW_MMIO_BASE):$(DEFAULT_WINDOW_SIZE)
100CBFSTOOL_ADD_CMD_OPTIONS += --mmap $(EXT_WINDOW_FLASH_BASE):$(EXT_WINDOW_MMIO_BASE):$(EXT_WINDOW_SIZE)
101endif
102
103
104endif # CONFIG_FAST_SPI_SUPPORTS_EXT_BIOS_WINDOW
105