1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu #ifndef PLATFORM_DEF_H 8*91f16700Schasinglulu #define PLATFORM_DEF_H 9*91f16700Schasinglulu 10*91f16700Schasinglulu #include <arch.h> 11*91f16700Schasinglulu #include <plat/common/common_def.h> 12*91f16700Schasinglulu 13*91f16700Schasinglulu #include <board_def.h> 14*91f16700Schasinglulu 15*91f16700Schasinglulu /******************************************************************************* 16*91f16700Schasinglulu * Generic platform constants 17*91f16700Schasinglulu ******************************************************************************/ 18*91f16700Schasinglulu 19*91f16700Schasinglulu /* Size of cacheable stack */ 20*91f16700Schasinglulu #if IMAGE_BL31 21*91f16700Schasinglulu #define PLATFORM_STACK_SIZE 0x800 22*91f16700Schasinglulu #else 23*91f16700Schasinglulu #define PLATFORM_STACK_SIZE 0x1000 24*91f16700Schasinglulu #endif 25*91f16700Schasinglulu 26*91f16700Schasinglulu #define PLATFORM_SYSTEM_COUNT 1 27*91f16700Schasinglulu #define PLATFORM_CORE_COUNT (K3_CLUSTER0_CORE_COUNT + \ 28*91f16700Schasinglulu K3_CLUSTER1_CORE_COUNT + \ 29*91f16700Schasinglulu K3_CLUSTER2_CORE_COUNT + \ 30*91f16700Schasinglulu K3_CLUSTER3_CORE_COUNT) 31*91f16700Schasinglulu 32*91f16700Schasinglulu #define PLATFORM_CLUSTER_COUNT ((K3_CLUSTER0_CORE_COUNT != 0) + \ 33*91f16700Schasinglulu (K3_CLUSTER1_CORE_COUNT != 0) + \ 34*91f16700Schasinglulu (K3_CLUSTER2_CORE_COUNT != 0) + \ 35*91f16700Schasinglulu (K3_CLUSTER3_CORE_COUNT != 0)) 36*91f16700Schasinglulu 37*91f16700Schasinglulu #define PLAT_NUM_PWR_DOMAINS (PLATFORM_SYSTEM_COUNT + \ 38*91f16700Schasinglulu PLATFORM_CLUSTER_COUNT + \ 39*91f16700Schasinglulu PLATFORM_CORE_COUNT) 40*91f16700Schasinglulu #define PLAT_MAX_PWR_LVL MPIDR_AFFLVL2 41*91f16700Schasinglulu #define PLAT_MAX_OFF_STATE U(2) 42*91f16700Schasinglulu #define PLAT_MAX_RET_STATE U(1) 43*91f16700Schasinglulu 44*91f16700Schasinglulu /******************************************************************************* 45*91f16700Schasinglulu * Memory layout constants 46*91f16700Schasinglulu ******************************************************************************/ 47*91f16700Schasinglulu 48*91f16700Schasinglulu /* 49*91f16700Schasinglulu * This RAM will be used for the bootloader including code, bss, and stacks. 50*91f16700Schasinglulu * It may need to be increased if BL31 grows in size. 51*91f16700Schasinglulu * 52*91f16700Schasinglulu * The link addresses are determined by BL31_BASE + offset. 53*91f16700Schasinglulu * When ENABLE_PIE is set, the TF images can be loaded anywhere, so 54*91f16700Schasinglulu * BL31_BASE is really arbitrary. 55*91f16700Schasinglulu * 56*91f16700Schasinglulu * When ENABLE_PIE is unset, BL31_BASE should be chosen so that 57*91f16700Schasinglulu * it matches to the physical address where BL31 is loaded, that is, 58*91f16700Schasinglulu * BL31_BASE should be the base address of the RAM region. 59*91f16700Schasinglulu * 60*91f16700Schasinglulu * Lets make things explicit by mapping BL31_BASE to 0x0 since ENABLE_PIE is 61*91f16700Schasinglulu * defined as default for our platform. 62*91f16700Schasinglulu */ 63*91f16700Schasinglulu #define BL31_BASE UL(0x00000000) /* PIE remapped on fly */ 64*91f16700Schasinglulu #define BL31_SIZE UL(0x00020000) /* 128k */ 65*91f16700Schasinglulu #define BL31_LIMIT (BL31_BASE + BL31_SIZE) 66*91f16700Schasinglulu 67*91f16700Schasinglulu /* 68*91f16700Schasinglulu * Defines the maximum number of translation tables that are allocated by the 69*91f16700Schasinglulu * translation table library code. To minimize the amount of runtime memory 70*91f16700Schasinglulu * used, choose the smallest value needed to map the required virtual addresses 71*91f16700Schasinglulu * for each BL stage. 72*91f16700Schasinglulu */ 73*91f16700Schasinglulu #define MAX_XLAT_TABLES 4 74*91f16700Schasinglulu 75*91f16700Schasinglulu /* 76*91f16700Schasinglulu * Defines the maximum number of regions that are allocated by the translation 77*91f16700Schasinglulu * table library code. A region consists of physical base address, virtual base 78*91f16700Schasinglulu * address, size and attributes (Device/Memory, RO/RW, Secure/Non-Secure), as 79*91f16700Schasinglulu * defined in the `mmap_region_t` structure. The platform defines the regions 80*91f16700Schasinglulu * that should be mapped. Then, the translation table library will create the 81*91f16700Schasinglulu * corresponding tables and descriptors at runtime. To minimize the amount of 82*91f16700Schasinglulu * runtime memory used, choose the smallest value needed to register the 83*91f16700Schasinglulu * required regions for each BL stage. 84*91f16700Schasinglulu */ 85*91f16700Schasinglulu #if USE_COHERENT_MEM 86*91f16700Schasinglulu #define MAX_MMAP_REGIONS 11 87*91f16700Schasinglulu #else 88*91f16700Schasinglulu #define MAX_MMAP_REGIONS 10 89*91f16700Schasinglulu #endif 90*91f16700Schasinglulu 91*91f16700Schasinglulu /* 92*91f16700Schasinglulu * Defines the total size of the address space in bytes. For example, for a 32 93*91f16700Schasinglulu * bit address space, this value should be `(1ull << 32)`. 94*91f16700Schasinglulu */ 95*91f16700Schasinglulu #define PLAT_PHY_ADDR_SPACE_SIZE (1ull << 32) 96*91f16700Schasinglulu #define PLAT_VIRT_ADDR_SPACE_SIZE (1ull << 32) 97*91f16700Schasinglulu 98*91f16700Schasinglulu /* 99*91f16700Schasinglulu * Some data must be aligned on the biggest cache line size in the platform. 100*91f16700Schasinglulu * This is known only to the platform as it might have a combination of 101*91f16700Schasinglulu * integrated and external caches. 102*91f16700Schasinglulu */ 103*91f16700Schasinglulu #define CACHE_WRITEBACK_SHIFT 6 104*91f16700Schasinglulu #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) 105*91f16700Schasinglulu 106*91f16700Schasinglulu /* Platform default console definitions */ 107*91f16700Schasinglulu #ifndef K3_USART_BASE 108*91f16700Schasinglulu #define K3_USART_BASE (0x02800000 + 0x10000 * K3_USART) 109*91f16700Schasinglulu #endif 110*91f16700Schasinglulu 111*91f16700Schasinglulu /* USART has a default size for address space */ 112*91f16700Schasinglulu #define K3_USART_SIZE 0x1000 113*91f16700Schasinglulu 114*91f16700Schasinglulu #ifndef K3_USART_CLK_SPEED 115*91f16700Schasinglulu #define K3_USART_CLK_SPEED 48000000 116*91f16700Schasinglulu #endif 117*91f16700Schasinglulu 118*91f16700Schasinglulu /* Crash console defaults */ 119*91f16700Schasinglulu #define CRASH_CONSOLE_BASE K3_USART_BASE 120*91f16700Schasinglulu #define CRASH_CONSOLE_CLK K3_USART_CLK_SPEED 121*91f16700Schasinglulu #define CRASH_CONSOLE_BAUD_RATE K3_USART_BAUD 122*91f16700Schasinglulu 123*91f16700Schasinglulu /* Timer frequency */ 124*91f16700Schasinglulu #ifndef SYS_COUNTER_FREQ_IN_TICKS 125*91f16700Schasinglulu #define SYS_COUNTER_FREQ_IN_TICKS 200000000 126*91f16700Schasinglulu #endif 127*91f16700Schasinglulu 128*91f16700Schasinglulu /* Interrupt numbers */ 129*91f16700Schasinglulu #define ARM_IRQ_SEC_PHY_TIMER 29 130*91f16700Schasinglulu 131*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_0 8 132*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_1 9 133*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_2 10 134*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_3 11 135*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_4 12 136*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_5 13 137*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_6 14 138*91f16700Schasinglulu #define ARM_IRQ_SEC_SGI_7 15 139*91f16700Schasinglulu 140*91f16700Schasinglulu /* 141*91f16700Schasinglulu * Define properties of Group 1 Secure and Group 0 interrupts as per GICv3 142*91f16700Schasinglulu * terminology. On a GICv2 system or mode, the lists will be merged and treated 143*91f16700Schasinglulu * as Group 0 interrupts. 144*91f16700Schasinglulu */ 145*91f16700Schasinglulu #define PLAT_ARM_G1S_IRQ_PROPS(grp) \ 146*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, grp, \ 147*91f16700Schasinglulu GIC_INTR_CFG_LEVEL), \ 148*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, grp, \ 149*91f16700Schasinglulu GIC_INTR_CFG_EDGE), \ 150*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, grp, \ 151*91f16700Schasinglulu GIC_INTR_CFG_EDGE), \ 152*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, grp, \ 153*91f16700Schasinglulu GIC_INTR_CFG_EDGE), \ 154*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, grp, \ 155*91f16700Schasinglulu GIC_INTR_CFG_EDGE), \ 156*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, grp, \ 157*91f16700Schasinglulu GIC_INTR_CFG_EDGE), \ 158*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \ 159*91f16700Schasinglulu GIC_INTR_CFG_EDGE) 160*91f16700Schasinglulu 161*91f16700Schasinglulu #define PLAT_ARM_G0_IRQ_PROPS(grp) \ 162*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, grp, \ 163*91f16700Schasinglulu GIC_INTR_CFG_EDGE), \ 164*91f16700Schasinglulu INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, grp, \ 165*91f16700Schasinglulu GIC_INTR_CFG_EDGE) 166*91f16700Schasinglulu 167*91f16700Schasinglulu 168*91f16700Schasinglulu #define K3_GTC_BASE 0x00A90000 169*91f16700Schasinglulu /* We just need 20 byte offset, but simpler to just remap the 64K page in */ 170*91f16700Schasinglulu #define K3_GTC_SIZE 0x10000 171*91f16700Schasinglulu #define K3_GTC_CNTCR_OFFSET 0x00 172*91f16700Schasinglulu #define K3_GTC_CNTCR_EN_MASK 0x01 173*91f16700Schasinglulu #define K3_GTC_CNTCR_HDBG_MASK 0x02 174*91f16700Schasinglulu #define K3_GTC_CNTFID0_OFFSET 0x20 175*91f16700Schasinglulu 176*91f16700Schasinglulu #define K3_GIC_BASE 0x01800000 177*91f16700Schasinglulu #define K3_GIC_SIZE 0x200000 178*91f16700Schasinglulu 179*91f16700Schasinglulu #if !K3_SEC_PROXY_LITE 180*91f16700Schasinglulu #define SEC_PROXY_DATA_BASE 0x32C00000 181*91f16700Schasinglulu #define SEC_PROXY_DATA_SIZE 0x80000 182*91f16700Schasinglulu #define SEC_PROXY_SCFG_BASE 0x32800000 183*91f16700Schasinglulu #define SEC_PROXY_SCFG_SIZE 0x80000 184*91f16700Schasinglulu #define SEC_PROXY_RT_BASE 0x32400000 185*91f16700Schasinglulu #define SEC_PROXY_RT_SIZE 0x80000 186*91f16700Schasinglulu #else 187*91f16700Schasinglulu #define SEC_PROXY_DATA_BASE 0x4D000000 188*91f16700Schasinglulu #define SEC_PROXY_DATA_SIZE 0x80000 189*91f16700Schasinglulu #define SEC_PROXY_SCFG_BASE 0x4A400000 190*91f16700Schasinglulu #define SEC_PROXY_SCFG_SIZE 0x80000 191*91f16700Schasinglulu #define SEC_PROXY_RT_BASE 0x4A600000 192*91f16700Schasinglulu #define SEC_PROXY_RT_SIZE 0x80000 193*91f16700Schasinglulu #endif /* K3_SEC_PROXY_LITE */ 194*91f16700Schasinglulu 195*91f16700Schasinglulu #define SEC_PROXY_TIMEOUT_US 1000000 196*91f16700Schasinglulu #define SEC_PROXY_MAX_MESSAGE_SIZE 56 197*91f16700Schasinglulu 198*91f16700Schasinglulu #define TI_SCI_HOST_ID 10 199*91f16700Schasinglulu #define TI_SCI_MAX_MESSAGE_SIZE 52 200*91f16700Schasinglulu 201*91f16700Schasinglulu #endif /* PLATFORM_DEF_H */ 202