xref: /rk3399_ARM-atf/plat/mediatek/mt8173/include/platform_def.h (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
17d116dccSCC Ma /*
21083b2b3SAntonio Nino Diaz  * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
37d116dccSCC Ma  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
57d116dccSCC Ma  */
67d116dccSCC Ma 
71083b2b3SAntonio Nino Diaz #ifndef PLATFORM_DEF_H
81083b2b3SAntonio Nino Diaz #define PLATFORM_DEF_H
97d116dccSCC Ma 
10*09d40e0eSAntonio Nino Diaz #include <common/interrupt_props.h>
11*09d40e0eSAntonio Nino Diaz #include <drivers/arm/gic_common.h>
12*09d40e0eSAntonio Nino Diaz #include <lib/utils_def.h>
13*09d40e0eSAntonio Nino Diaz 
148bc20038SKoan-Sin Tan #include "mt8173_def.h"
158bc20038SKoan-Sin Tan 
167d116dccSCC Ma /*******************************************************************************
177d116dccSCC Ma  * Platform binary types for linking
187d116dccSCC Ma  ******************************************************************************/
197d116dccSCC Ma #define PLATFORM_LINKER_FORMAT		"elf64-littleaarch64"
207d116dccSCC Ma #define PLATFORM_LINKER_ARCH		aarch64
217d116dccSCC Ma 
227d116dccSCC Ma /*******************************************************************************
237d116dccSCC Ma  * Generic platform constants
247d116dccSCC Ma  ******************************************************************************/
257d116dccSCC Ma 
267d116dccSCC Ma /* Size of cacheable stacks */
273d8256b2SMasahiro Yamada #if defined(IMAGE_BL1)
287d116dccSCC Ma #define PLATFORM_STACK_SIZE 0x440
293d8256b2SMasahiro Yamada #elif defined(IMAGE_BL2)
307d116dccSCC Ma #define PLATFORM_STACK_SIZE 0x400
313d8256b2SMasahiro Yamada #elif defined(IMAGE_BL31)
327d116dccSCC Ma #define PLATFORM_STACK_SIZE 0x800
333d8256b2SMasahiro Yamada #elif defined(IMAGE_BL32)
347d116dccSCC Ma #define PLATFORM_STACK_SIZE 0x440
357d116dccSCC Ma #endif
367d116dccSCC Ma 
377d116dccSCC Ma #define FIRMWARE_WELCOME_STR		"Booting Trusted Firmware\n"
387d116dccSCC Ma 
397d116dccSCC Ma #define PLATFORM_MAX_AFFLVL		MPIDR_AFFLVL2
401083b2b3SAntonio Nino Diaz #define PLAT_MAX_PWR_LVL		U(2)
411083b2b3SAntonio Nino Diaz #define PLAT_MAX_RET_STATE		U(1)
421083b2b3SAntonio Nino Diaz #define PLAT_MAX_OFF_STATE		U(2)
437d116dccSCC Ma #define PLATFORM_SYSTEM_COUNT		1
447d116dccSCC Ma #define PLATFORM_CLUSTER_COUNT		2
457d116dccSCC Ma #define PLATFORM_CLUSTER0_CORE_COUNT	4
467d116dccSCC Ma #define PLATFORM_CLUSTER1_CORE_COUNT	2
477d116dccSCC Ma #define PLATFORM_CORE_COUNT		(PLATFORM_CLUSTER1_CORE_COUNT +	\
487d116dccSCC Ma 					 PLATFORM_CLUSTER0_CORE_COUNT)
497d116dccSCC Ma #define PLATFORM_MAX_CPUS_PER_CLUSTER	4
507d116dccSCC Ma #define PLATFORM_NUM_AFFS		(PLATFORM_SYSTEM_COUNT +	\
517d116dccSCC Ma 					 PLATFORM_CLUSTER_COUNT +	\
527d116dccSCC Ma 					 PLATFORM_CORE_COUNT)
537d116dccSCC Ma 
547d116dccSCC Ma /*******************************************************************************
557d116dccSCC Ma  * Platform memory map related constants
567d116dccSCC Ma  ******************************************************************************/
57e2a65959SJimmy Huang /*
58e2a65959SJimmy Huang  * MT8173 SRAM memory layout
59e2a65959SJimmy Huang  * 0x100000 +-------------------+
60e2a65959SJimmy Huang  *          | shared mem (4KB)  |
61e2a65959SJimmy Huang  * 0x101000 +-------------------+
62e2a65959SJimmy Huang  *          |                   |
63e2a65959SJimmy Huang  *          |   BL3-1 (124KB)   |
64e2a65959SJimmy Huang  *          |                   |
65e2a65959SJimmy Huang  * 0x120000 +-------------------+
66e2a65959SJimmy Huang  *          |  reserved (64KB)  |
67e2a65959SJimmy Huang  * 0x130000 +-------------------+
68e2a65959SJimmy Huang  */
69e2a65959SJimmy Huang /* TF txet, ro, rw, xlat table, coherent memory ... etc.
70e2a65959SJimmy Huang  * Size: release: 128KB, debug: 128KB
71e2a65959SJimmy Huang  */
727d116dccSCC Ma #define TZRAM_BASE		(0x100000)
737d116dccSCC Ma #if DEBUG
747d116dccSCC Ma #define TZRAM_SIZE		(0x20000)
757d116dccSCC Ma #else
767d116dccSCC Ma #define TZRAM_SIZE		(0x20000)
777d116dccSCC Ma #endif
787d116dccSCC Ma 
79e2a65959SJimmy Huang /* Reserved: 64KB */
807d116dccSCC Ma #define TZRAM2_BASE		(TZRAM_BASE + TZRAM_SIZE)
817d116dccSCC Ma #define TZRAM2_SIZE		(0x10000)
827d116dccSCC Ma 
837d116dccSCC Ma /*******************************************************************************
847d116dccSCC Ma  * BL31 specific defines.
857d116dccSCC Ma  ******************************************************************************/
867d116dccSCC Ma /*
877d116dccSCC Ma  * Put BL3-1 at the top of the Trusted SRAM (just below the shared memory, if
887d116dccSCC Ma  * present). BL31_BASE is calculated using the current BL3-1 debug size plus a
897d116dccSCC Ma  * little space for growth.
907d116dccSCC Ma  */
917d116dccSCC Ma #define BL31_BASE		(TZRAM_BASE + 0x1000)
927d116dccSCC Ma #define BL31_LIMIT		(TZRAM_BASE + TZRAM_SIZE)
937d116dccSCC Ma #define TZRAM2_LIMIT		(TZRAM2_BASE + TZRAM2_SIZE)
947d116dccSCC Ma 
957d116dccSCC Ma /*******************************************************************************
967d116dccSCC Ma  * Platform specific page table and MMU setup constants
977d116dccSCC Ma  ******************************************************************************/
985724481fSDavid Cunado #define PLAT_PHY_ADDR_SPACE_SIZE	(1ULL << 32)
995724481fSDavid Cunado #define PLAT_VIRT_ADDR_SPACE_SIZE	(1ULL << 32)
1007d116dccSCC Ma #define MAX_XLAT_TABLES		4
1017d116dccSCC Ma #define MAX_MMAP_REGIONS	16
1027d116dccSCC Ma 
1037d116dccSCC Ma /*******************************************************************************
1047d116dccSCC Ma  * Declarations and constants to access the mailboxes safely. Each mailbox is
1057d116dccSCC Ma  * aligned on the biggest cache line size in the platform. This is known only
1067d116dccSCC Ma  * to the platform as it might have a combination of integrated and external
1077d116dccSCC Ma  * caches. Such alignment ensures that two maiboxes do not sit on the same cache
1087d116dccSCC Ma  * line at any cache level. They could belong to different cpus/clusters &
1097d116dccSCC Ma  * get written while being protected by different locks causing corruption of
1107d116dccSCC Ma  * a valid mailbox address.
1117d116dccSCC Ma  ******************************************************************************/
1127d116dccSCC Ma #define CACHE_WRITEBACK_SHIFT	6
1137d116dccSCC Ma #define CACHE_WRITEBACK_GRANULE	(1 << CACHE_WRITEBACK_SHIFT)
1147d116dccSCC Ma 
1158bc20038SKoan-Sin Tan 
1168bc20038SKoan-Sin Tan #define PLAT_ARM_GICD_BASE      BASE_GICD_BASE
1178bc20038SKoan-Sin Tan #define PLAT_ARM_GICC_BASE      BASE_GICC_BASE
1188bc20038SKoan-Sin Tan 
119831b3752SJeenu Viswambharan #define PLAT_ARM_G1S_IRQ_PROPS(grp) \
120831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, grp, \
121831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
122831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, grp, \
123831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
124831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, grp, \
125831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
126831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, grp, \
127831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
128831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, grp, \
129831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
130831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, grp, \
131831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
132831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, grp, \
133831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE), \
134831b3752SJeenu Viswambharan 	INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
135831b3752SJeenu Viswambharan 			GIC_INTR_CFG_EDGE)
1368bc20038SKoan-Sin Tan 
137831b3752SJeenu Viswambharan #define PLAT_ARM_G0_IRQ_PROPS(grp)
1388bc20038SKoan-Sin Tan 
1391083b2b3SAntonio Nino Diaz #endif /* PLATFORM_DEF_H */
140