blob: dab265b472eb5eb5245c641bdc4f00f4ecd632c9 [file] [log] [blame]
developer1033ea12019-04-10 21:09:26 +08001/*
2 * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef PLATFORM_DEF_H
8#define PLATFORM_DEF_H
9
10#include <arch.h>
11#include <drivers/arm/gic_common.h>
12
13#define PLAT_PRIMARY_CPU 0x0
14
15#define IO_PHYS 0x10000000
16#define INFRACFG_AO_BASE (IO_PHYS + 0x1000)
17#define PERI_BASE (IO_PHYS + 0x3000)
18#define GPIO_BASE (IO_PHYS + 0x5000)
19#define SPM_BASE (IO_PHYS + 0x6000)
20#define SLEEP_REG_MD_BASE (IO_PHYS + 0xf000)
21#define RGU_BASE (IO_PHYS + 0x7000)
22#define I2C4_BASE_SE (IO_PHYS + 0x1008000)
23#define I2C2_BASE_SE (IO_PHYS + 0x1009000)
24#define PMIC_WRAP_BASE (IO_PHYS + 0xd000)
25#define MCUCFG_BASE 0x0c530000
26#define CFG_SF_CTRL 0x0c510014
27#define CFG_SF_INI 0x0c510010
28#define EMI_MPU_BASE (IO_PHYS + 0x226000)
29#define TRNG_base (IO_PHYS + 0x20f000)
30#define MT_GIC_BASE 0x0c000000
31#define PLAT_MT_CCI_BASE 0x0c500000
32#define CCI_SIZE 0x00010000
33#define EINT_BASE 0x1000b000
34#define DVFSRC_BASE (IO_PHYS + 0x12000)
35
36#define SSPM_CFGREG_BASE (IO_PHYS + 0x440000)
37#define SSPM_MBOX_3_BASE (IO_PHYS + 0x480000)
38
39#define INFRACFG_AO_BASE (IO_PHYS + 0x1000)
40
41#define APMIXEDSYS (IO_PHYS + 0xC000)
42#define ARMPLL_LL_CON0 (APMIXEDSYS + 0x200)
43#define ARMPLL_L_CON0 (APMIXEDSYS + 0x210)
44#define MAINPLL_CON0 (APMIXEDSYS + 0x220)
45#define CCIPLL_CON0 (APMIXEDSYS + 0x290)
46
47#define TOP_CKMUXSEL (INFRACFG_AO_BASE + 0x0)
48
49#define armpll_mux1_sel_big_mask (0xf << 4)
50#define armpll_mux1_sel_big_ARMSPLL (0x1 << 4)
51#define armpll_mux1_sel_sml_mask (0xf << 8)
52#define armpll_mux1_sel_sml_ARMSPLL (0x1 << 8)
53
54
55/* Aggregate of all devices in the first GB */
56#define MTK_DEV_RNG0_BASE IO_PHYS
57#define MTK_DEV_RNG0_SIZE 0x490000
58#define MTK_DEV_RNG1_BASE (IO_PHYS + 0x1000000)
59#define MTK_DEV_RNG1_SIZE 0x4000000
60#define MTK_DEV_RNG2_BASE 0x0c000000
61#define MTK_DEV_RNG2_SIZE 0x600000
62#define MT_MCUSYS_SIZE 0x90000
63#define RAM_CONSOLE_BASE 0x11d000
64#define RAM_CONSOLE_SIZE 0x1000
65
66/*******************************************************************************
67 * MSDC
68 ******************************************************************************/
69#define MSDC0_BASE (IO_PHYS + 0x01230000)
70
71/*******************************************************************************
72 * MCUSYS related constants
73 ******************************************************************************/
74#define MT_L2_WRITE_ACCESS_RATE (MCUCFG_BASE + 0x604)
75#define MP0_CA7L_CACHE_CONFIG (MCUCFG_BASE + 0x7f0)
76#define MP1_CA7L_CACHE_CONFIG (MCUCFG_BASE + 0x7f4)
77
78/*******************************************************************************
79 * GIC related constants
80 ******************************************************************************/
81#define MT_POLARITY_LOW 0
82#define MT_POLARITY_HIGH 1
83#define MT_EDGE_SENSITIVE 1
84#define MT_LEVEL_SENSITIVE 0
85
86/*******************************************************************************
87 * UART related constants
88 ******************************************************************************/
89#define UART0_BASE (IO_PHYS + 0x01002000)
developera767ecc2019-08-20 22:27:44 +080090#define UART1_BASE (IO_PHYS + 0x01003000)
developer1033ea12019-04-10 21:09:26 +080091
92#define UART_BAUDRATE 115200
93#define UART_CLOCK 26000000
94
95/*******************************************************************************
96 * System counter frequency related constants
97 ******************************************************************************/
98#define SYS_COUNTER_FREQ_IN_TICKS 13000000
99#define SYS_COUNTER_FREQ_IN_MHZ 13
100
101/*******************************************************************************
102 * GIC-400 & interrupt handling related constants
103 ******************************************************************************/
104
105/* Base MTK_platform compatible GIC memory map */
106#define BASE_GICD_BASE MT_GIC_BASE
107#define BASE_GICC_BASE (MT_GIC_BASE + 0x400000)
108#define MT_GIC_RDIST_BASE (MT_GIC_BASE + 0x100000)
109#define BASE_GICR_BASE (MT_GIC_BASE + 0x100000)
110#define BASE_GICH_BASE (MT_GIC_BASE + 0x4000)
111#define BASE_GICV_BASE (MT_GIC_BASE + 0x6000)
112#define INT_POL_CTL0 (MCUCFG_BASE + 0xa80)
113#define SEC_POL_CTL_EN0 (MCUCFG_BASE + 0xa00)
114#define GIC_SYNC_DCM (MCUCFG_BASE + 0x758)
115#define GIC_SYNC_DCM_MASK 0x3
116#define GIC_SYNC_DCM_ON 0x3
117#define GIC_SYNC_DCM_OFF 0x0
118#define GIC_PRIVATE_SIGNALS 32
119
120#define PLAT_ARM_GICD_BASE BASE_GICD_BASE
121#define PLAT_ARM_GICC_BASE BASE_GICC_BASE
122
123#define PLAT_ARM_G1S_IRQ_PROPS(grp) ( \
124INTR_PROP_DESC(MT_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, grp, \
125 GIC_INTR_CFG_EDGE), \
126INTR_PROP_DESC(MT_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, grp, \
127 GIC_INTR_CFG_EDGE), \
128INTR_PROP_DESC(MT_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, grp, \
129 GIC_INTR_CFG_EDGE), \
130INTR_PROP_DESC(MT_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, grp, \
131 GIC_INTR_CFG_EDGE), \
132INTR_PROP_DESC(MT_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, grp, \
133 GIC_INTR_CFG_EDGE), \
134INTR_PROP_DESC(MT_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, grp, \
135 GIC_INTR_CFG_EDGE), \
136INTR_PROP_DESC(MT_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, grp, \
137 GIC_INTR_CFG_EDGE), \
138INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
139 GIC_INTR_CFG_EDGE)) \
140
141#define PLAT_ARM_G0_IRQ_PROPS(grp)
142
143/*******************************************************************************
144 * CCI-400 related constants
145 ******************************************************************************/
146#define PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX 4
147#define PLAT_MT_CCI_CLUSTER1_SL_IFACE_IX 3
148
149/*******************************************************************************
150 * WDT Registers
151 ******************************************************************************/
152#define MTK_WDT_BASE (IO_PHYS + 0x00007000)
153#define MTK_WDT_SIZE 0x1000
154#define MTK_WDT_MODE (MTK_WDT_BASE + 0x0000)
155#define MTK_WDT_LENGTH (MTK_WDT_BASE + 0x0004)
156#define MTK_WDT_RESTART (MTK_WDT_BASE + 0x0008)
157#define MTK_WDT_STATUS (MTK_WDT_BASE + 0x000C)
158#define MTK_WDT_INTERVAL (MTK_WDT_BASE + 0x0010)
159#define MTK_WDT_SWRST (MTK_WDT_BASE + 0x0014)
160#define MTK_WDT_SWSYSRST (MTK_WDT_BASE + 0x0018)
161#define MTK_WDT_NONRST_REG (MTK_WDT_BASE + 0x0020)
162#define MTK_WDT_NONRST_REG2 (MTK_WDT_BASE + 0x0024)
163#define MTK_WDT_REQ_MODE (MTK_WDT_BASE + 0x0030)
164#define MTK_WDT_REQ_IRQ_EN (MTK_WDT_BASE + 0x0034)
165#define MTK_WDT_EXT_REQ_CON (MTK_WDT_BASE + 0x0038)
166#define MTK_WDT_DEBUG_CTL (MTK_WDT_BASE + 0x0040)
167#define MTK_WDT_LATCH_CTL (MTK_WDT_BASE + 0x0044)
168#define MTK_WDT_DEBUG_CTL2 (MTK_WDT_BASE + 0x00A0)
169#define MTK_WDT_COUNTER (MTK_WDT_BASE + 0x0514)
170
171/* WDT_STATUS */
172#define MTK_WDT_STATUS_SPM_THERMAL_RST (1 << 0)
173#define MTK_WDT_STATUS_SPM_RST (1 << 1)
174#define MTK_WDT_STATUS_EINT_RST (1 << 2)
175#define MTK_WDT_STATUS_SYSRST_RST (1 << 3) /* from PMIC */
176#define MTK_WDT_STATUS_DVFSP_RST (1 << 4)
177#define MTK_WDT_STATUS_PMCU_RST (1 << 16)
178#define MTK_WDT_STATUS_MDDBG_RST (1 << 17)
179#define MTK_WDT_STATUS_THERMAL_DIRECT_RST (1 << 18)
180#define MTK_WDT_STATUS_DEBUG_RST (1 << 19)
181#define MTK_WDT_STATUS_SECURITY_RST (1 << 28)
182#define MTK_WDT_STATUS_IRQ_ASSERT (1 << 29)
183#define MTK_WDT_STATUS_SW_WDT_RST (1 << 30)
Justin Chadwell104d4a72019-07-03 14:13:55 +0100184#define MTK_WDT_STATUS_HW_WDT_RST (1U << 31)
developer1033ea12019-04-10 21:09:26 +0800185
186/* RGU other related */
187#define MTK_WDT_MODE_DUAL_MODE 0x0040
188#define MTK_WDT_MODE_IRQ 0x0008
189#define MTK_WDT_MODE_KEY 0x22000000
190#define MTK_WDT_MODE_EXTEN 0x0004
191#define MTK_WDT_SWRST_KEY 0x1209
192#define MTK_WDT_RESTART_KEY 0x1971
193
194/*******************************************************************************
195 * TRNG Registers
196 ******************************************************************************/
197#define TRNG_BASE_ADDR TRNG_base
198#define TRNG_BASE_SIZE 0x1000
199#define TRNG_CTRL (TRNG_base + 0x0000)
200#define TRNG_TIME (TRNG_base + 0x0004)
201#define TRNG_DATA (TRNG_base + 0x0008)
202#define TRNG_PDN_base 0x10001000
203#define TRNG_PDN_BASE_ADDR TRNG_PDN_BASE_ADDR
204#define TRNG_PDN_BASE_SIZE 0x1000
205#define TRNG_PDN_SET (TRNG_PDN_base + 0x0088)
206#define TRNG_PDN_CLR (TRNG_PDN_base + 0x008c)
207#define TRNG_PDN_STATUS (TRNG_PDN_base + 0x0094)
208#define TRNG_CTRL_RDY 0x80000000
209#define TRNG_CTRL_START 0x00000001
210#define TRNG_PDN_VALUE 0x200
211
212/* FIQ platform related define */
213#define MT_IRQ_SEC_SGI_0 8
214#define MT_IRQ_SEC_SGI_1 9
215#define MT_IRQ_SEC_SGI_2 10
216#define MT_IRQ_SEC_SGI_3 11
217#define MT_IRQ_SEC_SGI_4 12
218#define MT_IRQ_SEC_SGI_5 13
219#define MT_IRQ_SEC_SGI_6 14
220#define MT_IRQ_SEC_SGI_7 15
221
222#define FIQ_SMP_CALL_SGI 13
223#define WDT_IRQ_BIT_ID 174
224#define ATF_LOG_IRQ_ID 277
225
226#define ATF_AMMS_IRQ_ID 338
227#define PCCIF1_IRQ0_BIT_ID 185
228#define PCCIF1_IRQ1_BIT_ID 186
229
230#define DEBUG_XLAT_TABLE 0
231
232/*******************************************************************************
233 * Platform binary types for linking
234 ******************************************************************************/
235#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
236#define PLATFORM_LINKER_ARCH aarch64
237
238/*******************************************************************************
239 * Generic platform constants
240 ******************************************************************************/
241
242/* Size of cacheable stacks */
243#if DEBUG_XLAT_TABLE
244#define PLATFORM_STACK_SIZE 0x800
245#elif IMAGE_BL1
246#define PLATFORM_STACK_SIZE 0x440
247#elif IMAGE_BL2
248#define PLATFORM_STACK_SIZE 0x400
249#elif IMAGE_BL31
250#define PLATFORM_STACK_SIZE 0x800
251#elif IMAGE_BL32
252#define PLATFORM_STACK_SIZE 0x440
253#endif
254
255#define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n"
256#define PLAT_MAX_PWR_LVL U(2)
257#define PLAT_MAX_RET_STATE U(1)
258#define PLAT_MAX_OFF_STATE U(2)
259
260#define PLATFORM_CACHE_LINE_SIZE 64
261#define PLATFORM_SYSTEM_COUNT 1
262#define PLATFORM_CLUSTER_COUNT 2
263#define PLATFORM_CLUSTER0_CORE_COUNT 4
264#define PLATFORM_CLUSTER1_CORE_COUNT 4
265#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
266 PLATFORM_CLUSTER0_CORE_COUNT)
267#define PLATFORM_MAX_CPUS_PER_CLUSTER 4
268#define PLATFORM_NUM_AFFS (PLATFORM_SYSTEM_COUNT + \
269 PLATFORM_CLUSTER_COUNT + \
270 PLATFORM_CORE_COUNT)
271
272/*******************************************************************************
273 * Platform memory map related constants
274 ******************************************************************************/
275
276#define TZRAM_BASE 0x54600000
Hung-Te Linc05a0b52019-05-02 21:42:41 +0800277#define TZRAM_SIZE 0x00030000
developer1033ea12019-04-10 21:09:26 +0800278
279/*******************************************************************************
280 * BL31 specific defines.
281 ******************************************************************************/
282/*
283 * Put BL31 at the top of the Trusted SRAM (just below the shared memory, if
284 * present). BL31_BASE is calculated using the current BL31 debug size plus a
285 * little space for growth.
286 */
287#define BL31_BASE (TZRAM_BASE + 0x1000)
288#define BL31_LIMIT (TZRAM_BASE + TZRAM_SIZE)
289
290/*******************************************************************************
291 * Platform specific page table and MMU setup constants
292 ******************************************************************************/
293#define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32)
294#define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32)
Hung-Te Linc05a0b52019-05-02 21:42:41 +0800295#define MAX_XLAT_TABLES 16
developer1033ea12019-04-10 21:09:26 +0800296#define MAX_MMAP_REGIONS 16
297
298/*******************************************************************************
299 * Declarations and constants to access the mailboxes safely. Each mailbox is
300 * aligned on the biggest cache line size in the platform. This is known only
301 * to the platform as it might have a combination of integrated and external
302 * caches. Such alignment ensures that two maiboxes do not sit on the same cache
303 * line at any cache level. They could belong to different cpus/clusters &
304 * get written while being protected by different locks causing corruption of
305 * a valid mailbox address.
306 ******************************************************************************/
307#define CACHE_WRITEBACK_SHIFT 6
308#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
309#endif /* PLATFORM_DEF_H */