blob: e2022fac7fea0615b2f509dc9257061c0b1ea06c [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
Pali Rohár0233cd42020-12-03 12:00:47 +010067ifdef WTP
Pali Rohár8a936582020-10-15 13:50:28 +020068
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
Pali Rohára6ac1fb2020-11-23 19:49:23 +010088TIMDDRTOOL := $(DOIMAGEPATH)/tim/ddr/ddr_tool
89
90$(TIMBUILD): $(TIMDDRTOOL)
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030091
92# WTMI_IMG is used to specify the customized RTOS image running over
93# Service CPU (CM3 processor). By the default, it points to a
94# baremetal binary of fuse programming in A3700_utils.
95WTMI_IMG := $(DOIMAGEPATH)/wtmi/fuse/build/fuse.bin
96
97# WTMI_SYSINIT_IMG is used for the system early initialization,
98# such as AVS settings, clock-tree setup and dynamic DDR PHY training.
99# After the initialization is done, this image will be wiped out
100# from the memory and CM3 will continue with RTOS image or other application.
101WTMI_SYSINIT_IMG := $(DOIMAGEPATH)/wtmi/sys_init/build/sys_init.bin
102
103# WTMI_MULTI_IMG is composed of CM3 RTOS image (WTMI_IMG)
104# and sys-init image (WTMI_SYSINIT_IMG).
105WTMI_MULTI_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi.bin
106
Pali Rohárf7516d82020-11-23 19:34:43 +0100107WTMI_ENC_IMG := $(BUILD_PLAT)/wtmi-enc.bin
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300108BUILD_UART := uart-images
109
110SRCPATH := $(dir $(BL33))
111
112CLOCKSPRESET ?= CPU_800_DDR_800
113
114DDR_TOPOLOGY ?= 0
115
116BOOTDEV ?= SPINOR
117PARTNUM ?= 0
118
119TIM_IMAGE := $$(grep "Image Filename:" -m 1 $(DOIMAGE_CFG) | cut -c 17-)
120TIMBLDARGS := $(MARVELL_SECURE_BOOT) $(BOOTDEV) $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \
121 $(DDR_TOPOLOGY) $(PARTNUM) $(DEBUG) $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 1
122TIMBLDUARTARGS := $(MARVELL_SECURE_BOOT) UART $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \
123 $(DDR_TOPOLOGY) 0 0 $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 0
124DOIMAGE_FLAGS := -r $(DOIMAGE_CFG) -v -D
125
Pali Rohár06a38e22020-11-23 19:45:28 +0100126$(DOIMAGETOOL): FORCE
Pali Roháre3b81762020-10-29 16:44:45 +0100127 $(if $(value CRYPTOPP_PATH),,$(error "Platform '${PLAT}' for WTP image tool requires CRYPTOPP_PATH. Please set CRYPTOPP_PATH to point to the right directory"))
128 $(Q)$(MAKE) --no-print-directory -C $(CRYPTOPP_PATH) -f GNUmakefile
129 $(Q)$(MAKE) --no-print-directory -C $(DOIMAGEPATH)/wtptp/src/TBB_Linux -f TBB_linux.mak LIBDIR=$(CRYPTOPP_PATH)
130
Pali Rohára6ac1fb2020-11-23 19:49:23 +0100131$(WTMI_MULTI_IMG): FORCE
132 $(Q)$(MAKE) --no-print-directory -C $(DOIMAGEPATH) WTMI_IMG=$(WTMI_IMG) WTMI
133
134$(TIMDDRTOOL): FORCE
135 $(if $(value MV_DDR_PATH),,$(error "Platform '${PLAT}' for ddr tool requires MV_DDR_PATH. Please set MV_DDR_PATH to point to the right directory"))
136 $(Q)$(MAKE) --no-print-directory -C $(DOIMAGEPATH) MV_DDR_PATH=$(MV_DDR_PATH) mv_ddr
137
Pali Rohár06a38e22020-11-23 19:45:28 +0100138.PHONY: mrvl_flash
Pali Rohára6ac1fb2020-11-23 19:49:23 +0100139mrvl_flash: ${BUILD_PLAT}/${BOOT_IMAGE} ${WTMI_MULTI_IMG} ${DOIMAGETOOL} ${TIMBUILD}
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300140 @echo
141 @echo "Building uart images"
142 $(TIMBUILD) $(TIMBLDUARTARGS)
143 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(DOIMAGE_CFG)
144 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(DOIMAGE_CFG)
145ifeq ($(MARVELL_SECURE_BOOT),1)
146 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(TIMNCFG)
147 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(TIMNCFG)
148endif
149 $(DOIMAGETOOL) $(DOIMAGE_FLAGS)
150 @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi
151 @rm -rf $(BUILD_PLAT)/$(BUILD_UART)*
152 @mkdir $(BUILD_PLAT)/$(BUILD_UART)
153 @mv -t $(BUILD_PLAT)/$(BUILD_UART) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG)
154 @find . -name "*_h.*" |xargs cp -ut $(BUILD_PLAT)/$(BUILD_UART)
155 @mv $(subst .bin,_h.bin,$(WTMI_MULTI_IMG)) $(BUILD_PLAT)/$(BUILD_UART)/wtmi_h.bin
Konstantin Porotchkin434074b2019-10-24 10:48:08 +0300156 @tar czf $(BUILD_PLAT)/$(BUILD_UART).tgz.bin -C $(BUILD_PLAT) ./$(BUILD_UART)
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300157 @echo
158 @echo "Building flash image"
159 $(TIMBUILD) $(TIMBLDARGS)
160 sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(DOIMAGE_CFG)
161 sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(DOIMAGE_CFG)
162ifeq ($(MARVELL_SECURE_BOOT),1)
163 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(TIMNCFG)
164 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(TIMNCFG)
165 @echo -e "\n\t=======================================================\n";
166 @echo -e "\t Secure boot. Encrypting wtmi and boot-image \n";
167 @echo -e "\t=======================================================\n";
Pali Roháre5cbb042020-11-23 19:19:04 +0100168 @cp $(WTMI_MULTI_IMG) $(BUILD_PLAT)/wtmi-align.bin
169 @truncate -s %16 $(BUILD_PLAT)/wtmi-align.bin
170 @openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/wtmi-align.bin \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300171 -out $(WTMI_ENC_IMG) \
Konstantin Porotchkin4eb9bc42018-11-06 18:10:33 +0200172 -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300173 -iv `cat $(IMAGESPATH)/iv.txt` -p
174 @truncate -s %16 $(BUILD_PLAT)/$(BOOT_IMAGE);
175 @openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/$(BOOT_IMAGE) \
176 -out $(BUILD_PLAT)/$(BOOT_ENC_IMAGE) \
Konstantin Porotchkin4eb9bc42018-11-06 18:10:33 +0200177 -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300178 -iv `cat $(IMAGESPATH)/iv.txt` -p
179endif
180 $(DOIMAGETOOL) $(DOIMAGE_FLAGS)
181 @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi
Pali Rohár7c4142c2020-11-23 19:37:28 +0100182ifeq ($(MARVELL_SECURE_BOOT),1)
183 @sed -i 's|$(WTMI_MULTI_IMG)|$(WTMI_ENC_IMG)|1;s|$(BOOT_IMAGE)|$(BOOT_ENC_IMAGE)|1;' $(TIMNCFG)
184endif
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300185 $(TIM2IMG) $(TIM2IMGARGS) -o $(BUILD_PLAT)/$(FLASH_IMAGE)
Pali Rohár4b8f1332020-11-23 19:22:37 +0100186 @mv -t $(BUILD_PLAT) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG)
187 @cp -t $(BUILD_PLAT) $(WTMI_IMG) $(WTMI_SYSINIT_IMG) $(WTMI_MULTI_IMG)
Pali Rohár7c4142c2020-11-23 19:37:28 +0100188ifeq ($(MARVELL_SECURE_BOOT),1)
189 @mv -t $(BUILD_PLAT) OtpHash.txt
190endif
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300191 @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 +0200192
Pali Rohár06a38e22020-11-23 19:45:28 +0100193clean realclean distclean: mrvl_clean
194
195.PHONY: mrvl_clean
196mrvl_clean:
197 -$(Q)$(MAKE) --no-print-directory -C $(DOIMAGEPATH) MV_DDR_PATH=$(MV_DDR_PATH) clean
198 -$(Q)$(MAKE) --no-print-directory -C $(DOIMAGEPATH)/wtptp/src/TBB_Linux -f TBB_linux.mak LIBDIR=$(CRYPTOPP_PATH) clean
199ifdef CRYPTOPP_PATH
200 -$(Q)$(MAKE) --no-print-directory -C $(CRYPTOPP_PATH) -f GNUmakefile clean
201endif
202
Pali Rohár0233cd42020-12-03 12:00:47 +0100203else # WTP
Pali Rohár8a936582020-10-15 13:50:28 +0200204
Pali Rohár06a38e22020-11-23 19:45:28 +0100205.PHONY: mrvl_flash
Pali Rohár8a936582020-10-15 13:50:28 +0200206mrvl_flash:
207 $(error "Platform '${PLAT}' for target '$@' requires WTP. Please set WTP to point to the right directory")
208
Pali Rohár0233cd42020-12-03 12:00:47 +0100209endif # WTP
Pali Rohár06a38e22020-11-23 19:45:28 +0100210
211.PHONY: FORCE
212FORCE:;