xref: /rk3399_ARM-atf/plat/renesas/rcar/platform.mk (revision fd7b287cbe9147ca9e07dd9f30c49c58bbdd92a8)
1#
2# Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7PROGRAMMABLE_RESET_ADDRESS	:= 0
8COLD_BOOT_SINGLE_CPU		:= 1
9ARM_CCI_PRODUCT_ID		:= 500
10TRUSTED_BOARD_BOOT		:= 1
11RESET_TO_BL31			:= 1
12GENERATE_COT			:= 1
13BL2_AT_EL3			:= 1
14ENABLE_SVE_FOR_NS		:= 0
15
16CRASH_REPORTING			:= 1
17HANDLE_EA_EL3_FIRST		:= 1
18
19$(eval $(call add_define,PLAT_EXTRA_LD_SCRIPT))
20
21ifeq (${SPD},none)
22  SPD_NONE:=1
23  $(eval $(call add_define,SPD_NONE))
24endif
25
26# LSI setting common define
27RCAR_H3:=0
28RCAR_M3:=1
29RCAR_M3N:=2
30RCAR_E3:=3
31RCAR_H3N:=4
32RCAR_D3:=5
33RCAR_V3M:=6
34RCAR_AUTO:=99
35$(eval $(call add_define,RCAR_H3))
36$(eval $(call add_define,RCAR_M3))
37$(eval $(call add_define,RCAR_M3N))
38$(eval $(call add_define,RCAR_E3))
39$(eval $(call add_define,RCAR_H3N))
40$(eval $(call add_define,RCAR_D3))
41$(eval $(call add_define,RCAR_V3M))
42$(eval $(call add_define,RCAR_AUTO))
43RCAR_CUT_10:=0
44RCAR_CUT_11:=1
45RCAR_CUT_13:=3
46RCAR_CUT_20:=10
47RCAR_CUT_30:=20
48$(eval $(call add_define,RCAR_CUT_10))
49$(eval $(call add_define,RCAR_CUT_11))
50$(eval $(call add_define,RCAR_CUT_13))
51$(eval $(call add_define,RCAR_CUT_20))
52$(eval $(call add_define,RCAR_CUT_30))
53
54ifndef LSI
55  $(error "Error: Unknown LSI. Please use LSI=<LSI name> to specify the LSI")
56else
57  ifeq (${LSI},AUTO)
58    RCAR_LSI:=${RCAR_AUTO}
59  else ifeq (${LSI},H3)
60    RCAR_LSI:=${RCAR_H3}
61    ifndef LSI_CUT
62      # enable compatible function.
63      RCAR_LSI_CUT_COMPAT := 1
64      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
65    else
66      # disable compatible function.
67      ifeq (${LSI_CUT},10)
68        RCAR_LSI_CUT:=0
69      else ifeq (${LSI_CUT},11)
70        RCAR_LSI_CUT:=1
71      else ifeq (${LSI_CUT},20)
72        RCAR_LSI_CUT:=10
73      else ifeq (${LSI_CUT},30)
74        RCAR_LSI_CUT:=20
75      else
76        $(error "Error: ${LSI_CUT} is not supported.")
77      endif
78      $(eval $(call add_define,RCAR_LSI_CUT))
79    endif
80  else ifeq (${LSI},H3N)
81    RCAR_LSI:=${RCAR_H3N}
82    ifndef LSI_CUT
83      # enable compatible function.
84      RCAR_LSI_CUT_COMPAT := 1
85      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
86    else
87      # disable compatible function.
88      ifeq (${LSI_CUT},30)
89        RCAR_LSI_CUT:=20
90      else
91        $(error "Error: ${LSI_CUT} is not supported.")
92      endif
93      $(eval $(call add_define,RCAR_LSI_CUT))
94    endif
95  else ifeq (${LSI},M3)
96    RCAR_LSI:=${RCAR_M3}
97    ifndef LSI_CUT
98      # enable compatible function.
99      RCAR_LSI_CUT_COMPAT := 1
100      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
101    else
102      # disable compatible function.
103      ifeq (${LSI_CUT},10)
104        RCAR_LSI_CUT:=0
105      else ifeq (${LSI_CUT},11)
106        RCAR_LSI_CUT:=1
107      else ifeq (${LSI_CUT},13)
108        RCAR_LSI_CUT:=3
109      else ifeq (${LSI_CUT},30)
110        RCAR_LSI_CUT:=20
111      else
112        $(error "Error: ${LSI_CUT} is not supported.")
113      endif
114      $(eval $(call add_define,RCAR_LSI_CUT))
115    endif
116  else ifeq (${LSI},M3N)
117    RCAR_LSI:=${RCAR_M3N}
118    ifndef LSI_CUT
119      # enable compatible function.
120      RCAR_LSI_CUT_COMPAT := 1
121      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
122    else
123      # disable compatible function.
124      ifeq (${LSI_CUT},10)
125        RCAR_LSI_CUT:=0
126      else ifeq (${LSI_CUT},11)
127        RCAR_LSI_CUT:=1
128      else
129        $(error "Error: ${LSI_CUT} is not supported.")
130      endif
131      $(eval $(call add_define,RCAR_LSI_CUT))
132    endif
133  else ifeq (${LSI},E3)
134    RCAR_LSI:=${RCAR_E3}
135    ifndef LSI_CUT
136      # enable compatible function.
137      RCAR_LSI_CUT_COMPAT := 1
138      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
139    else
140      # disable compatible function.
141      ifeq (${LSI_CUT},10)
142        RCAR_LSI_CUT:=0
143      else ifeq (${LSI_CUT},11)
144        RCAR_LSI_CUT:=1
145      else
146        $(error "Error: ${LSI_CUT} is not supported.")
147      endif
148      $(eval $(call add_define,RCAR_LSI_CUT))
149    endif
150  else ifeq (${LSI},D3)
151    RCAR_LSI:=${RCAR_D3}
152    ifndef LSI_CUT
153      # enable compatible function.
154      RCAR_LSI_CUT_COMPAT := 1
155      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
156    else
157      # disable compatible function.
158      ifeq (${LSI_CUT},10)
159        RCAR_LSI_CUT:=0
160      else
161        $(error "Error: ${LSI_CUT} is not supported.")
162      endif
163      $(eval $(call add_define,RCAR_LSI_CUT))
164    endif
165  else ifeq (${LSI},V3M)
166    RCAR_LSI:=${RCAR_V3M}
167    ifndef LSI_CUT
168      # enable compatible function.
169      RCAR_LSI_CUT_COMPAT := 1
170      $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
171    else
172      # disable compatible function.
173      ifeq (${LSI_CUT},10)
174        RCAR_LSI_CUT:=0
175      endif
176      ifeq (${LSI_CUT},20)
177        RCAR_LSI_CUT:=10
178      endif
179      $(eval $(call add_define,RCAR_LSI_CUT))
180    endif
181  else
182    $(error "Error: ${LSI} is not supported.")
183  endif
184  $(eval $(call add_define,RCAR_LSI))
185endif
186
187# lock RPC HYPERFLASH access by default
188# unlock to repogram the ATF firmware from u-boot
189ifndef RCAR_RPC_HYPERFLASH_LOCKED
190RCAR_RPC_HYPERFLASH_LOCKED := 1
191endif
192$(eval $(call add_define,RCAR_RPC_HYPERFLASH_LOCKED))
193
194# Process RCAR_SECURE_BOOT flag
195ifndef RCAR_SECURE_BOOT
196RCAR_SECURE_BOOT := 1
197endif
198$(eval $(call add_define,RCAR_SECURE_BOOT))
199
200# Process RCAR_QOS_TYPE flag
201ifndef RCAR_QOS_TYPE
202RCAR_QOS_TYPE := 0
203endif
204$(eval $(call add_define,RCAR_QOS_TYPE))
205
206# Process RCAR_DRAM_SPLIT flag
207ifndef RCAR_DRAM_SPLIT
208RCAR_DRAM_SPLIT := 0
209endif
210$(eval $(call add_define,RCAR_DRAM_SPLIT))
211
212# Process RCAR_BL33_EXECUTION_EL flag
213ifndef RCAR_BL33_EXECUTION_EL
214RCAR_BL33_EXECUTION_EL := 0
215endif
216$(eval $(call add_define,RCAR_BL33_EXECUTION_EL))
217
218# Process RCAR_AVS_SETTING_ENABLE flag
219ifeq (${RCAR_AVS_SETTING_ENABLE},0)
220AVS_SETTING_ENABLE := 0
221else
222AVS_SETTING_ENABLE := 1
223endif
224$(eval $(call add_define,AVS_SETTING_ENABLE))
225
226# Process RCAR_LOSSY_ENABLE flag
227ifndef RCAR_LOSSY_ENABLE
228RCAR_LOSSY_ENABLE := 0
229endif
230$(eval $(call add_define,RCAR_LOSSY_ENABLE))
231
232# Process LIFEC_DBSC_PROTECT_ENABLE flag
233ifndef LIFEC_DBSC_PROTECT_ENABLE
234LIFEC_DBSC_PROTECT_ENABLE := 1
235endif
236$(eval $(call add_define,LIFEC_DBSC_PROTECT_ENABLE))
237
238# Process PMIC_ROHM_BD9571 flag
239ifndef PMIC_ROHM_BD9571
240PMIC_ROHM_BD9571 := 1
241endif
242$(eval $(call add_define,PMIC_ROHM_BD9571))
243
244# Process PMIC_LEVEL_MODE flag
245ifndef PMIC_LEVEL_MODE
246PMIC_LEVEL_MODE := 1
247endif
248$(eval $(call add_define,PMIC_LEVEL_MODE))
249
250# Process RCAR_GEN3_ULCB flag
251ifndef RCAR_GEN3_ULCB
252RCAR_GEN3_ULCB := 0
253endif
254ifeq (${RCAR_GEN3_ULCB},1)
255 BOARD_DEFAULT := 0x10
256 $(eval $(call add_define,BOARD_DEFAULT))
257endif
258$(eval $(call add_define,RCAR_GEN3_ULCB))
259
260# Process RCAR_REF_INT flag
261ifndef RCAR_REF_INT
262RCAR_REF_INT :=0
263endif
264$(eval $(call add_define,RCAR_REF_INT))
265
266# Process RCAR_REWT_TRAINING flag
267ifndef RCAR_REWT_TRAINING
268RCAR_REWT_TRAINING := 1
269endif
270$(eval $(call add_define,RCAR_REWT_TRAINING))
271
272# Process RCAR_SYSTEM_SUSPEND flag
273ifndef RCAR_SYSTEM_SUSPEND
274RCAR_SYSTEM_SUSPEND := 1
275endif
276$(eval $(call add_define,RCAR_SYSTEM_SUSPEND))
277
278# SYSTEM_SUSPEND requires power control of PMIC etc.
279# When executing SYSTEM_SUSPEND other than Salvator-X, Salvator-XS and Ebisu,
280# processing equivalent to that implemented in PMIC_ROHM_BD9571 is necessary.
281ifeq (${RCAR_SYSTEM_SUSPEND},1)
282  ifeq (${PMIC_ROHM_BD9571},0)
283    $(error "Error: When you want RCAR_SYSTEM_SUSPEND to be enable, please also set PMIC_ROHM_BD9571 to enable.")
284  endif
285endif
286
287# Process RCAR_DRAM_LPDDR4_MEMCONF flag
288ifndef RCAR_DRAM_LPDDR4_MEMCONF
289RCAR_DRAM_LPDDR4_MEMCONF :=1
290endif
291$(eval $(call add_define,RCAR_DRAM_LPDDR4_MEMCONF))
292
293# Process RCAR_DRAM_DDR3L_MEMCONF flag
294ifndef RCAR_DRAM_DDR3L_MEMCONF
295RCAR_DRAM_DDR3L_MEMCONF :=1
296endif
297$(eval $(call add_define,RCAR_DRAM_DDR3L_MEMCONF))
298
299# Process RCAR_DRAM_DDR3L_MEMDUAL flag
300ifndef RCAR_DRAM_DDR3L_MEMDUAL
301RCAR_DRAM_DDR3L_MEMDUAL :=1
302endif
303$(eval $(call add_define,RCAR_DRAM_DDR3L_MEMDUAL))
304
305# Process RCAR_BL33_ARG0 flag
306ifdef RCAR_BL33_ARG0
307$(eval $(call add_define,RCAR_BL33_ARG0))
308endif
309
310#Process RCAR_BL2_DCACHE flag
311ifndef RCAR_BL2_DCACHE
312RCAR_BL2_DCACHE := 0
313endif
314$(eval $(call add_define,RCAR_BL2_DCACHE))
315
316# Process RCAR_DRAM_CHANNEL flag
317ifndef RCAR_DRAM_CHANNEL
318RCAR_DRAM_CHANNEL :=15
319endif
320$(eval $(call add_define,RCAR_DRAM_CHANNEL))
321
322#Process RCAR_SYSTEM_RESET_KEEPON_DDR flag
323ifndef RCAR_SYSTEM_RESET_KEEPON_DDR
324RCAR_SYSTEM_RESET_KEEPON_DDR := 0
325endif
326$(eval $(call add_define,RCAR_SYSTEM_RESET_KEEPON_DDR))
327
328# RCAR_SYSTEM_RESET_KEEPON_DDR requires power control of PMIC etc.
329# When executing SYSTEM_SUSPEND other than Salvator-X, Salvator-XS and Ebisu,
330# processing equivalent to that implemented in PMIC_ROHM_BD9571 is necessary.
331# Also, it is necessary to enable RCAR_SYSTEM_SUSPEND.
332ifeq (${RCAR_SYSTEM_RESET_KEEPON_DDR},1)
333  ifeq (${PMIC_ROHM_BD9571},0)
334    $(error "Error: When you want RCAR_SYSTEM_RESET_KEEPON_DDR to be enable, please also set PMIC_ROHM_BD9571 to enable.")
335  endif
336  ifeq (${RCAR_SYSTEM_SUSPEND},0)
337    $(error "Error: When you want RCAR_SYSTEM_RESET_KEEPON_DDR to be enable, please also set RCAR_SYSTEM_SUSPEND to enable.")
338  endif
339endif
340
341# Enable workarounds for selected Cortex-A53 erratas.
342ERRATA_A53_835769  := 1
343ERRATA_A53_843419  := 1
344ERRATA_A53_855873  := 1
345
346# Enable workarounds for selected Cortex-A57 erratas.
347ERRATA_A57_859972  := 1
348ERRATA_A57_813419  := 1
349
350include drivers/staging/renesas/rcar/ddr/ddr.mk
351include drivers/staging/renesas/rcar/qos/qos.mk
352include drivers/staging/renesas/rcar/pfc/pfc.mk
353include lib/libfdt/libfdt.mk
354
355PLAT_INCLUDES	:=	-Idrivers/staging/renesas/rcar/ddr	\
356			-Idrivers/staging/renesas/rcar/qos	\
357			-Idrivers/renesas/rcar/iic_dvfs		\
358			-Idrivers/renesas/rcar/board		\
359			-Idrivers/renesas/rcar/cpld/		\
360			-Idrivers/renesas/rcar/avs		\
361			-Idrivers/renesas/rcar/delay		\
362			-Idrivers/renesas/rcar/rom		\
363			-Idrivers/renesas/rcar/scif		\
364			-Idrivers/renesas/rcar/emmc		\
365			-Idrivers/renesas/rcar/pwrc		\
366			-Idrivers/renesas/rcar/io		\
367			-Iplat/renesas/rcar/include/registers	\
368			-Iplat/renesas/rcar/include		\
369			-Iplat/renesas/rcar
370
371PLAT_BL_COMMON_SOURCES	:=	drivers/renesas/rcar/iic_dvfs/iic_dvfs.c \
372				plat/renesas/rcar/rcar_common.c
373
374RCAR_GIC_SOURCES	:=	drivers/arm/gic/common/gic_common.c	\
375				drivers/arm/gic/v2/gicv2_main.c		\
376				drivers/arm/gic/v2/gicv2_helpers.c	\
377				plat/common/plat_gicv2.c
378
379BL2_SOURCES	+=	${RCAR_GIC_SOURCES}				\
380			lib/cpus/aarch64/cortex_a53.S			\
381			lib/cpus/aarch64/cortex_a57.S			\
382			${LIBFDT_SRCS}					\
383			common/desc_image_load.c			\
384			plat/renesas/rcar/aarch64/platform_common.c	\
385			plat/renesas/rcar/aarch64/plat_helpers.S	\
386			plat/renesas/rcar/bl2_interrupt_error.c		\
387			plat/renesas/rcar/bl2_secure_setting.c		\
388			plat/renesas/rcar/bl2_plat_setup.c		\
389			plat/renesas/rcar/plat_storage.c		\
390			plat/renesas/rcar/bl2_plat_mem_params_desc.c	\
391			plat/renesas/rcar/plat_image_load.c		\
392			plat/renesas/rcar/bl2_cpg_init.c		\
393			drivers/renesas/rcar/console/rcar_printf.c	\
394			drivers/renesas/rcar/scif/scif.S		\
395			drivers/renesas/rcar/common.c			\
396			drivers/renesas/rcar/io/io_emmcdrv.c		\
397			drivers/renesas/rcar/io/io_memdrv.c		\
398			drivers/renesas/rcar/io/io_rcar.c		\
399			drivers/renesas/rcar/auth/auth_mod.c		\
400			drivers/renesas/rcar/rpc/rpc_driver.c		\
401			drivers/renesas/rcar/dma/dma_driver.c		\
402			drivers/renesas/rcar/avs/avs_driver.c		\
403			drivers/renesas/rcar/delay/micro_delay.c	\
404			drivers/renesas/rcar/emmc/emmc_interrupt.c	\
405			drivers/renesas/rcar/emmc/emmc_utility.c	\
406			drivers/renesas/rcar/emmc/emmc_mount.c		\
407			drivers/renesas/rcar/emmc/emmc_init.c		\
408			drivers/renesas/rcar/emmc/emmc_read.c		\
409			drivers/renesas/rcar/emmc/emmc_cmd.c		\
410			drivers/renesas/rcar/watchdog/swdt.c		\
411			drivers/renesas/rcar/rom/rom_api.c		\
412			drivers/renesas/rcar/board/board.c		\
413			drivers/io/io_storage.c
414
415BL31_SOURCES	+=	${RCAR_GIC_SOURCES}				\
416			lib/cpus/aarch64/cortex_a53.S			\
417			lib/cpus/aarch64/cortex_a57.S			\
418			plat/common/plat_psci_common.c			\
419			plat/renesas/rcar/plat_topology.c		\
420			plat/renesas/rcar/aarch64/plat_helpers.S	\
421			plat/renesas/rcar/aarch64/platform_common.c	\
422			plat/renesas/rcar/bl31_plat_setup.c		\
423			plat/renesas/rcar/plat_pm.c			\
424			drivers/renesas/rcar/console/rcar_console.S	\
425			drivers/renesas/rcar/console/rcar_printf.c	\
426			drivers/renesas/rcar/delay/micro_delay.c	\
427			drivers/renesas/rcar/pwrc/call_sram.S		\
428			drivers/renesas/rcar/pwrc/pwrc.c		\
429			drivers/renesas/rcar/common.c			\
430			drivers/arm/cci/cci.c
431
432ifeq (${RCAR_GEN3_ULCB},1)
433BL31_SOURCES		+=	drivers/renesas/rcar/cpld/ulcb_cpld.c
434endif
435
436include lib/xlat_tables_v2/xlat_tables.mk
437include drivers/auth/mbedtls/mbedtls_crypto.mk
438PLAT_BL_COMMON_SOURCES	+=	${XLAT_TABLES_LIB_SRCS}
439
440# build the layout images for the bootrom and the necessary srecords
441rcar: rcar_layout_tool rcar_srecord
442distclean realclean clean: clean_layout_tool clean_srecord
443
444# layout images
445LAYOUT_TOOLPATH ?= tools/renesas/rcar_layout_create
446
447clean_layout_tool:
448	@echo "clean layout tool"
449	${Q}${MAKE} -C ${LAYOUT_TOOLPATH} clean
450
451.PHONY: rcar_layout_tool
452rcar_layout_tool:
453	@echo "generating layout srecs"
454	${Q}${MAKE} CPPFLAGS="-D=AARCH64" --no-print-directory -C ${LAYOUT_TOOLPATH}
455
456# srecords
457SREC_PATH	= ${BUILD_PLAT}
458BL2_ELF_SRC	= ${SREC_PATH}/bl2/bl2.elf
459BL31_ELF_SRC	= ${SREC_PATH}/bl31/bl31.elf
460
461clean_srecord:
462	@echo "clean bl2 and bl31 srecs"
463	rm -f ${SREC_PATH}/bl2.srec ${SREC_PATH}/bl31.srec
464
465.PHONY: rcar_srecord
466rcar_srecord: $(BL2_ELF_SRC) $(BL31_ELF_SRC)
467	@echo "generating srec: ${SREC_PATH}/bl2.srec"
468	$(Q)$(OC) -O srec --srec-forceS3 ${BL2_ELF_SRC}  ${SREC_PATH}/bl2.srec
469	@echo "generating srec: ${SREC_PATH}/bl31.srec"
470	$(Q)$(OC) -O srec --srec-forceS3 ${BL31_ELF_SRC} ${SREC_PATH}/bl31.srec
471
472