blob: 8ecb4c3e434f5bc0db99fc0bf4e59d08dc8d2f3b [file] [log] [blame]
Yann Gautier4b0c72a2018-07-16 10:54:09 +02001/*
Yann Gautier230bf912021-09-15 11:30:25 +02002 * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
Yann Gautier4b0c72a2018-07-16 10:54:09 +02003 *
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 Diaze0f90632018-12-14 00:18:21 +000011#include <drivers/arm/gic_common.h>
12#include <lib/utils_def.h>
13#include <plat/common/common_def.h>
14
Yann Gautier4b0c72a2018-07-16 10:54:09 +020015#include "../stm32mp1_def.h"
16
17/*******************************************************************************
18 * Generic platform constants
19 ******************************************************************************/
20
21/* Size of cacheable stacks */
Yann Gautier9d135e42018-07-16 19:36:06 +020022#if defined(IMAGE_BL32)
23#define PLATFORM_STACK_SIZE 0x600
24#else
Yann Gautier4b0c72a2018-07-16 10:54:09 +020025#define PLATFORM_STACK_SIZE 0xC00
Yann Gautier9d135e42018-07-16 19:36:06 +020026#endif
Yann Gautier4b0c72a2018-07-16 10:54:09 +020027
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020028#if STM32MP_USE_STM32IMAGE
Yann Gautierb3386f72019-04-19 09:41:01 +020029#ifdef AARCH32_SP_OPTEE
30#define OPTEE_HEADER_IMAGE_NAME "teeh"
Yann Gautierebf15ba2021-05-19 16:10:25 +020031#define OPTEE_CORE_IMAGE_NAME "teex"
Yann Gautierb3386f72019-04-19 09:41:01 +020032#define OPTEE_PAGED_IMAGE_NAME "teed"
Yann Gautierb3386f72019-04-19 09:41:01 +020033#define OPTEE_HEADER_BINARY_TYPE U(0x20)
Yann Gautierebf15ba2021-05-19 16:10:25 +020034#define OPTEE_CORE_BINARY_TYPE U(0x21)
Yann Gautierb3386f72019-04-19 09:41:01 +020035#define OPTEE_PAGED_BINARY_TYPE U(0x22)
36#endif
37
Yann Gautier4b0c72a2018-07-16 10:54:09 +020038/* SSBL = second stage boot loader */
39#define BL33_IMAGE_NAME "ssbl"
Yann Gautier8244e1d2018-10-15 09:36:58 +020040#define BL33_BINARY_TYPE U(0x0)
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020041#else /* STM32MP_USE_STM32IMAGE */
42#define FIP_IMAGE_NAME "fip"
Sughosh Ganud1f87132021-12-01 16:46:34 +053043#define METADATA_PART_1 "metadata1"
44#define METADATA_PART_2 "metadata2"
45
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020046#endif /* STM32MP_USE_STM32IMAGE */
Yann Gautier4b0c72a2018-07-16 10:54:09 +020047
Yann Gautiera2e2a302019-02-14 11:13:39 +010048#define STM32MP_PRIMARY_CPU U(0x0)
49#define STM32MP_SECONDARY_CPU U(0x1)
Yann Gautier4b0c72a2018-07-16 10:54:09 +020050
Deepika Bhavnani3184eea2019-12-13 10:53:12 -060051#define PLATFORM_CLUSTER_COUNT U(1)
Yann Gautier4b0c72a2018-07-16 10:54:09 +020052#define PLATFORM_CLUSTER0_CORE_COUNT U(2)
53#define PLATFORM_CLUSTER1_CORE_COUNT U(0)
54#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
55 PLATFORM_CLUSTER0_CORE_COUNT)
56#define PLATFORM_MAX_CPUS_PER_CLUSTER 2
57
Yann Gautierf9d40d52019-01-17 14:41:46 +010058#define MAX_IO_DEVICES U(4)
59#define MAX_IO_HANDLES U(4)
60#define MAX_IO_BLOCK_DEVICES U(1)
Lionel Debieve402a46b2019-11-04 12:28:15 +010061#define MAX_IO_MTD_DEVICES U(1)
Yann Gautier4b0c72a2018-07-16 10:54:09 +020062
63/*******************************************************************************
64 * BL2 specific defines.
65 ******************************************************************************/
66/*
67 * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug
68 * size plus a little space for growth.
69 */
Yann Gautiera2e2a302019-02-14 11:13:39 +010070#define BL2_BASE STM32MP_BL2_BASE
71#define BL2_LIMIT (STM32MP_BL2_BASE + \
72 STM32MP_BL2_SIZE)
Yann Gautier4b0c72a2018-07-16 10:54:09 +020073
Yann Gautier230bf912021-09-15 11:30:25 +020074#define BL2_RO_BASE STM32MP_BL2_RO_BASE
75#define BL2_RO_LIMIT (STM32MP_BL2_RO_BASE + \
76 STM32MP_BL2_RO_SIZE)
77
78#define BL2_RW_BASE STM32MP_BL2_RW_BASE
79#define BL2_RW_LIMIT (STM32MP_BL2_RW_BASE + \
80 STM32MP_BL2_RW_SIZE)
Yann Gautier4b0c72a2018-07-16 10:54:09 +020081/*******************************************************************************
82 * BL32 specific defines.
83 ******************************************************************************/
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020084#if STM32MP_USE_STM32IMAGE || defined(IMAGE_BL32)
Yann Gautierdca61542021-02-10 18:19:23 +010085#if ENABLE_PIE
86#define BL32_BASE 0
87#define BL32_LIMIT STM32MP_BL32_SIZE
88#else
Yann Gautiera2e2a302019-02-14 11:13:39 +010089#define BL32_BASE STM32MP_BL32_BASE
90#define BL32_LIMIT (STM32MP_BL32_BASE + \
91 STM32MP_BL32_SIZE)
Yann Gautierb3386f72019-04-19 09:41:01 +020092#endif
Yann Gautier0ed7b2a2021-05-19 18:48:16 +020093#endif /* STM32MP_USE_STM32IMAGE || defined(IMAGE_BL32) */
Yann Gautier4b0c72a2018-07-16 10:54:09 +020094
95/*******************************************************************************
96 * BL33 specific defines.
97 ******************************************************************************/
Yann Gautiera2e2a302019-02-14 11:13:39 +010098#define BL33_BASE STM32MP_BL33_BASE
Yann Gautier4b0c72a2018-07-16 10:54:09 +020099
100/*
101 * Load address of BL33 for this platform port
102 */
Yann Gautiera2e2a302019-02-14 11:13:39 +0100103#define PLAT_STM32MP_NS_IMAGE_OFFSET BL33_BASE
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200104
Patrick Delaunay9c5ee782021-07-06 14:07:56 +0200105/* Needed by STM32CubeProgrammer support */
106#define DWL_BUFFER_BASE (STM32MP_DDR_BASE + U(0x08000000))
107#define DWL_BUFFER_SIZE U(0x08000000)
108
Vyacheslav Yurkove43a0802021-06-04 10:10:51 +0200109/*
110 * SSBL offset in case it's stored in eMMC boot partition.
111 * We can fix it to 256K because TF-A size can't be bigger than SRAM
112 */
113#define PLAT_EMMC_BOOT_SSBL_OFFSET U(0x40000)
114
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200115/*******************************************************************************
116 * DTB specific defines.
117 ******************************************************************************/
Yann Gautiera2e2a302019-02-14 11:13:39 +0100118#define DTB_BASE STM32MP_DTB_BASE
119#define DTB_LIMIT (STM32MP_DTB_BASE + \
120 STM32MP_DTB_SIZE)
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200121
122/*******************************************************************************
123 * Platform specific page table and MMU setup constants
124 ******************************************************************************/
Yann Gautierf9d40d52019-01-17 14:41:46 +0100125#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
126#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200127
128/*******************************************************************************
129 * Declarations and constants to access the mailboxes safely. Each mailbox is
130 * aligned on the biggest cache line size in the platform. This is known only
131 * to the platform as it might have a combination of integrated and external
132 * caches. Such alignment ensures that two maiboxes do not sit on the same cache
133 * line at any cache level. They could belong to different cpus/clusters &
134 * get written while being protected by different locks causing corruption of
135 * a valid mailbox address.
136 ******************************************************************************/
137#define CACHE_WRITEBACK_SHIFT 6
138#define CACHE_WRITEBACK_GRANULE (U(1) << CACHE_WRITEBACK_SHIFT)
139
140/*
141 * Secure Interrupt: based on the standard ARM mapping
142 */
143#define ARM_IRQ_SEC_PHY_TIMER U(29)
144
145#define ARM_IRQ_SEC_SGI_0 U(8)
146#define ARM_IRQ_SEC_SGI_1 U(9)
147#define ARM_IRQ_SEC_SGI_2 U(10)
148#define ARM_IRQ_SEC_SGI_3 U(11)
149#define ARM_IRQ_SEC_SGI_4 U(12)
150#define ARM_IRQ_SEC_SGI_5 U(13)
151#define ARM_IRQ_SEC_SGI_6 U(14)
152#define ARM_IRQ_SEC_SGI_7 U(15)
153
154#define STM32MP1_IRQ_TZC400 U(36)
155#define STM32MP1_IRQ_TAMPSERRS U(229)
156#define STM32MP1_IRQ_AXIERRIRQ U(244)
157
158/*
159 * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
160 * terminology. On a GICv2 system or mode, the lists will be merged and treated
161 * as Group 0 interrupts.
162 */
163#define PLATFORM_G1S_PROPS(grp) \
164 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, \
165 GIC_HIGHEST_SEC_PRIORITY, \
166 grp, GIC_INTR_CFG_LEVEL), \
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200167 INTR_PROP_DESC(STM32MP1_IRQ_AXIERRIRQ, \
168 GIC_HIGHEST_SEC_PRIORITY, \
169 grp, GIC_INTR_CFG_LEVEL), \
170 INTR_PROP_DESC(STM32MP1_IRQ_TZC400, \
171 GIC_HIGHEST_SEC_PRIORITY, \
172 grp, GIC_INTR_CFG_LEVEL), \
173 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, \
174 GIC_HIGHEST_SEC_PRIORITY, \
175 grp, GIC_INTR_CFG_EDGE), \
176 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, \
177 GIC_HIGHEST_SEC_PRIORITY, \
178 grp, GIC_INTR_CFG_EDGE), \
179 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, \
180 GIC_HIGHEST_SEC_PRIORITY, \
181 grp, GIC_INTR_CFG_EDGE), \
182 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, \
183 GIC_HIGHEST_SEC_PRIORITY, \
184 grp, GIC_INTR_CFG_EDGE), \
185 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, \
186 GIC_HIGHEST_SEC_PRIORITY, \
187 grp, GIC_INTR_CFG_EDGE), \
188 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, \
189 GIC_HIGHEST_SEC_PRIORITY, \
190 grp, GIC_INTR_CFG_EDGE)
191
192#define PLATFORM_G0_PROPS(grp) \
193 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, \
194 GIC_HIGHEST_SEC_PRIORITY, \
195 grp, GIC_INTR_CFG_EDGE), \
196 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, \
197 GIC_HIGHEST_SEC_PRIORITY, \
198 grp, GIC_INTR_CFG_EDGE)
199
200/*
201 * Power
202 */
203#define PLAT_MAX_PWR_LVL U(1)
204
205/* Local power state for power domains in Run state. */
206#define ARM_LOCAL_STATE_RUN U(0)
207/* Local power state for retention. Valid only for CPU power domains */
208#define ARM_LOCAL_STATE_RET U(1)
209/* Local power state for power-down. Valid for CPU and cluster power domains */
210#define ARM_LOCAL_STATE_OFF U(2)
211/*
212 * This macro defines the deepest retention state possible.
213 * A higher state id will represent an invalid or a power down state.
214 */
215#define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET
216/*
217 * This macro defines the deepest power down states possible. Any state ID
218 * higher than this is invalid.
219 */
220#define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF
221
222/*******************************************************************************
223 * Size of the per-cpu data in bytes that should be reserved in the generic
224 * per-cpu data structure for the FVP port.
225 ******************************************************************************/
226#define PLAT_PCPU_DATA_SIZE 2
227
Etienne Carriere34f0e932020-07-16 17:36:18 +0200228/*******************************************************************************
229 * Number of parallel entry slots in SMT SCMI server entry context. For this
230 * platform, SCMI server is reached through SMC only, hence the number of
231 * entry slots.
232 ******************************************************************************/
233#define PLAT_SMT_ENTRY_COUNT PLATFORM_CORE_COUNT
234
Yann Gautier4b0c72a2018-07-16 10:54:09 +0200235#endif /* PLATFORM_DEF_H */