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