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 | |
Pali Rohár | 3666d48 | 2020-10-29 16:50:19 +0100 | [diff] [blame] | 18 | include plat/marvell/marvell.mk |
| 19 | |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 20 | #*********** A3700 ************* |
Pali Rohár | 8a93658 | 2020-10-15 13:50:28 +0200 | [diff] [blame] | 21 | |
| 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 |
| 29 | include drivers/arm/gic/v3/gicv3.mk |
| 30 | |
| 31 | MARVELL_GIC_SOURCES := ${GICV3_SOURCES} \ |
| 32 | plat/common/plat_gicv3.c |
| 33 | |
| 34 | PLAT_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 | |
| 40 | PLAT_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 | |
| 44 | BL1_SOURCES += $(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \ |
| 45 | lib/cpus/aarch64/cortex_a53.S |
| 46 | |
| 47 | BL31_PORTING_SOURCES := $(PLAT_FAMILY_BASE)/$(PLAT)/board/pm_src.c |
| 48 | |
| 49 | MARVELL_DRV := $(MARVELL_DRV_BASE)/comphy/phy-comphy-3700.c |
| 50 | |
| 51 | BL31_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 | |
| 67 | ifneq (${WTP},) |
| 68 | |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 69 | DOIMAGEPATH := $(WTP) |
Pali Rohár | e3b8176 | 2020-10-29 16:44:45 +0100 | [diff] [blame] | 70 | DOIMAGETOOL := $(DOIMAGEPATH)/wtptp/src/TBB_Linux/release/TBB_linux |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 71 | |
| 72 | ifeq ($(MARVELL_SECURE_BOOT),1) |
| 73 | DOIMAGE_CFG := $(DOIMAGEPATH)/atf-tim.txt |
| 74 | IMAGESPATH := $(DOIMAGEPATH)/tim/trusted |
| 75 | |
| 76 | TIMNCFG := $(DOIMAGEPATH)/atf-timN.txt |
| 77 | TIMNSIG := $(IMAGESPATH)/timnsign.txt |
| 78 | TIM2IMGARGS := -i $(DOIMAGE_CFG) -n $(TIMNCFG) |
| 79 | TIMN_IMAGE := $$(grep "Image Filename:" -m 1 $(TIMNCFG) | cut -c 17-) |
| 80 | else #MARVELL_SECURE_BOOT |
| 81 | DOIMAGE_CFG := $(DOIMAGEPATH)/atf-ntim.txt |
| 82 | IMAGESPATH := $(DOIMAGEPATH)/tim/untrusted |
| 83 | TIM2IMGARGS := -i $(DOIMAGE_CFG) |
| 84 | endif #MARVELL_SECURE_BOOT |
| 85 | |
| 86 | TIMBUILD := $(DOIMAGEPATH)/script/buildtim.sh |
| 87 | TIM2IMG := $(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. |
| 92 | WTMI_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. |
| 98 | WTMI_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). |
| 102 | WTMI_MULTI_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi.bin |
| 103 | |
| 104 | WTMI_ENC_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi-enc.bin |
| 105 | BUILD_UART := uart-images |
| 106 | |
| 107 | SRCPATH := $(dir $(BL33)) |
| 108 | |
| 109 | CLOCKSPRESET ?= CPU_800_DDR_800 |
| 110 | |
| 111 | DDR_TOPOLOGY ?= 0 |
| 112 | |
| 113 | BOOTDEV ?= SPINOR |
| 114 | PARTNUM ?= 0 |
| 115 | |
| 116 | TIM_IMAGE := $$(grep "Image Filename:" -m 1 $(DOIMAGE_CFG) | cut -c 17-) |
| 117 | TIMBLDARGS := $(MARVELL_SECURE_BOOT) $(BOOTDEV) $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \ |
| 118 | $(DDR_TOPOLOGY) $(PARTNUM) $(DEBUG) $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 1 |
| 119 | TIMBLDUARTARGS := $(MARVELL_SECURE_BOOT) UART $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \ |
| 120 | $(DDR_TOPOLOGY) 0 0 $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 0 |
| 121 | DOIMAGE_FLAGS := -r $(DOIMAGE_CFG) -v -D |
| 122 | |
Pali Rohár | e3b8176 | 2020-10-29 16:44:45 +0100 | [diff] [blame] | 123 | $(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ár | 3666d48 | 2020-10-29 16:50:19 +0100 | [diff] [blame] | 128 | mrvl_flash: ${BUILD_PLAT}/${BOOT_IMAGE} ${DOIMAGETOOL} |
Pali Rohár | 6dca2c6 | 2020-10-21 11:50:40 +0200 | [diff] [blame] | 129 | $(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 Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 131 | @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) |
| 136 | ifeq ($(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) |
| 139 | endif |
| 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 Porotchkin | 434074b | 2019-10-24 10:48:08 +0300 | [diff] [blame] | 147 | @tar czf $(BUILD_PLAT)/$(BUILD_UART).tgz.bin -C $(BUILD_PLAT) ./$(BUILD_UART) |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 148 | @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) |
| 153 | ifeq ($(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ár | e5cbb04 | 2020-11-23 19:19:04 +0100 | [diff] [blame] | 159 | @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 Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 162 | -out $(WTMI_ENC_IMG) \ |
Konstantin Porotchkin | 4eb9bc4 | 2018-11-06 18:10:33 +0200 | [diff] [blame] | 163 | -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \ |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 164 | -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 Porotchkin | 4eb9bc4 | 2018-11-06 18:10:33 +0200 | [diff] [blame] | 168 | -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \ |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 169 | -iv `cat $(IMAGESPATH)/iv.txt` -p |
| 170 | endif |
| 171 | $(DOIMAGETOOL) $(DOIMAGE_FLAGS) |
| 172 | @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi |
| 173 | @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 |
| 174 | $(TIM2IMG) $(TIM2IMGARGS) -o $(BUILD_PLAT)/$(FLASH_IMAGE) |
Pali Rohár | 4b8f133 | 2020-11-23 19:22:37 +0100 | [diff] [blame^] | 175 | @mv -t $(BUILD_PLAT) $(TIM_IMAGE) $(DOIMAGE_CFG) $(TIMN_IMAGE) $(TIMNCFG) |
| 176 | @cp -t $(BUILD_PLAT) $(WTMI_IMG) $(WTMI_SYSINIT_IMG) $(WTMI_MULTI_IMG) |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 177 | @if [ "$(MARVELL_SECURE_BOOT)" = "1" ]; then mv -t $(BUILD_PLAT) $(WTMI_ENC_IMG) OtpHash.txt; fi |
| 178 | @find . -name "*.txt" | grep -E "CSK[[:alnum:]]_KeyHash.txt|Tim_msg.txt|TIMHash.txt" | xargs rm -f |
Pali Rohár | 8a93658 | 2020-10-15 13:50:28 +0200 | [diff] [blame] | 179 | |
| 180 | else # ${WTP} |
| 181 | |
| 182 | mrvl_flash: |
| 183 | $(error "Platform '${PLAT}' for target '$@' requires WTP. Please set WTP to point to the right directory") |
| 184 | |
| 185 | endif # ${WTP} |