Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 1 | /* |
Yann Gautier | 230bf91 | 2021-09-15 11:30:25 +0200 | [diff] [blame] | 2 | * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved. |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [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 <arch.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <drivers/arm/gic_common.h> |
| 12 | #include <lib/utils_def.h> |
| 13 | #include <plat/common/common_def.h> |
| 14 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 15 | #include "../stm32mp1_def.h" |
| 16 | |
| 17 | /******************************************************************************* |
| 18 | * Generic platform constants |
| 19 | ******************************************************************************/ |
| 20 | |
| 21 | /* Size of cacheable stacks */ |
Yann Gautier | 9d135e4 | 2018-07-16 19:36:06 +0200 | [diff] [blame] | 22 | #if defined(IMAGE_BL32) |
| 23 | #define PLATFORM_STACK_SIZE 0x600 |
| 24 | #else |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 25 | #define PLATFORM_STACK_SIZE 0xC00 |
Yann Gautier | 9d135e4 | 2018-07-16 19:36:06 +0200 | [diff] [blame] | 26 | #endif |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 27 | |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 28 | #if STM32MP_USE_STM32IMAGE |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 29 | #ifdef AARCH32_SP_OPTEE |
| 30 | #define OPTEE_HEADER_IMAGE_NAME "teeh" |
Yann Gautier | ebf15ba | 2021-05-19 16:10:25 +0200 | [diff] [blame] | 31 | #define OPTEE_CORE_IMAGE_NAME "teex" |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 32 | #define OPTEE_PAGED_IMAGE_NAME "teed" |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 33 | #define OPTEE_HEADER_BINARY_TYPE U(0x20) |
Yann Gautier | ebf15ba | 2021-05-19 16:10:25 +0200 | [diff] [blame] | 34 | #define OPTEE_CORE_BINARY_TYPE U(0x21) |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 35 | #define OPTEE_PAGED_BINARY_TYPE U(0x22) |
| 36 | #endif |
| 37 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 38 | /* SSBL = second stage boot loader */ |
| 39 | #define BL33_IMAGE_NAME "ssbl" |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 40 | #define BL33_BINARY_TYPE U(0x0) |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 41 | #else /* STM32MP_USE_STM32IMAGE */ |
| 42 | #define FIP_IMAGE_NAME "fip" |
| 43 | #endif /* STM32MP_USE_STM32IMAGE */ |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 44 | |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 45 | #define STM32MP_PRIMARY_CPU U(0x0) |
| 46 | #define STM32MP_SECONDARY_CPU U(0x1) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 47 | |
Deepika Bhavnani | 3184eea | 2019-12-13 10:53:12 -0600 | [diff] [blame] | 48 | #define PLATFORM_CLUSTER_COUNT U(1) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 49 | #define PLATFORM_CLUSTER0_CORE_COUNT U(2) |
| 50 | #define PLATFORM_CLUSTER1_CORE_COUNT U(0) |
| 51 | #define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \ |
| 52 | PLATFORM_CLUSTER0_CORE_COUNT) |
| 53 | #define PLATFORM_MAX_CPUS_PER_CLUSTER 2 |
| 54 | |
Yann Gautier | f9d40d5 | 2019-01-17 14:41:46 +0100 | [diff] [blame] | 55 | #define MAX_IO_DEVICES U(4) |
| 56 | #define MAX_IO_HANDLES U(4) |
| 57 | #define MAX_IO_BLOCK_DEVICES U(1) |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 58 | #define MAX_IO_MTD_DEVICES U(1) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 59 | |
| 60 | /******************************************************************************* |
| 61 | * BL2 specific defines. |
| 62 | ******************************************************************************/ |
| 63 | /* |
| 64 | * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug |
| 65 | * size plus a little space for growth. |
| 66 | */ |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 67 | #define BL2_BASE STM32MP_BL2_BASE |
| 68 | #define BL2_LIMIT (STM32MP_BL2_BASE + \ |
| 69 | STM32MP_BL2_SIZE) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 70 | |
Yann Gautier | 230bf91 | 2021-09-15 11:30:25 +0200 | [diff] [blame] | 71 | #define BL2_RO_BASE STM32MP_BL2_RO_BASE |
| 72 | #define BL2_RO_LIMIT (STM32MP_BL2_RO_BASE + \ |
| 73 | STM32MP_BL2_RO_SIZE) |
| 74 | |
| 75 | #define BL2_RW_BASE STM32MP_BL2_RW_BASE |
| 76 | #define BL2_RW_LIMIT (STM32MP_BL2_RW_BASE + \ |
| 77 | STM32MP_BL2_RW_SIZE) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 78 | /******************************************************************************* |
| 79 | * BL32 specific defines. |
| 80 | ******************************************************************************/ |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 81 | #if STM32MP_USE_STM32IMAGE || defined(IMAGE_BL32) |
Yann Gautier | dca6154 | 2021-02-10 18:19:23 +0100 | [diff] [blame] | 82 | #if ENABLE_PIE |
| 83 | #define BL32_BASE 0 |
| 84 | #define BL32_LIMIT STM32MP_BL32_SIZE |
| 85 | #else |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 86 | #define BL32_BASE STM32MP_BL32_BASE |
| 87 | #define BL32_LIMIT (STM32MP_BL32_BASE + \ |
| 88 | STM32MP_BL32_SIZE) |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 89 | #endif |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 90 | #endif /* STM32MP_USE_STM32IMAGE || defined(IMAGE_BL32) */ |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 91 | |
| 92 | /******************************************************************************* |
| 93 | * BL33 specific defines. |
| 94 | ******************************************************************************/ |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 95 | #define BL33_BASE STM32MP_BL33_BASE |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * Load address of BL33 for this platform port |
| 99 | */ |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 100 | #define PLAT_STM32MP_NS_IMAGE_OFFSET BL33_BASE |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 101 | |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 102 | /* Needed by STM32CubeProgrammer support */ |
| 103 | #define DWL_BUFFER_BASE (STM32MP_DDR_BASE + U(0x08000000)) |
| 104 | #define DWL_BUFFER_SIZE U(0x08000000) |
| 105 | |
Vyacheslav Yurkov | e43a080 | 2021-06-04 10:10:51 +0200 | [diff] [blame] | 106 | /* |
| 107 | * SSBL offset in case it's stored in eMMC boot partition. |
| 108 | * We can fix it to 256K because TF-A size can't be bigger than SRAM |
| 109 | */ |
| 110 | #define PLAT_EMMC_BOOT_SSBL_OFFSET U(0x40000) |
| 111 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 112 | /******************************************************************************* |
| 113 | * DTB specific defines. |
| 114 | ******************************************************************************/ |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 115 | #define DTB_BASE STM32MP_DTB_BASE |
| 116 | #define DTB_LIMIT (STM32MP_DTB_BASE + \ |
| 117 | STM32MP_DTB_SIZE) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 118 | |
| 119 | /******************************************************************************* |
| 120 | * Platform specific page table and MMU setup constants |
| 121 | ******************************************************************************/ |
Yann Gautier | f9d40d5 | 2019-01-17 14:41:46 +0100 | [diff] [blame] | 122 | #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32) |
| 123 | #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 124 | |
| 125 | /******************************************************************************* |
| 126 | * Declarations and constants to access the mailboxes safely. Each mailbox is |
| 127 | * aligned on the biggest cache line size in the platform. This is known only |
| 128 | * to the platform as it might have a combination of integrated and external |
| 129 | * caches. Such alignment ensures that two maiboxes do not sit on the same cache |
| 130 | * line at any cache level. They could belong to different cpus/clusters & |
| 131 | * get written while being protected by different locks causing corruption of |
| 132 | * a valid mailbox address. |
| 133 | ******************************************************************************/ |
| 134 | #define CACHE_WRITEBACK_SHIFT 6 |
| 135 | #define CACHE_WRITEBACK_GRANULE (U(1) << CACHE_WRITEBACK_SHIFT) |
| 136 | |
| 137 | /* |
| 138 | * Secure Interrupt: based on the standard ARM mapping |
| 139 | */ |
| 140 | #define ARM_IRQ_SEC_PHY_TIMER U(29) |
| 141 | |
| 142 | #define ARM_IRQ_SEC_SGI_0 U(8) |
| 143 | #define ARM_IRQ_SEC_SGI_1 U(9) |
| 144 | #define ARM_IRQ_SEC_SGI_2 U(10) |
| 145 | #define ARM_IRQ_SEC_SGI_3 U(11) |
| 146 | #define ARM_IRQ_SEC_SGI_4 U(12) |
| 147 | #define ARM_IRQ_SEC_SGI_5 U(13) |
| 148 | #define ARM_IRQ_SEC_SGI_6 U(14) |
| 149 | #define ARM_IRQ_SEC_SGI_7 U(15) |
| 150 | |
| 151 | #define STM32MP1_IRQ_TZC400 U(36) |
| 152 | #define STM32MP1_IRQ_TAMPSERRS U(229) |
| 153 | #define STM32MP1_IRQ_AXIERRIRQ U(244) |
| 154 | |
| 155 | /* |
| 156 | * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3 |
| 157 | * terminology. On a GICv2 system or mode, the lists will be merged and treated |
| 158 | * as Group 0 interrupts. |
| 159 | */ |
| 160 | #define PLATFORM_G1S_PROPS(grp) \ |
| 161 | INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, \ |
| 162 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 163 | grp, GIC_INTR_CFG_LEVEL), \ |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 164 | INTR_PROP_DESC(STM32MP1_IRQ_AXIERRIRQ, \ |
| 165 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 166 | grp, GIC_INTR_CFG_LEVEL), \ |
| 167 | INTR_PROP_DESC(STM32MP1_IRQ_TZC400, \ |
| 168 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 169 | grp, GIC_INTR_CFG_LEVEL), \ |
| 170 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, \ |
| 171 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 172 | grp, GIC_INTR_CFG_EDGE), \ |
| 173 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, \ |
| 174 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 175 | grp, GIC_INTR_CFG_EDGE), \ |
| 176 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, \ |
| 177 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 178 | grp, GIC_INTR_CFG_EDGE), \ |
| 179 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, \ |
| 180 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 181 | grp, GIC_INTR_CFG_EDGE), \ |
| 182 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, \ |
| 183 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 184 | grp, GIC_INTR_CFG_EDGE), \ |
| 185 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, \ |
| 186 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 187 | grp, GIC_INTR_CFG_EDGE) |
| 188 | |
| 189 | #define PLATFORM_G0_PROPS(grp) \ |
| 190 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, \ |
| 191 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 192 | grp, GIC_INTR_CFG_EDGE), \ |
| 193 | INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, \ |
| 194 | GIC_HIGHEST_SEC_PRIORITY, \ |
| 195 | grp, GIC_INTR_CFG_EDGE) |
| 196 | |
| 197 | /* |
| 198 | * Power |
| 199 | */ |
| 200 | #define PLAT_MAX_PWR_LVL U(1) |
| 201 | |
| 202 | /* Local power state for power domains in Run state. */ |
| 203 | #define ARM_LOCAL_STATE_RUN U(0) |
| 204 | /* Local power state for retention. Valid only for CPU power domains */ |
| 205 | #define ARM_LOCAL_STATE_RET U(1) |
| 206 | /* Local power state for power-down. Valid for CPU and cluster power domains */ |
| 207 | #define ARM_LOCAL_STATE_OFF U(2) |
| 208 | /* |
| 209 | * This macro defines the deepest retention state possible. |
| 210 | * A higher state id will represent an invalid or a power down state. |
| 211 | */ |
| 212 | #define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET |
| 213 | /* |
| 214 | * This macro defines the deepest power down states possible. Any state ID |
| 215 | * higher than this is invalid. |
| 216 | */ |
| 217 | #define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF |
| 218 | |
| 219 | /******************************************************************************* |
| 220 | * Size of the per-cpu data in bytes that should be reserved in the generic |
| 221 | * per-cpu data structure for the FVP port. |
| 222 | ******************************************************************************/ |
| 223 | #define PLAT_PCPU_DATA_SIZE 2 |
| 224 | |
Etienne Carriere | 34f0e93 | 2020-07-16 17:36:18 +0200 | [diff] [blame] | 225 | /******************************************************************************* |
| 226 | * Number of parallel entry slots in SMT SCMI server entry context. For this |
| 227 | * platform, SCMI server is reached through SMC only, hence the number of |
| 228 | * entry slots. |
| 229 | ******************************************************************************/ |
| 230 | #define PLAT_SMT_ENTRY_COUNT PLATFORM_CORE_COUNT |
| 231 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 232 | #endif /* PLATFORM_DEF_H */ |