1#
2# Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7# Non-TF Boot ROM
8BL2_AT_EL3	:=	1
9
10# On Hikey960, the TSP can execute from TZC secure area in DRAM.
11HIKEY960_TSP_RAM_LOCATION	?=	dram
12ifeq (${HIKEY960_TSP_RAM_LOCATION}, dram)
13  HIKEY960_TSP_RAM_LOCATION_ID = HIKEY960_DRAM_ID
14else ifeq (${HIKEY960_TSP_RAM_LOCATION}, sram)
15  HIKEY960_TSP_RAM_LOCATION_ID = HIKEY960_SRAM_ID
16else
17  $(error "Currently unsupported HIKEY960_TSP_RAM_LOCATION value")
18endif
19
20CRASH_CONSOLE_BASE		:=	PL011_UART6_BASE
21COLD_BOOT_SINGLE_CPU		:=	1
22PLAT_PL061_MAX_GPIOS		:=	232
23PROGRAMMABLE_RESET_ADDRESS	:=	1
24ENABLE_SVE_FOR_NS		:=	0
25PLAT_PARTITION_BLOCK_SIZE	:=	4096
26
27# Process flags
28$(eval $(call add_define,HIKEY960_TSP_RAM_LOCATION_ID))
29$(eval $(call add_define,CRASH_CONSOLE_BASE))
30$(eval $(call add_define,PLAT_PL061_MAX_GPIOS))
31$(eval $(call add_define,PLAT_PARTITION_BLOCK_SIZE))
32
33# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
34# in the FIP if the platform requires.
35ifneq ($(BL32_EXTRA1),)
36$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1))
37endif
38ifneq ($(BL32_EXTRA2),)
39$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2))
40endif
41
42USE_COHERENT_MEM	:=	1
43
44PLAT_INCLUDES		:=	-Iplat/hisilicon/hikey960/include
45
46PLAT_BL_COMMON_SOURCES	:=	drivers/arm/pl011/aarch64/pl011_console.S \
47				drivers/delay_timer/delay_timer.c	\
48				drivers/delay_timer/generic_delay_timer.c \
49				lib/xlat_tables/aarch64/xlat_tables.c	\
50				lib/xlat_tables/xlat_tables_common.c	\
51				plat/hisilicon/hikey960/aarch64/hikey960_common.c \
52				plat/hisilicon/hikey960/hikey960_boardid.c
53
54HIKEY960_GIC_SOURCES	:=	drivers/arm/gic/common/gic_common.c	\
55				drivers/arm/gic/v2/gicv2_main.c		\
56				drivers/arm/gic/v2/gicv2_helpers.c	\
57				plat/common/plat_gicv2.c
58
59BL1_SOURCES		+=	bl1/tbbr/tbbr_img_desc.c		\
60				drivers/arm/pl061/pl061_gpio.c		\
61				drivers/gpio/gpio.c			\
62				drivers/io/io_block.c			\
63				drivers/io/io_fip.c			\
64				drivers/io/io_storage.c			\
65				drivers/synopsys/ufs/dw_ufs.c		\
66				drivers/ufs/ufs.c 			\
67				lib/cpus/aarch64/cortex_a53.S		\
68				plat/hisilicon/hikey960/aarch64/hikey960_helpers.S \
69				plat/hisilicon/hikey960/hikey960_bl1_setup.c \
70				plat/hisilicon/hikey960/hikey960_bl_common.c \
71				plat/hisilicon/hikey960/hikey960_io_storage.c \
72				${HIKEY960_GIC_SOURCES}
73
74BL2_SOURCES		+=	common/desc_image_load.c		\
75				drivers/arm/pl061/pl061_gpio.c		\
76				drivers/gpio/gpio.c			\
77				drivers/io/io_block.c			\
78				drivers/io/io_fip.c			\
79				drivers/io/io_storage.c			\
80				drivers/partition/gpt.c			\
81				drivers/partition/partition.c		\
82				drivers/synopsys/ufs/dw_ufs.c		\
83				drivers/ufs/ufs.c			\
84				lib/cpus/aarch64/cortex_a53.S		\
85				plat/hisilicon/hikey960/aarch64/hikey960_helpers.S \
86				plat/hisilicon/hikey960/hikey960_bl2_mem_params_desc.c \
87				plat/hisilicon/hikey960/hikey960_bl2_setup.c \
88				plat/hisilicon/hikey960/hikey960_bl_common.c \
89				plat/hisilicon/hikey960/hikey960_image_load.c \
90				plat/hisilicon/hikey960/hikey960_io_storage.c \
91				plat/hisilicon/hikey960/hikey960_mcu_load.c
92
93ifeq (${SPD},opteed)
94BL2_SOURCES		+=	lib/optee/optee_utils.c
95endif
96
97BL31_SOURCES		+=	drivers/arm/cci/cci.c			\
98				drivers/arm/pl061/pl061_gpio.c		\
99				drivers/gpio/gpio.c			\
100				lib/cpus/aarch64/cortex_a53.S           \
101				lib/cpus/aarch64/cortex_a72.S		\
102				lib/cpus/aarch64/cortex_a73.S		\
103				plat/common/plat_psci_common.c  \
104				plat/hisilicon/hikey960/aarch64/hikey960_helpers.S \
105				plat/hisilicon/hikey960/hikey960_bl31_setup.c \
106				plat/hisilicon/hikey960/hikey960_bl_common.c \
107				plat/hisilicon/hikey960/hikey960_pm.c	\
108				plat/hisilicon/hikey960/hikey960_topology.c \
109				plat/hisilicon/hikey960/drivers/pwrc/hisi_pwrc.c \
110				plat/hisilicon/hikey960/drivers/ipc/hisi_ipc.c \
111				${HIKEY960_GIC_SOURCES}
112
113ifneq (${TRUSTED_BOARD_BOOT},0)
114
115include drivers/auth/mbedtls/mbedtls_crypto.mk
116include drivers/auth/mbedtls/mbedtls_x509.mk
117
118AUTH_SOURCES		:=	drivers/auth/auth_mod.c			\
119				drivers/auth/crypto_mod.c		\
120				drivers/auth/img_parser_mod.c		\
121				drivers/auth/tbbr/tbbr_cot_common.c
122
123BL1_SOURCES		+=	${AUTH_SOURCES}				\
124				plat/common/tbbr/plat_tbbr.c		\
125				plat/hisilicon/hikey960/hikey960_tbbr.c	\
126				plat/hisilicon/hikey960/hikey960_rotpk.S \
127				drivers/auth/tbbr/tbbr_cot_bl1.c
128
129BL2_SOURCES		+=	${AUTH_SOURCES}				\
130				plat/common/tbbr/plat_tbbr.c		\
131				plat/hisilicon/hikey960/hikey960_tbbr.c	\
132				plat/hisilicon/hikey960/hikey960_rotpk.S \
133				drivers/auth/tbbr/tbbr_cot_bl2.c
134
135ROT_KEY		=	$(BUILD_PLAT)/rot_key.pem
136ROTPK_HASH		=	$(BUILD_PLAT)/rotpk_sha256.bin
137
138$(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
139$(BUILD_PLAT)/bl1/hikey960_rotpk.o: $(ROTPK_HASH)
140$(BUILD_PLAT)/bl2/hikey960_rotpk.o: $(ROTPK_HASH)
141
142certificates: $(ROT_KEY)
143$(ROT_KEY): | $(BUILD_PLAT)
144	@echo "  OPENSSL $@"
145	$(Q)openssl genrsa 2048 > $@ 2>/dev/null
146
147$(ROTPK_HASH): $(ROT_KEY)
148	@echo "  OPENSSL $@"
149	$(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
150	openssl dgst -sha256 -binary > $@ 2>/dev/null
151endif
152
153# Enable workarounds for selected Cortex-A53 errata.
154ERRATA_A53_836870		:=	1
155ERRATA_A53_843419		:=	1
156ERRATA_A53_855873		:=	1
157
158FIP_ALIGN			:=	512
159