1#
2# Copyright (C) 2016 - 2020 Marvell International Ltd.
3#
4# SPDX-License-Identifier:     BSD-3-Clause
5# https://spdx.org/licenses
6
7PLAT_FAMILY		:= a8k
8PLAT_INCLUDE_BASE	:= include/plat/marvell/armada/$(PLAT_FAMILY)
9PLAT_COMMON_BASE	:= plat/marvell/armada/a8k/common
10MARVELL_DRV_BASE	:= drivers/marvell
11MARVELL_COMMON_BASE	:= plat/marvell/armada/common
12
13MARVELL_SVC_TEST	:= 0
14$(eval $(call add_define,MARVELL_SVC_TEST))
15
16ERRATA_A72_859971	:= 1
17
18# Enable MSS support for a8k family
19MSS_SUPPORT		:= 1
20$(eval $(call add_define,MSS_SUPPORT))
21
22# Disable EL3 cache for power management
23BL31_CACHE_DISABLE	:= 0
24$(eval $(call add_define,BL31_CACHE_DISABLE))
25
26$(eval $(call add_define,PCI_EP_SUPPORT))
27$(eval $(call assert_boolean,PCI_EP_SUPPORT))
28
29AP_NUM			:= 1
30$(eval $(call add_define,AP_NUM))
31
32DOIMAGEPATH		?=	tools/marvell/doimage
33DOIMAGETOOL		?=	${DOIMAGEPATH}/doimage
34
35include plat/marvell/marvell.mk
36include tools/marvell/doimage/doimage.mk
37
38ifeq (${MARVELL_SECURE_BOOT},1)
39DOIMAGE_SEC_FLAGS := -c $(DOIMAGE_SEC)
40DOIMAGE_LIBS_CHECK = \
41        if ! [ -d "/usr/include/mbedtls" ]; then \
42                        echo "****************************************" >&2; \
43                        echo "Missing mbedTLS installation! " >&2; \
44                        echo "Please download it from \"tls.mbed.org\"" >&2; \
45			echo "Alternatively on Debian/Ubuntu system install" >&2; \
46			echo "\"libmbedtls-dev\" package" >&2; \
47                        echo "Make sure to use version 2.1.0 or later" >&2; \
48                        echo "****************************************" >&2; \
49                exit 1; \
50        else if ! [ -f "/usr/include/libconfig.h" ]; then \
51                        echo "********************************************************" >&2; \
52                        echo "Missing Libconfig installation!" >&2; \
53                        echo "Please download it from \"www.hyperrealm.com/libconfig/\"" >&2; \
54                        echo "Alternatively on Debian/Ubuntu system install packages" >&2; \
55                        echo "\"libconfig8\" and \"libconfig8-dev\"" >&2; \
56                        echo "********************************************************" >&2; \
57                exit 1; \
58        fi \
59        fi
60else #MARVELL_SECURE_BOOT
61DOIMAGE_LIBS_CHECK =
62DOIMAGE_SEC_FLAGS =
63endif #MARVELL_SECURE_BOOT
64
65ROM_BIN_EXT ?= $(BUILD_PLAT)/ble.bin
66DOIMAGE_FLAGS	+= -b $(ROM_BIN_EXT) $(NAND_DOIMAGE_FLAGS) $(DOIMAGE_SEC_FLAGS)
67
68# Check whether to build system_power.c for the platform
69ifneq ("$(wildcard $(BOARD_DIR)/board/system_power.c)","")
70SYSTEM_POWER_SUPPORT = 1
71else
72SYSTEM_POWER_SUPPORT = 0
73endif
74
75# This define specifies DDR type for BLE
76$(eval $(call add_define,CONFIG_DDR4))
77
78MARVELL_GIC_SOURCES	:=	drivers/arm/gic/common/gic_common.c	\
79				drivers/arm/gic/v2/gicv2_main.c		\
80				drivers/arm/gic/v2/gicv2_helpers.c	\
81				plat/common/plat_gicv2.c
82
83PLAT_INCLUDES		+=	-I$(BOARD_DIR)				\
84				-I$(BOARD_DIR)/board			\
85				-I$(CURDIR)/drivers/marvell		\
86				-I$(PLAT_COMMON_BASE)/include		\
87				-I$(PLAT_INCLUDE_BASE)/common
88
89PLAT_BL_COMMON_SOURCES	:=	$(PLAT_COMMON_BASE)/aarch64/a8k_common.c \
90				drivers/ti/uart/aarch64/16550_console.S
91
92ifndef BLE_PORTING_SOURCES
93BLE_PORTING_SOURCES	:=	$(BOARD_DIR)/board/dram_port.c \
94				$(BOARD_DIR)/board/marvell_plat_config.c
95endif
96
97MARVELL_MOCHI_DRV	+=	$(MARVELL_DRV_BASE)/mochi/cp110_setup.c
98
99BLE_SOURCES		:=	drivers/mentor/i2c/mi2cv.c		\
100				$(PLAT_COMMON_BASE)/plat_ble_setup.c	\
101				$(MARVELL_MOCHI_DRV)			\
102				$(PLAT_COMMON_BASE)/plat_pm.c		\
103				$(MARVELL_DRV_BASE)/ap807_clocks_init.c	\
104				$(MARVELL_DRV_BASE)/thermal.c		\
105				$(PLAT_COMMON_BASE)/plat_thermal.c	\
106				$(BLE_PORTING_SOURCES)			\
107				$(MARVELL_DRV_BASE)/ccu.c		\
108				$(MARVELL_DRV_BASE)/io_win.c
109
110BL1_SOURCES		+=	$(PLAT_COMMON_BASE)/aarch64/plat_helpers.S \
111				lib/cpus/aarch64/cortex_a72.S
112
113MARVELL_DRV		:= 	$(MARVELL_DRV_BASE)/io_win.c	\
114				$(MARVELL_DRV_BASE)/iob.c	\
115				$(MARVELL_DRV_BASE)/mci.c	\
116				$(MARVELL_DRV_BASE)/amb_adec.c	\
117				$(MARVELL_DRV_BASE)/ccu.c	\
118				$(MARVELL_DRV_BASE)/cache_llc.c	\
119				$(MARVELL_DRV_BASE)/comphy/phy-comphy-cp110.c	\
120				$(MARVELL_DRV_BASE)/mc_trustzone/mc_trustzone.c	\
121				$(MARVELL_DRV_BASE)/secure_dfx_access/armada_thermal.c	\
122				$(MARVELL_DRV_BASE)/secure_dfx_access/misc_dfx.c	\
123				$(MARVELL_DRV_BASE)/ddr_phy_access.c	\
124				drivers/rambus/trng_ip_76.c
125
126ifeq (${MSS_SUPPORT}, 1)
127MARVELL_DRV		+=	$(MARVELL_DRV_BASE)/mg_conf_cm3/mg_conf_cm3.c
128endif
129
130ifndef BL31_PORTING_SOURCES
131BL31_PORTING_SOURCES	:=	$(BOARD_DIR)/board/marvell_plat_config.c
132endif
133
134ifeq ($(SYSTEM_POWER_SUPPORT),1)
135BL31_PORTING_SOURCES	+=	$(BOARD_DIR)/board/system_power.c
136endif
137
138BL31_SOURCES		+=	lib/cpus/aarch64/cortex_a72.S		       \
139				$(PLAT_COMMON_BASE)/aarch64/plat_helpers.S     \
140				$(PLAT_COMMON_BASE)/aarch64/plat_arch_config.c \
141				$(PLAT_COMMON_BASE)/plat_pm.c		       \
142				$(PLAT_COMMON_BASE)/plat_bl31_setup.c	       \
143				$(MARVELL_COMMON_BASE)/marvell_gicv2.c	       \
144				$(MARVELL_COMMON_BASE)/mrvl_sip_svc.c	       \
145				$(MARVELL_COMMON_BASE)/marvell_ddr_info.c      \
146				$(BL31_PORTING_SOURCES)			       \
147				$(MARVELL_DRV)				       \
148				$(MARVELL_MOCHI_DRV)			       \
149				$(MARVELL_GIC_SOURCES)
150
151# Add trace functionality for PM
152BL31_SOURCES		+=	$(PLAT_COMMON_BASE)/plat_pm_trace.c
153
154
155ifeq (${MSS_SUPPORT}, 1)
156# Force builds with BL2 image on a80x0 platforms
157ifndef SCP_BL2
158 $(error "Error: SCP_BL2 image is mandatory for a8k family")
159endif
160
161# MSS (SCP) build
162include $(PLAT_COMMON_BASE)/mss/mss_a8k.mk
163endif
164
165# BLE (ROM context execution code, AKA binary extension)
166BLE_PATH	?=  $(PLAT_COMMON_BASE)/ble
167
168include ${BLE_PATH}/ble.mk
169$(eval $(call MAKE_BL,e))
170
171clean realclean distclean: mrvl_clean
172
173.PHONY: mrvl_clean
174mrvl_clean:
175	@echo "  Doimage CLEAN"
176	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${DOIMAGEPATH} clean
177
178${DOIMAGETOOL}: FORCE
179	@$(DOIMAGE_LIBS_CHECK)
180	${Q}${MAKE} --no-print-directory -C ${DOIMAGEPATH}
181
182${BUILD_PLAT}/${FLASH_IMAGE}: ${ROM_BIN_EXT} ${BUILD_PLAT}/${BOOT_IMAGE} ${DOIMAGETOOL}
183	@${ECHO_BLANK_LINE}
184	@echo "Building flash image"
185	${Q}${DOIMAGETOOL} ${DOIMAGE_FLAGS} ${BUILD_PLAT}/${BOOT_IMAGE} ${BUILD_PLAT}/${FLASH_IMAGE}
186	@${ECHO_BLANK_LINE}
187	@echo "Built $@ successfully"
188	@${ECHO_BLANK_LINE}
189