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 | |
Pali Rohár | 0233cd4 | 2020-12-03 12:00:47 +0100 | [diff] [blame] | 67 | ifdef WTP |
Pali Rohár | 8a93658 | 2020-10-15 13:50:28 +0200 | [diff] [blame] | 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 |
Pali Rohár | a6ac1fb | 2020-11-23 19:49:23 +0100 | [diff] [blame] | 88 | TIMDDRTOOL := $(DOIMAGEPATH)/tim/ddr/ddr_tool |
| 89 | |
| 90 | $(TIMBUILD): $(TIMDDRTOOL) |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 91 | |
| 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. |
| 95 | WTMI_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. |
| 101 | WTMI_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). |
| 105 | WTMI_MULTI_IMG := $(DOIMAGEPATH)/wtmi/build/wtmi.bin |
| 106 | |
Pali Rohár | f7516d8 | 2020-11-23 19:34:43 +0100 | [diff] [blame] | 107 | WTMI_ENC_IMG := $(BUILD_PLAT)/wtmi-enc.bin |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 108 | BUILD_UART := uart-images |
| 109 | |
| 110 | SRCPATH := $(dir $(BL33)) |
| 111 | |
| 112 | CLOCKSPRESET ?= CPU_800_DDR_800 |
| 113 | |
| 114 | DDR_TOPOLOGY ?= 0 |
| 115 | |
| 116 | BOOTDEV ?= SPINOR |
| 117 | PARTNUM ?= 0 |
| 118 | |
| 119 | TIM_IMAGE := $$(grep "Image Filename:" -m 1 $(DOIMAGE_CFG) | cut -c 17-) |
| 120 | TIMBLDARGS := $(MARVELL_SECURE_BOOT) $(BOOTDEV) $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \ |
| 121 | $(DDR_TOPOLOGY) $(PARTNUM) $(DEBUG) $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 1 |
| 122 | TIMBLDUARTARGS := $(MARVELL_SECURE_BOOT) UART $(IMAGESPATH) $(DOIMAGEPATH) $(CLOCKSPRESET) \ |
| 123 | $(DDR_TOPOLOGY) 0 0 $(DOIMAGE_CFG) $(TIMNCFG) $(TIMNSIG) 0 |
| 124 | DOIMAGE_FLAGS := -r $(DOIMAGE_CFG) -v -D |
| 125 | |
Pali Rohár | 06a38e2 | 2020-11-23 19:45:28 +0100 | [diff] [blame] | 126 | $(DOIMAGETOOL): FORCE |
Pali Rohár | e3b8176 | 2020-10-29 16:44:45 +0100 | [diff] [blame] | 127 | $(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ár | a6ac1fb | 2020-11-23 19:49:23 +0100 | [diff] [blame] | 131 | $(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ár | 06a38e2 | 2020-11-23 19:45:28 +0100 | [diff] [blame] | 138 | .PHONY: mrvl_flash |
Pali Rohár | a6ac1fb | 2020-11-23 19:49:23 +0100 | [diff] [blame] | 139 | mrvl_flash: ${BUILD_PLAT}/${BOOT_IMAGE} ${WTMI_MULTI_IMG} ${DOIMAGETOOL} ${TIMBUILD} |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 140 | @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) |
| 145 | ifeq ($(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) |
| 148 | endif |
| 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 Porotchkin | 434074b | 2019-10-24 10:48:08 +0300 | [diff] [blame] | 156 | @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] | 157 | @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) |
| 162 | ifeq ($(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ár | e5cbb04 | 2020-11-23 19:19:04 +0100 | [diff] [blame] | 168 | @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 Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 171 | -out $(WTMI_ENC_IMG) \ |
Konstantin Porotchkin | 4eb9bc4 | 2018-11-06 18:10:33 +0200 | [diff] [blame] | 172 | -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \ |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 173 | -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 Porotchkin | 4eb9bc4 | 2018-11-06 18:10:33 +0200 | [diff] [blame] | 177 | -K `cat $(IMAGESPATH)/aes-256.txt` -nosalt \ |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 178 | -iv `cat $(IMAGESPATH)/iv.txt` -p |
| 179 | endif |
| 180 | $(DOIMAGETOOL) $(DOIMAGE_FLAGS) |
| 181 | @if [ -e "$(TIMNCFG)" ]; then $(DOIMAGETOOL) -r $(TIMNCFG); fi |
Pali Rohár | 7c4142c | 2020-11-23 19:37:28 +0100 | [diff] [blame] | 182 | ifeq ($(MARVELL_SECURE_BOOT),1) |
| 183 | @sed -i 's|$(WTMI_MULTI_IMG)|$(WTMI_ENC_IMG)|1;s|$(BOOT_IMAGE)|$(BOOT_ENC_IMAGE)|1;' $(TIMNCFG) |
| 184 | endif |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 185 | $(TIM2IMG) $(TIM2IMGARGS) -o $(BUILD_PLAT)/$(FLASH_IMAGE) |
Pali Rohár | 4b8f133 | 2020-11-23 19:22:37 +0100 | [diff] [blame] | 186 | @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ár | 7c4142c | 2020-11-23 19:37:28 +0100 | [diff] [blame] | 188 | ifeq ($(MARVELL_SECURE_BOOT),1) |
| 189 | @mv -t $(BUILD_PLAT) OtpHash.txt |
| 190 | endif |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 191 | @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] | 192 | |
Pali Rohár | 06a38e2 | 2020-11-23 19:45:28 +0100 | [diff] [blame] | 193 | clean realclean distclean: mrvl_clean |
| 194 | |
| 195 | .PHONY: mrvl_clean |
| 196 | mrvl_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 |
| 199 | ifdef CRYPTOPP_PATH |
| 200 | -$(Q)$(MAKE) --no-print-directory -C $(CRYPTOPP_PATH) -f GNUmakefile clean |
| 201 | endif |
| 202 | |
Pali Rohár | 0233cd4 | 2020-12-03 12:00:47 +0100 | [diff] [blame] | 203 | else # WTP |
Pali Rohár | 8a93658 | 2020-10-15 13:50:28 +0200 | [diff] [blame] | 204 | |
Pali Rohár | 06a38e2 | 2020-11-23 19:45:28 +0100 | [diff] [blame] | 205 | .PHONY: mrvl_flash |
Pali Rohár | 8a93658 | 2020-10-15 13:50:28 +0200 | [diff] [blame] | 206 | mrvl_flash: |
| 207 | $(error "Platform '${PLAT}' for target '$@' requires WTP. Please set WTP to point to the right directory") |
| 208 | |
Pali Rohár | 0233cd4 | 2020-12-03 12:00:47 +0100 | [diff] [blame] | 209 | endif # WTP |
Pali Rohár | 06a38e2 | 2020-11-23 19:45:28 +0100 | [diff] [blame] | 210 | |
| 211 | .PHONY: FORCE |
| 212 | FORCE:; |