xref: /rk3399_ARM-atf/plat/socionext/synquacer/include/platform_def.h (revision 48ab390444e1dabb669430ace9b8e5a80348eed0)
1c35d59a3SSumit Garg /*
2*48ab3904SJassi Brar  * Copyright (c) 2018-2022, ARM Limited and Contributors. All rights reserved.
3c35d59a3SSumit Garg  *
4c35d59a3SSumit Garg  * SPDX-License-Identifier: BSD-3-Clause
5c35d59a3SSumit Garg  */
6c35d59a3SSumit Garg 
71083b2b3SAntonio Nino Diaz #ifndef PLATFORM_DEF_H
81083b2b3SAntonio Nino Diaz #define PLATFORM_DEF_H
9c35d59a3SSumit Garg 
1009d40e0eSAntonio Nino Diaz #include <lib/utils_def.h>
1109d40e0eSAntonio Nino Diaz #include <plat/common/common_def.h>
12c35d59a3SSumit Garg 
13007a7a33SSumit Garg /* CPU topology */
1450dae22eSDeepika Bhavnani #define PLAT_MAX_CORES_PER_CLUSTER	U(2)
1550dae22eSDeepika Bhavnani #define PLAT_CLUSTER_COUNT		U(12)
16007a7a33SSumit Garg #define PLATFORM_CORE_COUNT		(PLAT_CLUSTER_COUNT *	\
17007a7a33SSumit Garg 					 PLAT_MAX_CORES_PER_CLUSTER)
18007a7a33SSumit Garg 
19b67d2029SMasahisa Kojima /* Macros to read the SQ power domain state */
20b67d2029SMasahisa Kojima #define SQ_PWR_LVL0		MPIDR_AFFLVL0
21b67d2029SMasahisa Kojima #define SQ_PWR_LVL1		MPIDR_AFFLVL1
22b67d2029SMasahisa Kojima #define SQ_PWR_LVL2		MPIDR_AFFLVL2
23b67d2029SMasahisa Kojima 
24b67d2029SMasahisa Kojima #define SQ_CORE_PWR_STATE(state)	(state)->pwr_domain_state[SQ_PWR_LVL0]
25b67d2029SMasahisa Kojima #define SQ_CLUSTER_PWR_STATE(state)	(state)->pwr_domain_state[SQ_PWR_LVL1]
26b67d2029SMasahisa Kojima #define SQ_SYSTEM_PWR_STATE(state)	((PLAT_MAX_PWR_LVL > SQ_PWR_LVL1) ?\
27b67d2029SMasahisa Kojima 				(state)->pwr_domain_state[SQ_PWR_LVL2] : 0)
28b67d2029SMasahisa Kojima 
291083b2b3SAntonio Nino Diaz #define PLAT_MAX_PWR_LVL		U(1)
301083b2b3SAntonio Nino Diaz #define PLAT_MAX_RET_STATE		U(1)
311083b2b3SAntonio Nino Diaz #define PLAT_MAX_OFF_STATE		U(2)
32753701ccSSumit Garg 
33753701ccSSumit Garg #define SQ_LOCAL_STATE_RUN		0
34753701ccSSumit Garg #define SQ_LOCAL_STATE_RET		1
35753701ccSSumit Garg #define SQ_LOCAL_STATE_OFF		2
36753701ccSSumit Garg 
37c35d59a3SSumit Garg #define CACHE_WRITEBACK_SHIFT		6
38c35d59a3SSumit Garg #define CACHE_WRITEBACK_GRANULE		(1 << CACHE_WRITEBACK_SHIFT)
39c35d59a3SSumit Garg 
408cd37d7bSSumit Garg #define PLAT_PHY_ADDR_SPACE_SIZE	(1ULL << 32)
418cd37d7bSSumit Garg #define PLAT_VIRT_ADDR_SPACE_SIZE	(1ULL << 32)
42434454a2SArd Biesheuvel #define MAX_XLAT_TABLES			8
43434454a2SArd Biesheuvel #define MAX_MMAP_REGIONS		8
448cd37d7bSSumit Garg 
45c35d59a3SSumit Garg #define PLATFORM_STACK_SIZE		0x400
46c35d59a3SSumit Garg 
47*48ab3904SJassi Brar #if !RESET_TO_BL31
48*48ab3904SJassi Brar 
49*48ab3904SJassi Brar /* A mailbox page will be mapped from BL2 and BL31 */
50*48ab3904SJassi Brar #define BL2_MAILBOX_BASE		0x0403f000
51*48ab3904SJassi Brar #define BL2_MAILBOX_SIZE		0x1000
52*48ab3904SJassi Brar 
53*48ab3904SJassi Brar #define MAX_IO_HANDLES			2
54*48ab3904SJassi Brar #define MAX_IO_DEVICES			2
55*48ab3904SJassi Brar #define MAX_IO_BLOCK_DEVICES	U(1)
56*48ab3904SJassi Brar 
57*48ab3904SJassi Brar #define BL2_BASE			0x04000000
58*48ab3904SJassi Brar #define BL2_SIZE			(256 * 1024)
59*48ab3904SJassi Brar #define BL2_LIMIT			(BL2_BASE + BL2_SIZE)
60*48ab3904SJassi Brar 
61*48ab3904SJassi Brar /* If BL2 is enabled, the BL31 is loaded on secure DRAM */
62*48ab3904SJassi Brar #define BL31_BASE			0xfbe00000
63*48ab3904SJassi Brar #define BL31_SIZE			0x00100000
64*48ab3904SJassi Brar #else
65*48ab3904SJassi Brar 
66c35d59a3SSumit Garg #define BL31_BASE			0x04000000
67c35d59a3SSumit Garg #define BL31_SIZE			0x00080000
68*48ab3904SJassi Brar #endif
69*48ab3904SJassi Brar 
70c35d59a3SSumit Garg #define BL31_LIMIT			(BL31_BASE + BL31_SIZE)
71c35d59a3SSumit Garg 
72e373b6a2SArd Biesheuvel #define BL32_BASE			0xfc000000
73434454a2SArd Biesheuvel #define BL32_SIZE			0x03c00000
74434454a2SArd Biesheuvel #define BL32_LIMIT			(BL32_BASE + BL32_SIZE)
75e373b6a2SArd Biesheuvel 
76*48ab3904SJassi Brar /* Alternative BL33 */
77*48ab3904SJassi Brar #define PLAT_SQ_BL33_BASE		0xe0000000
78*48ab3904SJassi Brar #define PLAT_SQ_BL33_SIZE		0x00100000
79*48ab3904SJassi Brar 
80*48ab3904SJassi Brar /* FIP IO base */
81*48ab3904SJassi Brar #define PLAT_SQ_FIP_IOBASE		0x08600000
82*48ab3904SJassi Brar #define PLAT_SQ_FIP_MAXSIZE		0x00400000
83*48ab3904SJassi Brar 
840eb275c9SSumit Garg #define PLAT_SQ_CCN_BASE		0x32000000
850eb275c9SSumit Garg #define PLAT_SQ_CLUSTER_TO_CCN_ID_MAP					\
860eb275c9SSumit Garg 					0,	/* Cluster 0 */		\
870eb275c9SSumit Garg 					18,	/* Cluster 1 */		\
880eb275c9SSumit Garg 					11,	/* Cluster 2 */		\
890eb275c9SSumit Garg 					29,	/* Cluster 3 */		\
900eb275c9SSumit Garg 					35,	/* Cluster 4 */		\
910eb275c9SSumit Garg 					17,	/* Cluster 5 */		\
920eb275c9SSumit Garg 					12,	/* Cluster 6 */		\
930eb275c9SSumit Garg 					30,	/* Cluster 7 */		\
940eb275c9SSumit Garg 					14,	/* Cluster 8 */		\
950eb275c9SSumit Garg 					32,	/* Cluster 9 */		\
960eb275c9SSumit Garg 					15,	/* Cluster 10 */	\
970eb275c9SSumit Garg 					33	/* Cluster 11 */
980eb275c9SSumit Garg 
9967b40070SSumit Garg /* UART related constants */
10067b40070SSumit Garg #define PLAT_SQ_BOOT_UART_BASE		0x2A400000
10167b40070SSumit Garg #define PLAT_SQ_BOOT_UART_CLK_IN_HZ	62500000
10267b40070SSumit Garg #define SQ_CONSOLE_BAUDRATE		115200
10367b40070SSumit Garg 
1045931fdacSSumit Garg #define SQ_SYS_CNTCTL_BASE		0x2a430000
1055931fdacSSumit Garg 
1065931fdacSSumit Garg #define SQ_SYS_TIMCTL_BASE		0x2a810000
1075931fdacSSumit Garg #define PLAT_SQ_NSTIMER_FRAME_ID	0
1084d4911d7SMasahisa Kojima #define SQ_SYS_CNT_BASE_NS		0x2a830000
1095931fdacSSumit Garg 
110cfe19f85SArd Biesheuvel #define DRAMINFO_BASE			0x2E00FFC0
111cfe19f85SArd Biesheuvel 
11205377100SSumit Garg #define PLAT_SQ_MHU_BASE		0x45000000
11305377100SSumit Garg 
114b7ad0444SSumit Garg #define PLAT_SQ_SCP_COM_SHARED_MEM_BASE		0x45400000
115b7ad0444SSumit Garg #define SCPI_CMD_GET_DRAMINFO			0x1
116b7ad0444SSumit Garg 
11785427debSSumit Garg #define SQ_BOOT_CFG_ADDR			0x45410000
11885427debSSumit Garg #define PLAT_SQ_PRIMARY_CPU_SHIFT		8
11985427debSSumit Garg #define PLAT_SQ_PRIMARY_CPU_BIT_WIDTH		6
12085427debSSumit Garg 
121b529799fSSumit Garg #define PLAT_SQ_GICD_BASE		0x30000000
122b529799fSSumit Garg #define PLAT_SQ_GICR_BASE		0x30400000
123b529799fSSumit Garg 
124753701ccSSumit Garg #define PLAT_SQ_GPIO_BASE		0x51000000
125753701ccSSumit Garg 
126434454a2SArd Biesheuvel #define PLAT_SPM_BUF_BASE		(BL32_LIMIT - 32 * PLAT_SPM_BUF_SIZE)
127434454a2SArd Biesheuvel #define PLAT_SPM_BUF_SIZE		ULL(0x10000)
128434454a2SArd Biesheuvel #define PLAT_SPM_SPM_BUF_EL0_MMAP	MAP_REGION2(PLAT_SPM_BUF_BASE, \
129434454a2SArd Biesheuvel 						    PLAT_SPM_BUF_BASE, \
130434454a2SArd Biesheuvel 						    PLAT_SPM_BUF_SIZE, \
131434454a2SArd Biesheuvel 						    MT_RO_DATA | MT_SECURE | \
132434454a2SArd Biesheuvel 						    MT_USER, PAGE_SIZE)
133434454a2SArd Biesheuvel 
134434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_NS_BUF_BASE	BL32_LIMIT
135434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_NS_BUF_SIZE	ULL(0x200000)
136434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_NS_BUF_MMAP	MAP_REGION2(PLAT_SP_IMAGE_NS_BUF_BASE, \
137434454a2SArd Biesheuvel 						    PLAT_SP_IMAGE_NS_BUF_BASE, \
138434454a2SArd Biesheuvel 						    PLAT_SP_IMAGE_NS_BUF_SIZE, \
139434454a2SArd Biesheuvel 						    MT_RW_DATA | MT_NS | \
140434454a2SArd Biesheuvel 						    MT_USER, PAGE_SIZE)
141434454a2SArd Biesheuvel 
142434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_STACK_PCPU_SIZE	ULL(0x10000)
143434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_STACK_SIZE	(32 * PLAT_SP_IMAGE_STACK_PCPU_SIZE)
144434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_STACK_BASE	(PLAT_SQ_SP_HEAP_BASE + PLAT_SQ_SP_HEAP_SIZE)
145434454a2SArd Biesheuvel 
146434454a2SArd Biesheuvel #define PLAT_SQ_SP_IMAGE_SIZE		ULL(0x200000)
147434454a2SArd Biesheuvel #define PLAT_SQ_SP_IMAGE_MMAP		MAP_REGION2(BL32_BASE, BL32_BASE, \
148434454a2SArd Biesheuvel 						    PLAT_SQ_SP_IMAGE_SIZE, \
149434454a2SArd Biesheuvel 						    MT_CODE | MT_SECURE | \
150434454a2SArd Biesheuvel 						    MT_USER, PAGE_SIZE)
151434454a2SArd Biesheuvel 
152434454a2SArd Biesheuvel #define PLAT_SQ_SP_HEAP_BASE		(BL32_BASE + PLAT_SQ_SP_IMAGE_SIZE)
153434454a2SArd Biesheuvel #define PLAT_SQ_SP_HEAP_SIZE		ULL(0x800000)
154434454a2SArd Biesheuvel 
155434454a2SArd Biesheuvel #define PLAT_SQ_SP_IMAGE_RW_MMAP	MAP_REGION2(PLAT_SQ_SP_HEAP_BASE, \
156434454a2SArd Biesheuvel 						    PLAT_SQ_SP_HEAP_BASE, \
157434454a2SArd Biesheuvel 						    (PLAT_SQ_SP_HEAP_SIZE + \
158434454a2SArd Biesheuvel 						     PLAT_SP_IMAGE_STACK_SIZE), \
159434454a2SArd Biesheuvel 						    MT_RW_DATA | MT_SECURE | \
160434454a2SArd Biesheuvel 						    MT_USER, PAGE_SIZE)
161434454a2SArd Biesheuvel 
162434454a2SArd Biesheuvel #define PLAT_SQ_SP_PRIV_BASE		(PLAT_SP_IMAGE_STACK_BASE + \
163434454a2SArd Biesheuvel 					 PLAT_SP_IMAGE_STACK_SIZE)
164434454a2SArd Biesheuvel #define PLAT_SQ_SP_PRIV_SIZE		ULL(0x40000)
165434454a2SArd Biesheuvel 
166434454a2SArd Biesheuvel #define PLAT_SP_PRI			0x20
167434454a2SArd Biesheuvel #define PLAT_PRI_BITS			2
168434454a2SArd Biesheuvel #define PLAT_SPM_COOKIE_0		ULL(0)
169434454a2SArd Biesheuvel #define PLAT_SPM_COOKIE_1		ULL(0)
170434454a2SArd Biesheuvel 
171434454a2SArd Biesheuvel /* Total number of memory regions with distinct properties */
172434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_NUM_MEM_REGIONS	6
173434454a2SArd Biesheuvel 
174434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_MMAP_REGIONS	30
175434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_MAX_XLAT_TABLES	20
176434454a2SArd Biesheuvel #define PLAT_SP_IMAGE_XLAT_SECTION_NAME	"sp_xlat_table"
1770922e481SMasahisa Kojima #define PLAT_SP_IMAGE_BASE_XLAT_SECTION_NAME	"sp_xlat_table"
178434454a2SArd Biesheuvel 
179434454a2SArd Biesheuvel #define PLAT_SQ_UART1_BASE		PLAT_SQ_BOOT_UART_BASE
180434454a2SArd Biesheuvel #define PLAT_SQ_UART1_SIZE		ULL(0x1000)
181434454a2SArd Biesheuvel #define PLAT_SQ_UART1_MMAP		MAP_REGION_FLAT(PLAT_SQ_UART1_BASE, \
182434454a2SArd Biesheuvel 							PLAT_SQ_UART1_SIZE, \
183434454a2SArd Biesheuvel 							MT_DEVICE | MT_RW | \
184434454a2SArd Biesheuvel 							MT_NS | MT_PRIVILEGED)
185434454a2SArd Biesheuvel 
186434454a2SArd Biesheuvel #define PLAT_SQ_PERIPH_BASE		0x50000000
187434454a2SArd Biesheuvel #define PLAT_SQ_PERIPH_SIZE		ULL(0x8000000)
188434454a2SArd Biesheuvel #define PLAT_SQ_PERIPH_MMAP		MAP_REGION_FLAT(PLAT_SQ_PERIPH_BASE, \
189434454a2SArd Biesheuvel 							PLAT_SQ_PERIPH_SIZE, \
190434454a2SArd Biesheuvel 							MT_DEVICE | MT_RW | \
191434454a2SArd Biesheuvel 							MT_NS | MT_USER)
192434454a2SArd Biesheuvel 
193434454a2SArd Biesheuvel #define PLAT_SQ_FLASH_BASE		0x08000000
194434454a2SArd Biesheuvel #define PLAT_SQ_FLASH_SIZE		ULL(0x8000000)
195434454a2SArd Biesheuvel #define PLAT_SQ_FLASH_MMAP		MAP_REGION_FLAT(PLAT_SQ_FLASH_BASE, \
196434454a2SArd Biesheuvel 							PLAT_SQ_FLASH_SIZE, \
197434454a2SArd Biesheuvel 							MT_DEVICE | MT_RW | \
198434454a2SArd Biesheuvel 							MT_NS | MT_USER)
199434454a2SArd Biesheuvel 
2001083b2b3SAntonio Nino Diaz #endif /* PLATFORM_DEF_H */
201