blob: e2ac97ffc9b9eebf63ea9308f34cb41a6417f354 [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
8MARVELL_PLAT_BASE := plat/marvell
9MARVELL_PLAT_INCLUDE_BASE := include/plat/marvell
10PLAT_FAMILY := a3700
11PLAT_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
16
17include $(MARVELL_PLAT_BASE)/marvell.mk
18
19#*********** A3700 *************
20DOIMAGEPATH := $(WTP)
21DOIMAGETOOL := $(DOIMAGEPATH)/wtptp/linux/tbb_linux
22
23ifeq ($(MARVELL_SECURE_BOOT),1)
24DOIMAGE_CFG := $(DOIMAGEPATH)/atf-tim.txt
25IMAGESPATH := $(DOIMAGEPATH)/tim/trusted
26
27TIMNCFG := $(DOIMAGEPATH)/atf-timN.txt
28TIMNSIG := $(IMAGESPATH)/timnsign.txt
29TIM2IMGARGS := -i $(DOIMAGE_CFG) -n $(TIMNCFG)
30TIMN_IMAGE := $$(grep "Image Filename:" -m 1 $(TIMNCFG) | cut -c 17-)
31else #MARVELL_SECURE_BOOT
32DOIMAGE_CFG := $(DOIMAGEPATH)/atf-ntim.txt
33IMAGESPATH := $(DOIMAGEPATH)/tim/untrusted
34TIM2IMGARGS := -i $(DOIMAGE_CFG)
35endif #MARVELL_SECURE_BOOT
36
37TIMBUILD := $(DOIMAGEPATH)/script/buildtim.sh
38TIM2IMG := $(DOIMAGEPATH)/script/tim2img.pl
39
40# WTMI_IMG is used to specify the customized RTOS image running over
41# Service CPU (CM3 processor). By the default, it points to a
42# baremetal binary of fuse programming in A3700_utils.
43WTMI_IMG := $(DOIMAGEPATH)/wtmi/fuse/build/fuse.bin
44
45# WTMI_SYSINIT_IMG is used for the system early initialization,
46# such as AVS settings, clock-tree setup and dynamic DDR PHY training.
47# After the initialization is done, this image will be wiped out
48# from the memory and CM3 will continue with RTOS image or other application.
49WTMI_SYSINIT_IMG := $(DOIMAGEPATH)/wtmi/sys_init/build/sys_init.bin
50
51# WTMI_MULTI_IMG is composed of CM3 RTOS image (WTMI_IMG)
52# and sys-init image (WTMI_SYSINIT_IMG).
53WTMI_MULTI_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi.bin
54
55WTMI_ENC_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi-enc.bin
56BUILD_UART := uart-images
57
58SRCPATH := $(dir $(BL33))
59
60CLOCKSPRESET ?= CPU_800_DDR_800
61
62DDR_TOPOLOGY ?= 0
63
64BOOTDEV ?= SPINOR
65PARTNUM ?= 0
66
67TIM_IMAGE := $$(grep "Image Filename:" -m 1 $(DOIMAGE_CFG) | cut -c 17-)
68TIMBLDARGS := $(MARVELL_SECURE_BOOT) $(BOOTDEV) $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \
69 $(DDR_TOPOLOGY) $(PARTNUM) $(DEBUG) $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 1
70TIMBLDUARTARGS := $(MARVELL_SECURE_BOOT) UART $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \
71 $(DDR_TOPOLOGY) 0 0 $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 0
72DOIMAGE_FLAGS := -r $(DOIMAGE_CFG) -v -D
73
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030074# GICV3
75$(eval $(call add_define,CONFIG_GICV3))
76
77# CCI-400
78$(eval $(call add_define,USE_CCI))
79
80MARVELL_GIC_SOURCES := drivers/arm/gic/common/gic_common.c \
81 drivers/arm/gic/v3/gicv3_main.c \
82 drivers/arm/gic/v3/gicv3_helpers.c \
83 drivers/arm/gic/v3/arm_gicv3_common.c \
84 plat/common/plat_gicv3.c \
85 drivers/arm/gic/v3/gic500.c
86
87ATF_INCLUDES := -Iinclude/common/tbbr \
88 -Iinclude/drivers
89
90PLAT_INCLUDES := -I$(PLAT_FAMILY_BASE)/$(PLAT) \
91 -I$(PLAT_COMMON_BASE)/include \
92 -I$(PLAT_INCLUDE_BASE)/common \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030093 -I$(MARVELL_DRV_BASE) \
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020094 -Iinclude/drivers/marvell/uart \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030095 -I$/drivers/arm/gic/common/ \
96 $(ATF_INCLUDES)
97
98PLAT_BL_COMMON_SOURCES := $(PLAT_COMMON_BASE)/aarch64/a3700_common.c \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +030099 $(MARVELL_COMMON_BASE)/marvell_cci.c \
100 $(MARVELL_DRV_BASE)/uart/a3700_console.S
101
102BL1_SOURCES += $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
103 lib/cpus/aarch64/cortex_a53.S
104
105BL31_PORTING_SOURCES := $(PLAT_FAMILY_BASE)/$(PLAT)/board/pm_src.c
106
107MARVELL_DRV := $(MARVELL_DRV_BASE)/comphy/phy-comphy-3700.c
108
109BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
110 $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
111 $(PLAT_COMMON_BASE)/plat_pm.c \
112 $(PLAT_COMMON_BASE)/dram_win.c \
113 $(PLAT_COMMON_BASE)/io_addr_dec.c \
114 $(PLAT_COMMON_BASE)/marvell_plat_config.c \
115 $(PLAT_FAMILY_BASE)/$(PLAT)/plat_bl31_setup.c \
116 $(MARVELL_COMMON_BASE)/marvell_ddr_info.c \
117 $(MARVELL_COMMON_BASE)/marvell_gicv3.c \
118 $(MARVELL_GIC_SOURCES) \
119 drivers/arm/cci/cci.c \
120 $(BL31_PORTING_SOURCES) \
121 $(PLAT_COMMON_BASE)/a3700_sip_svc.c \
122 $(MARVELL_DRV)
123
124mrvl_flash: ${BUILD_PLAT}/${FIP_NAME} ${DOIMAGETOOL}
125 $(shell truncate -s %128K ${BUILD_PLAT}/bl1.bin)
126 $(shell cat ${BUILD_PLAT}/bl1.bin ${BUILD_PLAT}/${FIP_NAME} > ${BUILD_PLAT}/${BOOT_IMAGE})
127 $(shell truncate -s %4 ${BUILD_PLAT}/${BOOT_IMAGE})
128 $(shell truncate -s %4 $(WTMI_IMG))
129 @echo
130 @echo "Building uart images"
131 $(TIMBUILD) $(TIMBLDUARTARGS)
132 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(DOIMAGE_CFG)
133 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(DOIMAGE_CFG)
134ifeq ($(MARVELL_SECURE_BOOT),1)
135 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(TIMNCFG)
136 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(TIMNCFG)
137endif
138 $(DOIMAGETOOL) $(DOIMAGE_FLAGS)
139 @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi
140 @rm -rf $(BUILD_PLAT)/$(BUILD_UART)*
141 @mkdir $(BUILD_PLAT)/$(BUILD_UART)
142 @mv -t $(BUILD_PLAT)/$(BUILD_UART) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG)
143 @find . -name "*_h.*" |xargs cp -ut $(BUILD_PLAT)/$(BUILD_UART)
144 @mv $(subst .bin,_h.bin,$(WTMI_MULTI_IMG)) $(BUILD_PLAT)/$(BUILD_UART)/wtmi_h.bin
145 @tar czf $(BUILD_PLAT)/$(BUILD_UART).tgz -C $(BUILD_PLAT) ./$(BUILD_UART)
146 @echo
147 @echo "Building flash image"
148 $(TIMBUILD) $(TIMBLDARGS)
149 sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(DOIMAGE_CFG)
150 sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(DOIMAGE_CFG)
151ifeq ($(MARVELL_SECURE_BOOT),1)
152 @sed -i 's|WTMI_IMG|$(WTMI_MULTI_IMG)|1' $(TIMNCFG)
153 @sed -i 's|BOOT_IMAGE|$(BUILD_PLAT)/$(BOOT_IMAGE)|1' $(TIMNCFG)
154 @echo -e "\n\t=======================================================\n";
155 @echo -e "\t Secure boot. Encrypting wtmi and boot-image \n";
156 @echo -e "\t=======================================================\n";
157 @truncate -s %16 $(WTMI_MULTI_IMG)
158 @openssl enc -aes-256-cbc -e -in $(WTMI_MULTI_IMG) \
159 -out $(WTMI_ENC_IMG) \
Konstantin Porotchkin4eb9bc42018-11-06 18:10:33 +0200160 -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300161 -iv `cat $(IMAGESPATH)/iv.txt` -p
162 @truncate -s %16 $(BUILD_PLAT)/$(BOOT_IMAGE);
163 @openssl enc -aes-256-cbc -e -in $(BUILD_PLAT)/$(BOOT_IMAGE) \
164 -out $(BUILD_PLAT)/$(BOOT_ENC_IMAGE) \
Konstantin Porotchkin4eb9bc42018-11-06 18:10:33 +0200165 -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \
Konstantin Porotchkine7be6e22018-10-08 16:53:09 +0300166 -iv `cat $(IMAGESPATH)/iv.txt` -p
167endif
168 $(DOIMAGETOOL) $(DOIMAGE_FLAGS)
169 @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi
170 @if [ "$(MARVELL_SECURE_BOOT)" = "1" ]; then sed -i 's|$(WTMI_MULTI_IMG)|$(WTMI_ENC_IMG)|1;s|$(BOOT_IMAGE)|$(BOOT_ENC_IMAGE)|1;' $(TIMNCFG); fi
171 $(TIM2IMG) $(TIM2IMGARGS) -o $(BUILD_PLAT)/$(FLASH_IMAGE)
172 @mv -t $(BUILD_PLAT) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG) $(WTMI_IMG) $(WTMI_SYSINIT_IMG) $(WTMI_MULTI_IMG)
173 @if [ "$(MARVELL_SECURE_BOOT)" = "1" ]; then mv -t $(BUILD_PLAT) $(WTMI_ENC_IMG) OtpHash.txt; fi
174 @find . -name "*.txt" | grep -E "CSK[[:alnum:]]_KeyHash.txt|Tim_msg.txt|TIMHash.txt" | xargs rm -f