Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 1 | /* |
Khandelwal | 368564c | 2020-01-29 16:51:42 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved. |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef PLATFORM_DEF_H |
| 8 | #define PLATFORM_DEF_H |
| 9 | |
| 10 | #include <lib/utils_def.h> |
| 11 | #include <lib/xlat_tables/xlat_tables_defs.h> |
| 12 | #include <plat/arm/board/common/v2m_def.h> |
| 13 | #include <plat/arm/common/arm_spm_def.h> |
| 14 | #include <plat/common/common_def.h> |
| 15 | |
| 16 | /* Core/Cluster/Thread counts for Corstone700 */ |
Deepika Bhavnani | 4287c0c | 2019-12-13 10:23:18 -0600 | [diff] [blame] | 17 | #define CORSTONE700_CLUSTER_COUNT U(1) |
| 18 | #define CORSTONE700_MAX_CPUS_PER_CLUSTER U(4) |
| 19 | #define CORSTONE700_MAX_PE_PER_CPU U(1) |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 20 | |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 21 | #define PLAT_ARM_CLUSTER_COUNT CORSTONE700_CLUSTER_COUNT |
| 22 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 23 | #define PLATFORM_CORE_COUNT (PLAT_ARM_CLUSTER_COUNT * \ |
| 24 | CORSTONE700_MAX_CPUS_PER_CLUSTER * \ |
| 25 | CORSTONE700_MAX_PE_PER_CPU) |
| 26 | |
| 27 | |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 28 | /* UART related constants */ |
| 29 | #define PLAT_ARM_BOOT_UART_BASE 0x1a510000 |
| 30 | #define PLAT_ARM_BOOT_UART_CLK_IN_HZ V2M_IOFPGA_UART0_CLK_IN_HZ |
| 31 | #define PLAT_ARM_RUN_UART_BASE 0x1a520000 |
| 32 | #define PLAT_ARM_RUN_UART_CLK_IN_HZ V2M_IOFPGA_UART1_CLK_IN_HZ |
| 33 | #define ARM_CONSOLE_BAUDRATE 115200 |
| 34 | #define PLAT_ARM_CRASH_UART_BASE PLAT_ARM_RUN_UART_BASE |
| 35 | #define PLAT_ARM_CRASH_UART_CLK_IN_HZ PLAT_ARM_RUN_UART_CLK_IN_HZ |
| 36 | |
| 37 | /* Memory related constants */ |
| 38 | #define ARM_DRAM1_BASE UL(0x80000000) |
| 39 | #define ARM_DRAM1_SIZE UL(0x80000000) |
| 40 | #define ARM_DRAM1_END (ARM_DRAM1_BASE + \ |
| 41 | ARM_DRAM1_SIZE - 1) |
| 42 | #define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE |
| 43 | #define ARM_NS_DRAM1_SIZE ARM_DRAM1_SIZE |
| 44 | #define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \ |
| 45 | ARM_NS_DRAM1_SIZE - 1) |
| 46 | #define ARM_TRUSTED_SRAM_BASE UL(0x02000000) |
| 47 | #define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE |
| 48 | #define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */ |
| 49 | #define PLAT_ARM_TRUSTED_SRAM_SIZE 0x00040000 /* 256 KB */ |
| 50 | |
| 51 | /* The remaining Trusted SRAM is used to load the BL images */ |
| 52 | #define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \ |
| 53 | ARM_SHARED_RAM_SIZE) |
| 54 | #define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \ |
| 55 | ARM_SHARED_RAM_SIZE) |
| 56 | |
| 57 | /* |
| 58 | * SP_MIN is the only BL image in SRAM. Allocate the whole of SRAM (excluding |
| 59 | * the page reserved for fw_configs) to BL32 |
| 60 | */ |
| 61 | #define BL32_BASE (ARM_BL_RAM_BASE + PAGE_SIZE) |
| 62 | #define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE) |
| 63 | |
| 64 | /* |
| 65 | * Some data must be aligned on the biggest cache line size in the platform. |
| 66 | * This is known only to the platform as it might have a combination of |
| 67 | * integrated and external caches. |
| 68 | */ |
| 69 | #define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT) |
| 70 | #define ARM_CACHE_WRITEBACK_SHIFT 6 |
| 71 | |
| 72 | /* |
| 73 | * To enable TB_FW_CONFIG to be loaded by BL1, define the corresponding base |
| 74 | * and limit. Leave enough space for BL2 meminfo. |
| 75 | */ |
| 76 | #define ARM_TB_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t)) |
| 77 | #define ARM_TB_FW_CONFIG_LIMIT (ARM_BL_RAM_BASE + (PAGE_SIZE / 2U)) |
| 78 | |
| 79 | /* |
| 80 | * The max number of regions like RO(code), coherent and data required by |
| 81 | * different BL stages which need to be mapped in the MMU. |
| 82 | */ |
| 83 | #define ARM_BL_REGIONS 2 |
| 84 | #define PLAT_ARM_MMAP_ENTRIES 8 |
| 85 | #define MAX_XLAT_TABLES 5 |
| 86 | #define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \ |
| 87 | ARM_BL_REGIONS) |
| 88 | |
| 89 | /* GIC related constants */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 90 | #define PLAT_ARM_GICD_BASE 0x1C010000 |
| 91 | #define PLAT_ARM_GICC_BASE 0x1C02F000 |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 92 | |
Khandelwal | 368564c | 2020-01-29 16:51:42 +0000 | [diff] [blame] | 93 | /* MHUv2 Secure Channel receiver and sender */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 94 | #define PLAT_SDK700_MHU0_SEND 0x1B800000 |
| 95 | #define PLAT_SDK700_MHU0_RECV 0x1B810000 |
Khandelwal | 368564c | 2020-01-29 16:51:42 +0000 | [diff] [blame] | 96 | |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 97 | /* Timer/watchdog related constants */ |
| 98 | #define ARM_SYS_CNTCTL_BASE UL(0x1a200000) |
| 99 | #define ARM_SYS_CNTREAD_BASE UL(0x1a210000) |
| 100 | #define ARM_SYS_TIMCTL_BASE UL(0x1a220000) |
| 101 | #define CORSTONE700_TIMER_BASE_FREQUENCY UL(24000000) |
| 102 | #define CORSTONE700_IRQ_TZ_WDOG 32 |
| 103 | #define CORSTONE700_IRQ_SEC_SYS_TIMER 34 |
| 104 | |
| 105 | #define PLAT_MAX_PWR_LVL 2 |
| 106 | /* |
| 107 | * Macros mapping the MPIDR Affinity levels to ARM Platform Power levels. The |
| 108 | * power levels have a 1:1 mapping with the MPIDR affinity levels. |
| 109 | */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 110 | #define ARM_PWR_LVL0 MPIDR_AFFLVL0 |
| 111 | #define ARM_PWR_LVL1 MPIDR_AFFLVL1 |
| 112 | #define ARM_PWR_LVL2 MPIDR_AFFLVL2 |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 113 | |
| 114 | /* |
| 115 | * Macros for local power states in ARM platforms encoded by State-ID field |
| 116 | * within the power-state parameter. |
| 117 | */ |
| 118 | /* Local power state for power domains in Run state. */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 119 | #define ARM_LOCAL_STATE_RUN U(0) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 120 | /* Local power state for retention. Valid only for CPU power domains */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 121 | #define ARM_LOCAL_STATE_RET U(1) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 122 | /* Local power state for OFF/power-down. Valid for CPU and cluster |
| 123 | * power domains |
| 124 | */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 125 | #define ARM_LOCAL_STATE_OFF U(2) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 126 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 127 | #define PLAT_ARM_TRUSTED_MAILBOX_BASE ARM_TRUSTED_SRAM_BASE |
| 128 | #define PLAT_ARM_NSTIMER_FRAME_ID U(1) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 129 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 130 | #define PLAT_ARM_NS_IMAGE_OFFSET (ARM_DRAM1_BASE + UL(0x8000000)) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 131 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 132 | #define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32) |
| 133 | #define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 134 | |
| 135 | /* |
| 136 | * This macro defines the deepest retention state possible. A higher state |
| 137 | * ID will represent an invalid or a power down state. |
| 138 | */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 139 | #define PLAT_MAX_RET_STATE 1 |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 140 | |
| 141 | /* |
| 142 | * This macro defines the deepest power down states possible. Any state ID |
| 143 | * higher than this is invalid. |
| 144 | */ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 145 | #define PLAT_MAX_OFF_STATE 2 |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 146 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 147 | #define PLATFORM_STACK_SIZE UL(0x440) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 148 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 149 | #define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \ |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 150 | ARM_SHARED_RAM_BASE, \ |
| 151 | ARM_SHARED_RAM_SIZE, \ |
| 152 | MT_DEVICE | MT_RW | MT_SECURE) |
| 153 | |
| 154 | #define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \ |
| 155 | ARM_NS_DRAM1_BASE, \ |
| 156 | ARM_NS_DRAM1_SIZE, \ |
| 157 | MT_MEMORY | MT_RW | MT_NS) |
| 158 | |
| 159 | #define ARM_MAP_BL_RO MAP_REGION_FLAT( \ |
| 160 | BL_CODE_BASE, \ |
| 161 | BL_CODE_END \ |
| 162 | - BL_CODE_BASE, \ |
| 163 | MT_CODE | MT_SECURE), \ |
| 164 | MAP_REGION_FLAT( \ |
| 165 | BL_RO_DATA_BASE, \ |
| 166 | BL_RO_DATA_END \ |
| 167 | - BL_RO_DATA_BASE, \ |
| 168 | MT_RO_DATA | MT_SECURE) |
| 169 | #if USE_COHERENT_MEM |
| 170 | #define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \ |
| 171 | BL_COHERENT_RAM_BASE, \ |
| 172 | BL_COHERENT_RAM_END \ |
| 173 | - BL_COHERENT_RAM_BASE, \ |
| 174 | MT_DEVICE | MT_RW | MT_SECURE) |
| 175 | #endif |
| 176 | |
| 177 | #define CORSTONE700_DEVICE_BASE (0x1A000000) |
| 178 | #define CORSTONE700_DEVICE_SIZE (0x26000000) |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 179 | #define CORSTONE700_MAP_DEVICE MAP_REGION_FLAT( \ |
| 180 | CORSTONE700_DEVICE_BASE,\ |
| 181 | CORSTONE700_DEVICE_SIZE,\ |
| 182 | MT_DEVICE | MT_RW | MT_SECURE) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 183 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 184 | #define ARM_IRQ_SEC_PHY_TIMER 29 |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 185 | |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 186 | #define ARM_IRQ_SEC_SGI_0 8 |
| 187 | #define ARM_IRQ_SEC_SGI_1 9 |
| 188 | #define ARM_IRQ_SEC_SGI_2 10 |
| 189 | #define ARM_IRQ_SEC_SGI_3 11 |
| 190 | #define ARM_IRQ_SEC_SGI_4 12 |
| 191 | #define ARM_IRQ_SEC_SGI_5 13 |
| 192 | #define ARM_IRQ_SEC_SGI_6 14 |
| 193 | #define ARM_IRQ_SEC_SGI_7 15 |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 194 | |
| 195 | /* |
| 196 | * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3 |
| 197 | * terminology. On a GICv2 system or mode, the lists will be merged and treated |
| 198 | * as Group 0 interrupts. |
| 199 | */ |
| 200 | #define ARM_G1S_IRQ_PROPS(grp) \ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 201 | INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, \ |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 202 | (grp), GIC_INTR_CFG_LEVEL), \ |
| 203 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, \ |
| 204 | (grp), GIC_INTR_CFG_EDGE), \ |
| 205 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, \ |
| 206 | (grp), GIC_INTR_CFG_EDGE), \ |
| 207 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, \ |
| 208 | (grp), GIC_INTR_CFG_EDGE), \ |
| 209 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, \ |
| 210 | (grp), GIC_INTR_CFG_EDGE), \ |
| 211 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, \ |
| 212 | (grp), GIC_INTR_CFG_EDGE), \ |
| 213 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, \ |
| 214 | (grp), GIC_INTR_CFG_EDGE) |
| 215 | |
| 216 | #define ARM_G0_IRQ_PROPS(grp) \ |
| 217 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \ |
| 218 | GIC_INTR_CFG_EDGE) |
| 219 | |
| 220 | /* |
| 221 | * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3 |
| 222 | * terminology. On a GICv2 system or mode, the lists will be merged and treated |
| 223 | * as Group 0 interrupts. |
| 224 | */ |
| 225 | #define PLAT_ARM_G1S_IRQ_PROPS(grp) \ |
Avinash Mehta | d46b58c | 2019-07-11 16:23:43 +0100 | [diff] [blame^] | 226 | ARM_G1S_IRQ_PROPS(grp), \ |
| 227 | INTR_PROP_DESC(CORSTONE700_IRQ_TZ_WDOG, GIC_HIGHEST_SEC_PRIORITY, \ |
| 228 | (grp), GIC_INTR_CFG_LEVEL), \ |
| 229 | INTR_PROP_DESC(CORSTONE700_IRQ_SEC_SYS_TIMER, \ |
| 230 | GIC_HIGHEST_SEC_PRIORITY, (grp), GIC_INTR_CFG_LEVEL) |
Manish Pandey | 52990ae | 2018-11-28 11:20:37 +0000 | [diff] [blame] | 231 | |
| 232 | #define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp) |
| 233 | |
| 234 | #endif /* PLATFORM_DEF_H */ |