blob: 437f5d050b81e9966515bc671a144625e4d064be [file] [log] [blame]
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +03001#
2# Copyright (C) 2018 Marvell International Ltd.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5# https://spdx.org/licenses
6#
7
Grzegorz Jaszczyk3039bce2019-11-05 13:14:59 +01008MARVELL_PLAT_BASE := plat/marvell/armada
9MARVELL_PLAT_INCLUDE_BASE := include/plat/marvell/armada
Marcin Wojtas45f16552020-06-18 19:50:47 +020010PLAT_FAMILY := a3k
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030011PLAT_FAMILY_BASE := $(MARVELL_PLAT_BASE)/$(PLAT_FAMILY)
12PLAT_INCLUDE_BASE := $(MARVELL_PLAT_INCLUDE_BASE)/$(PLAT_FAMILY)
13PLAT_COMMON_BASE := $(PLAT_FAMILY_BASE)/common
14MARVELL_DRV_BASE := drivers/marvell
15MARVELL_COMMON_BASE := $(MARVELL_PLAT_BASE)/common
Remi Pommarel07e1e9e2019-07-14 20:49:12 +020016HANDLE_EA_EL3_FIRST := 1
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030017
Pali Rohár3666d482020-10-29 16:50:19 +010018include plat/marvell/marvell.mk
19
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030020#*********** A3700 *************
Pali Rohár8a936582020-10-15 13:50:28 +020021
22# GICV3
23$(eval $(call add_define,CONFIG_GICV3))
24
25# CCI-400
26$(eval $(call add_define,USE_CCI))
27
28# Include GICv3 driver files
29include drivers/arm/gic/v3/gicv3.mk
30
31MARVELL_GIC_SOURCES := ${GICV3_SOURCES} \
32 plat/common/plat_gicv3.c
33
34PLAT_INCLUDES := -I$(PLAT_FAMILY_BASE)/$(PLAT) \
35 -I$(PLAT_COMMON_BASE)/include \
36 -I$(PLAT_INCLUDE_BASE)/common \
37 -I$(MARVELL_DRV_BASE) \
38 -I$/drivers/arm/gic/common/
39
40PLAT_BL_COMMON_SOURCES := $(PLAT_COMMON_BASE)/aarch64/a3700_common.c \
41 $(MARVELL_COMMON_BASE)/marvell_cci.c \
42 $(MARVELL_DRV_BASE)/uart/a3700_console.S
43
44BL1_SOURCES += $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
45 lib/cpus/aarch64/cortex_a53.S
46
47BL31_PORTING_SOURCES := $(PLAT_FAMILY_BASE)/$(PLAT)/board/pm_src.c
48
49MARVELL_DRV := $(MARVELL_DRV_BASE)/comphy/phy-comphy-3700.c
50
51BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
52 $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
53 $(PLAT_COMMON_BASE)/plat_pm.c \
54 $(PLAT_COMMON_BASE)/dram_win.c \
55 $(PLAT_COMMON_BASE)/io_addr_dec.c \
56 $(PLAT_COMMON_BASE)/marvell_plat_config.c \
57 $(PLAT_COMMON_BASE)/a3700_ea.c \
58 $(PLAT_FAMILY_BASE)/$(PLAT)/plat_bl31_setup.c \
59 $(MARVELL_COMMON_BASE)/marvell_ddr_info.c \
60 $(MARVELL_COMMON_BASE)/marvell_gicv3.c \
61 $(MARVELL_GIC_SOURCES) \
62 drivers/arm/cci/cci.c \
63 $(BL31_PORTING_SOURCES) \
64 $(PLAT_COMMON_BASE)/a3700_sip_svc.c \
65 $(MARVELL_DRV)
66
67ifneq (${WTP},)
68
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030069DOIMAGEPATH := $(WTP)
Pali Roháre3b81762020-10-29 16:44:45 +010070DOIMAGETOOL := $(DOIMAGEPATH)/wtptp/src/TBB_Linux/release/TBB_linux
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030071
72ifeq ($(MARVELL_SECURE_BOOT),1)
73DOIMAGE_CFG := $(DOIMAGEPATH)/atf-tim.txt
74IMAGESPATH := $(DOIMAGEPATH)/tim/trusted
75
76TIMNCFG := $(DOIMAGEPATH)/atf-timN.txt
77TIMNSIG := $(IMAGESPATH)/timnsign.txt
78TIM2IMGARGS := -i $(DOIMAGE_CFG) -n $(TIMNCFG)
79TIMN_IMAGE := $$(grep "Image Filename:" -m 1 $(TIMNCFG) | cut -c 17-)
80else #MARVELL_SECURE_BOOT
81DOIMAGE_CFG := $(DOIMAGEPATH)/atf-ntim.txt
82IMAGESPATH := $(DOIMAGEPATH)/tim/untrusted
83TIM2IMGARGS := -i $(DOIMAGE_CFG)
84endif #MARVELL_SECURE_BOOT
85
86TIMBUILD := $(DOIMAGEPATH)/script/buildtim.sh
87TIM2IMG := $(DOIMAGEPATH)/script/tim2img.pl
88
89# WTMI_IMG is used to specify the customized RTOS image running over
90# Service CPU (CM3 processor). By the default, it points to a
91# baremetal binary of fuse programming in A3700_utils.
92WTMI_IMG := $(DOIMAGEPATH)/wtmi/fuse/build/fuse.bin
93
94# WTMI_SYSINIT_IMG is used for the system early initialization,
95# such as AVS settings, clock-tree setup and dynamic DDR PHY training.
96# After the initialization is done, this image will be wiped out
97# from the memory and CM3 will continue with RTOS image or other application.
98WTMI_SYSINIT_IMG := $(DOIMAGEPATH)/wtmi/sys_init/build/sys_init.bin
99
100# WTMI_MULTI_IMG is composed of CM3 RTOS image (WTMI_IMG)
101# and sys-init image (WTMI_SYSINIT_IMG).
102WTMI_MULTI_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi.bin
103
Pali Rohárf7516d82020-11-23 19:34:43 +0100104WTMI_ENC_IMG := $(BUILD_PLAT)/wtmi-enc.bin
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300105BUILD_UART := uart-images
106
107SRCPATH := $(dir $(BL33))
108
109CLOCKSPRESET ?= CPU_800_DDR_800
110
111DDR_TOPOLOGY ?= 0
112
113BOOTDEV ?= SPINOR
114PARTNUM ?= 0
115
116TIM_IMAGE := $$(grep "Image Filename:" -m 1 $(DOIMAGE_CFG) | cut -c 17-)
117TIMBLDARGS := $(MARVELL_SECURE_BOOT) $(BOOTDEV) $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \
118 $(DDR_TOPOLOGY) $(PARTNUM) $(DEBUG) $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 1
119TIMBLDUARTARGS := $(MARVELL_SECURE_BOOT) UART $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \
120 $(DDR_TOPOLOGY) 0 0 $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 0
121DOIMAGE_FLAGS := -r $(DOIMAGE_CFG) -v -D
122
Pali Roháre3b81762020-10-29 16:44:45 +0100123$(DOIMAGETOOL):
124 $(if $(value CRYPTOPP_PATH),,$(error "Platform '${PLAT}' for WTP image tool requires CRYPTOPP_PATH. Please set CRYPTOPP_PATH to point to the right directory"))
125 $(Q)$(MAKE) --no-print-directory -C $(CRYPTOPP_PATH) -f GNUmakefile
126 $(Q)$(MAKE) --no-print-directory -C $(DOIMAGEPATH)/wtptp/src/TBB_Linux -f TBB_linux.mak LIBDIR=$(CRYPTOPP_PATH)
127
Pali Rohár3666d482020-10-29 16:50:19 +0100128mrvl_flash: ${BUILD_PLAT}/${BOOT_IMAGE} ${DOIMAGETOOL}
Pali Rohár6dca2c62020-10-21 11:50:40 +0200129 $(if $(value MV_DDR_PATH),,$(error "Platform '${PLAT}' for target '$@' requires MV_DDR_PATH. Please set MV_DDR_PATH to point to the right directory"))
130 ${Q}${MAKE} --no-print-directory -C ${DOIMAGEPATH} WTMI_IMG=$(WTMI_IMG) MV_DDR_PATH=$(MV_DDR_PATH)
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300131 @echo
132 @echo "Building uart images"
133 $(TIMBUILD) $(TIMBLDUARTARGS)
134 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(DOIMAGE_CFG)
135 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(DOIMAGE_CFG)
136ifeq ($(MARVELL_SECURE_BOOT),1)
137 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(TIMNCFG)
138 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(TIMNCFG)
139endif
140 $(DOIMAGETOOL) $(DOIMAGE_FLAGS)
141 @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi
142 @rm -rf $(BUILD_PLAT)/$(BUILD_UART)*
143 @mkdir $(BUILD_PLAT)/$(BUILD_UART)
144 @mv -t $(BUILD_PLAT)/$(BUILD_UART) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG)
145 @find . -name "*_h.*" |xargs cp -ut $(BUILD_PLAT)/$(BUILD_UART)
146 @mv $(subst .bin,_h.bin,$(WTMI_MULTI_IMG)) $(BUILD_PLAT)/$(BUILD_UART)/wtmi_h.bin
Konstantin Porotchkin434074b2019-10-24 10:48:08 +0300147 @tar czf $(BUILD_PLAT)/$(BUILD_UART).tgz.bin -C $(BUILD_PLAT) ./$(BUILD_UART)
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300148 @echo
149 @echo "Building flash image"
150 $(TIMBUILD) $(TIMBLDARGS)
151 sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(DOIMAGE_CFG)
152 sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(DOIMAGE_CFG)
153ifeq ($(MARVELL_SECURE_BOOT),1)
154 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(TIMNCFG)
155 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(TIMNCFG)
156 @echo -e "\n\t=======================================================\n";
157 @echo -e "\t Secure boot. Encrypting wtmi and boot-image \n";
158 @echo -e "\t=======================================================\n";
Pali Roháre5cbb042020-11-23 19:19:04 +0100159 @cp $(WTMI_MULTI_IMG) $(BUILD_PLAT)/wtmi-align.bin
160 @truncate -s %16 $(BUILD_PLAT)/wtmi-align.bin
161 @openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/wtmi-align.bin \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300162 -out $(WTMI_ENC_IMG) \
Konstantin Porotchkin4eb9bc42018-11-06 18:10:33 +0200163 -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300164 -iv `cat $(IMAGESPATH)/iv.txt` -p
165 @truncate -s %16 $(BUILD_PLAT)/$(BOOT_IMAGE);
166 @openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/$(BOOT_IMAGE) \
167 -out $(BUILD_PLAT)/$(BOOT_ENC_IMAGE) \
Konstantin Porotchkin4eb9bc42018-11-06 18:10:33 +0200168 -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300169 -iv `cat $(IMAGESPATH)/iv.txt` -p
170endif
171 $(DOIMAGETOOL) $(DOIMAGE_FLAGS)
172 @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi
Pali Rohár7c4142c2020-11-23 19:37:28 +0100173ifeq ($(MARVELL_SECURE_BOOT),1)
174 @sed -i 's|$(WTMI_MULTI_IMG)|$(WTMI_ENC_IMG)|1;s|$(BOOT_IMAGE)|$(BOOT_ENC_IMAGE)|1;' $(TIMNCFG)
175endif
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300176 $(TIM2IMG) $(TIM2IMGARGS) -o $(BUILD_PLAT)/$(FLASH_IMAGE)
Pali Rohár4b8f1332020-11-23 19:22:37 +0100177 @mv -t $(BUILD_PLAT) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG)
178 @cp -t $(BUILD_PLAT) $(WTMI_IMG) $(WTMI_SYSINIT_IMG) $(WTMI_MULTI_IMG)
Pali Rohár7c4142c2020-11-23 19:37:28 +0100179ifeq ($(MARVELL_SECURE_BOOT),1)
180 @mv -t $(BUILD_PLAT) OtpHash.txt
181endif
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300182 @find . -name "*.txt" | grep -E "CSK[[:alnum:]]_KeyHash.txt|Tim_msg.txt|TIMHash.txt" | xargs rm -f
Pali Rohár8a936582020-10-15 13:50:28 +0200183
184else # ${WTP}
185
186mrvl_flash:
187 $(error "Platform '${PLAT}' for target '$@' requires WTP. Please set WTP to point to the right directory")
188
189endif # ${WTP}