blob: 3b3e92d06b16405f0c4166c3d20553e83645566d [file] [log] [blame]
Sheetal Tigadoli13680c92019-12-13 10:39:06 +05301#
Bharat Gooty66b0bb42020-09-24 12:29:00 +05302# Copyright (c) 2015 - 2021, Broadcom
Sheetal Tigadoli13680c92019-12-13 10:39:06 +05303#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7PLAT_BL_COMMON_SOURCES += plat/brcm/board/common/board_common.c
8
9# If no board config makefile, do not include it
10ifneq (${BOARD_CFG},)
11BOARD_CFG_MAKE := $(shell find plat/brcm/board/${PLAT} -name '${BOARD_CFG}.mk')
12$(eval $(call add_define,BOARD_CFG))
13ifneq (${BOARD_CFG_MAKE},)
14$(info Including ${BOARD_CFG_MAKE})
15include ${BOARD_CFG_MAKE}
16else
17$(error Error: File ${BOARD_CFG}.mk not found in plat/brcm/board/${PLAT})
18endif
19endif
20
21# To compile with highest log level (VERBOSE) set value to 50
22LOG_LEVEL := 40
23
24# Use custom generic timer clock
25ifneq (${GENTIMER_ACTUAL_CLOCK},)
26$(info Using GENTIMER_ACTUAL_CLOCK=$(GENTIMER_ACTUAL_CLOCK))
27SYSCNT_FREQ := $(GENTIMER_ACTUAL_CLOCK)
28$(eval $(call add_define,SYSCNT_FREQ))
29endif
30
Sheetal Tigadolib0156702020-01-05 14:59:04 +053031ifeq (${DRIVER_EMMC_ENABLE},)
32DRIVER_EMMC_ENABLE :=1
33endif
34
Sheetal Tigadoli3bb1b4c2020-01-05 21:19:02 +053035ifeq (${DRIVER_SPI_ENABLE},)
36DRIVER_SPI_ENABLE := 0
37endif
38
Bharat Gooty66b0bb42020-09-24 12:29:00 +053039ifeq (${DRIVER_I2C_ENABLE},)
40DRIVER_I2C_ENABLE := 0
41endif
42
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +053043# By default, Trusted Watchdog is always enabled unless SPIN_ON_BL1_EXIT is set
44ifeq (${BRCM_DISABLE_TRUSTED_WDOG},)
45BRCM_DISABLE_TRUSTED_WDOG := 0
46endif
47ifeq (${SPIN_ON_BL1_EXIT}, 1)
48BRCM_DISABLE_TRUSTED_WDOG := 1
49endif
50
51$(eval $(call assert_boolean,BRCM_DISABLE_TRUSTED_WDOG))
52$(eval $(call add_define,BRCM_DISABLE_TRUSTED_WDOG))
53
Sheetal Tigadoli2a96dc22019-12-18 12:01:01 +053054# Process ARM_BL31_IN_DRAM flag
55ifeq (${ARM_BL31_IN_DRAM},)
56ARM_BL31_IN_DRAM := 0
57endif
58$(eval $(call assert_boolean,ARM_BL31_IN_DRAM))
59$(eval $(call add_define,ARM_BL31_IN_DRAM))
60
Sheetal Tigadoli13680c92019-12-13 10:39:06 +053061ifeq (${STANDALONE_BL2},yes)
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +053062BL2_LOG_LEVEL := 40
Sheetal Tigadoli13680c92019-12-13 10:39:06 +053063$(eval $(call add_define,MMU_DISABLED))
64endif
65
66# BL2 XIP from QSPI
67RUN_BL2_FROM_QSPI := 0
68ifeq (${RUN_BL2_FROM_QSPI},1)
69$(eval $(call add_define,RUN_BL2_FROM_QSPI))
70endif
71
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +053072# BL2 XIP from NAND
73RUN_BL2_FROM_NAND := 0
74ifeq (${RUN_BL2_FROM_NAND},1)
75$(eval $(call add_define,RUN_BL2_FROM_NAND))
76endif
77
78ifneq (${ELOG_AP_UART_LOG_BASE},)
79$(eval $(call add_define,ELOG_AP_UART_LOG_BASE))
80endif
81
82ifeq (${ELOG_SUPPORT},1)
83ifeq (${ELOG_STORE_MEDIA},DDR)
84$(eval $(call add_define,ELOG_STORE_MEDIA_DDR))
85ifneq (${ELOG_STORE_OFFSET},)
86$(eval $(call add_define,ELOG_STORE_OFFSET))
87endif
88endif
89endif
90
91ifneq (${BL2_LOG_LEVEL},)
92$(eval $(call add_define,BL2_LOG_LEVEL))
93endif
94
Sheetal Tigadoli58a9eca2019-12-18 20:05:09 +053095ifneq (${BL31_LOG_LEVEL},)
96$(eval $(call add_define,BL31_LOG_LEVEL))
97endif
98
Sheetal Tigadoli13680c92019-12-13 10:39:06 +053099# Use CRMU SRAM from iHOST
100ifneq (${USE_CRMU_SRAM},)
101$(eval $(call add_define,USE_CRMU_SRAM))
102endif
103
Sheetal Tigadolib0156702020-01-05 14:59:04 +0530104# Use PIO mode if DDR is not used
105ifeq (${USE_DDR},yes)
106EMMC_USE_DMA := 1
107else
108EMMC_USE_DMA := 0
109endif
110$(eval $(call add_define,EMMC_USE_DMA))
111
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530112# On BRCM platforms, separate the code and read-only data sections to allow
113# mapping the former as executable and the latter as execute-never.
114SEPARATE_CODE_AND_RODATA := 1
115
116# Use generic OID definition (tbbr_oid.h)
117USE_TBBR_DEFS := 1
118
Sheetal Tigadoli2a96dc22019-12-18 12:01:01 +0530119PLAT_INCLUDES += -Iplat/brcm/board/common \
Sheetal Tigadolib0156702020-01-05 14:59:04 +0530120 -Iinclude/drivers/brcm \
Bharat Gootyd9ff1ca2020-09-24 13:02:39 +0530121 -Iinclude/drivers/brcm/emmc \
122 -Iinclude/drivers/brcm/mdio
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530123
124PLAT_BL_COMMON_SOURCES += plat/brcm/common/brcm_common.c \
125 plat/brcm/board/common/cmn_sec.c \
126 plat/brcm/board/common/bcm_console.c \
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530127 plat/brcm/board/common/brcm_mbedtls.c \
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530128 plat/brcm/board/common/plat_setup.c \
129 plat/brcm/board/common/platform_common.c \
130 drivers/arm/sp804/sp804_delay_timer.c \
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530131 drivers/brcm/sotp.c \
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530132 drivers/delay_timer/delay_timer.c \
133 drivers/io/io_fip.c \
134 drivers/io/io_memmap.c \
135 drivers/io/io_storage.c \
136 plat/brcm/common/brcm_io_storage.c \
137 plat/brcm/board/common/err.c \
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530138 plat/brcm/board/common/sbl_util.c \
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530139 drivers/arm/sp805/sp805.c
140
Bharat Gooty23763b52020-07-13 17:58:29 +0530141# Add RNG driver
142DRIVER_RNG_ENABLE := 1
143ifeq (${DRIVER_RNG_ENABLE},1)
144PLAT_BL_COMMON_SOURCES += drivers/brcm/rng.c
145endif
146
Sheetal Tigadolib0156702020-01-05 14:59:04 +0530147# Add eMMC driver
148ifeq (${DRIVER_EMMC_ENABLE},1)
149$(eval $(call add_define,DRIVER_EMMC_ENABLE))
150
151EMMC_SOURCES += drivers/brcm/emmc/emmc_chal_sd.c \
152 drivers/brcm/emmc/emmc_csl_sdcard.c \
153 drivers/brcm/emmc/emmc_csl_sdcmd.c \
154 drivers/brcm/emmc/emmc_pboot_hal_memory_drv.c
155
156PLAT_BL_COMMON_SOURCES += ${EMMC_SOURCES}
157
158ifeq (${DRIVER_EMMC_ENABLE_DATA_WIDTH_8BIT},)
159$(eval $(call add_define,DRIVER_EMMC_ENABLE_DATA_WIDTH_8BIT))
160endif
161endif
162
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530163BL2_SOURCES += plat/brcm/common/brcm_bl2_mem_params_desc.c \
164 plat/brcm/common/brcm_image_load.c \
165 common/desc_image_load.c
166
167BL2_SOURCES += plat/brcm/common/brcm_bl2_setup.c
168
Sheetal Tigadoli2a96dc22019-12-18 12:01:01 +0530169BL31_SOURCES += plat/brcm/common/brcm_bl31_setup.c
170
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530171ifeq (${BCM_ELOG},yes)
172ELOG_SOURCES += plat/brcm/board/common/bcm_elog.c
173BL2_SOURCES += ${ELOG_SOURCES}
Sheetal Tigadoli58a9eca2019-12-18 20:05:09 +0530174BL31_SOURCES += ${ELOG_SOURCES}
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530175endif
176
Sheetal Tigadoli3bb1b4c2020-01-05 21:19:02 +0530177# Add spi driver
178ifeq (${DRIVER_SPI_ENABLE},1)
179PLAT_BL_COMMON_SOURCES += drivers/brcm/spi/iproc_spi.c \
180 drivers/brcm/spi/iproc_qspi.c
181endif
182
Sheetal Tigadoli6c4db5d2020-01-06 00:08:24 +0530183# Add spi nor/flash driver
184ifeq (${DRIVER_SPI_NOR_ENABLE},1)
185PLAT_BL_COMMON_SOURCES += drivers/brcm/spi_sf.c \
186 drivers/brcm/spi_flash.c
187endif
188
Bharat Gooty66b0bb42020-09-24 12:29:00 +0530189ifeq (${DRIVER_I2C_ENABLE},1)
190$(eval $(call add_define,DRIVER_I2C_ENABLE))
191BL2_SOURCES += drivers/brcm/i2c/i2c.c
192PLAT_INCLUDES += -Iinclude/drivers/brcm/i2c
193endif
194
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530195ifeq (${DRIVER_OCOTP_ENABLE},1)
196$(eval $(call add_define,DRIVER_OCOTP_ENABLE))
197BL2_SOURCES += drivers/brcm/ocotp.c
198endif
199
200# Enable FRU table support
201ifeq (${USE_FRU},yes)
202$(eval $(call add_define,USE_FRU))
203BL2_SOURCES += drivers/brcm/fru.c
204endif
205
206# Enable GPIO support
207ifeq (${USE_GPIO},yes)
208$(eval $(call add_define,USE_GPIO))
209BL2_SOURCES += drivers/gpio/gpio.c
210BL2_SOURCES += drivers/brcm/iproc_gpio.c
211ifeq (${GPIO_SUPPORT_FLOAT_DETECTION},yes)
212$(eval $(call add_define,GPIO_SUPPORT_FLOAT_DETECTION))
213endif
214endif
215
216# Include mbedtls if it can be located
217MBEDTLS_DIR := mbedtls
218MBEDTLS_CHECK := $(shell find ${MBEDTLS_DIR}/include -name '${MBEDTLS_DIR}')
219
220ifneq (${MBEDTLS_CHECK},)
221$(info Found mbedTLS at ${MBEDTLS_DIR})
222PLAT_INCLUDES += -I${MBEDTLS_DIR}/include/mbedtls
223# Specify mbedTLS configuration file
224MBEDTLS_CONFIG_FILE := "<brcm_mbedtls_config.h>"
225
226# By default, use RSA keys
227KEY_ALG := rsa_1_5
228
229# Include common TBB sources
230AUTH_SOURCES += drivers/auth/auth_mod.c \
231 drivers/auth/crypto_mod.c \
232 drivers/auth/img_parser_mod.c \
Manish V Badarkhe043fd622020-05-16 16:36:39 +0100233 drivers/auth/tbbr/tbbr_cot_common.c \
234 drivers/auth/tbbr/tbbr_cot_bl2.c
Sheetal Tigadoliad0943e2019-12-18 19:44:43 +0530235
236BL2_SOURCES += ${AUTH_SOURCES}
237
238# Use ATF framework for MBEDTLS
239TRUSTED_BOARD_BOOT := 1
240CRYPTO_LIB_MK := drivers/auth/mbedtls/mbedtls_crypto.mk
241IMG_PARSER_LIB_MK := drivers/auth/mbedtls/mbedtls_x509.mk
242$(info Including ${CRYPTO_LIB_MK})
243include ${CRYPTO_LIB_MK}
244$(info Including ${IMG_PARSER_LIB_MK})
245include ${IMG_PARSER_LIB_MK}
246
247# Use ATF secure boot functions
248# Use Hardcoded hash for devel
249
250ARM_ROTPK_LOCATION=arm_rsa
251ifeq (${ARM_ROTPK_LOCATION}, arm_rsa)
252ARM_ROTPK_LOCATION_ID=ARM_ROTPK_DEVEL_RSA_ID
253ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem
254else ifeq (${ARM_ROTPK_LOCATION}, brcm_rsa)
255ARM_ROTPK_LOCATION_ID=BRCM_ROTPK_SOTP_RSA_ID
256ifeq (${ROT_KEY},)
257ROT_KEY=plat/brcm/board/common/rotpk/rsa_dauth2048_key.pem
258endif
259KEY_FIND := $(shell m="${ROT_KEY}"; [ -f "$$m" ] && echo "$$m")
260ifeq (${KEY_FIND},)
261$(error Error: No ${ROT_KEY} located)
262else
263$(info Using ROT_KEY: ${ROT_KEY})
264endif
265else
266$(error "Unsupported ARM_ROTPK_LOCATION value")
267endif
268
269$(eval $(call add_define,ARM_ROTPK_LOCATION_ID))
270PLAT_BL_COMMON_SOURCES+=plat/brcm/board/common/board_arm_trusted_boot.c
271endif
272
Sheetal Tigadoli2a96dc22019-12-18 12:01:01 +0530273#M0 runtime firmware
274ifdef SCP_BL2
275$(eval $(call add_define,NEED_SCP_BL2))
276SCP_CFG_DIR=$(dir ${SCP_BL2})
277PLAT_INCLUDES += -I${SCP_CFG_DIR}
278endif
279
280ifneq (${NEED_BL33},yes)
281# If there is no BL33, BL31 will jump to this address.
282ifeq (${USE_DDR},yes)
283PRELOADED_BL33_BASE := 0x80000000
284else
285PRELOADED_BL33_BASE := 0x74000000
286endif
287endif
288
Sheetal Tigadoli13680c92019-12-13 10:39:06 +0530289# Use translation tables library v1 by default
290ARM_XLAT_TABLES_LIB_V1 := 1
291ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
292$(eval $(call assert_boolean,ARM_XLAT_TABLES_LIB_V1))
293$(eval $(call add_define,ARM_XLAT_TABLES_LIB_V1))
294PLAT_BL_COMMON_SOURCES += lib/xlat_tables/aarch64/xlat_tables.c \
295 lib/xlat_tables/xlat_tables_common.c
296endif