blob: 523f9bb51fd6a6dbe91816034e0c3d40866bce0e [file] [log] [blame]
Yann Gautiera3f46382023-06-14 10:40:59 +02001/*
Yann Gautier65af6f62025-02-26 12:01:54 +01002 * Copyright (c) 2023-2025, STMicroelectronics - All Rights Reserved
Yann Gautiera3f46382023-06-14 10:40:59 +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>
Yann Gautierece4c252023-06-13 18:45:03 +020011#include <drivers/arm/gic_common.h>
Yann Gautiera3f46382023-06-14 10:40:59 +020012#include <lib/utils_def.h>
13#include <plat/common/common_def.h>
14
15#include "../stm32mp2_def.h"
16
17/*******************************************************************************
18 * Generic platform constants
19 ******************************************************************************/
20
21/* Size of cacheable stacks */
22#define PLATFORM_STACK_SIZE 0xC00
23
24#define STM32MP_PRIMARY_CPU U(0x0)
25#define STM32MP_SECONDARY_CPU U(0x1)
26
27#define MAX_IO_DEVICES U(4)
28#define MAX_IO_HANDLES U(4)
29#define MAX_IO_BLOCK_DEVICES U(1)
30#define MAX_IO_MTD_DEVICES U(1)
31
32#define PLATFORM_CLUSTER_COUNT U(1)
33#define PLATFORM_CORE_COUNT U(2)
34#define PLATFORM_MAX_CPUS_PER_CLUSTER U(2)
35
Maxime Méréf6ab3912024-10-15 17:40:03 +020036#define PLAT_MAX_PWR_LVL U(1)
Yann Gautierece4c252023-06-13 18:45:03 +020037#define PLAT_MIN_SUSPEND_PWR_LVL U(2)
38#define PLAT_NUM_PWR_DOMAINS U(6)
Yann Gautiera3f46382023-06-14 10:40:59 +020039
40/* Local power state for power domains in Run state. */
41#define STM32MP_LOCAL_STATE_RUN U(0)
42/* Local power state for retention. */
43#define STM32MP_LOCAL_STATE_RET U(1)
44#define STM32MP_LOCAL_STATE_LP U(2)
45#define PLAT_MAX_RET_STATE STM32MP_LOCAL_STATE_LP
46/* Local power state for OFF/power-down. */
47#define STM32MP_LOCAL_STATE_OFF U(3)
48#define PLAT_MAX_OFF_STATE STM32MP_LOCAL_STATE_OFF
49
50/* Macros to parse the state information from State-ID (recommended encoding) */
51#define PLAT_LOCAL_PSTATE_WIDTH U(4)
52#define PLAT_LOCAL_PSTATE_MASK GENMASK(PLAT_LOCAL_PSTATE_WIDTH - 1U, 0)
53
54/*******************************************************************************
55 * BL2 specific defines.
56 ******************************************************************************/
57/*
58 * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug
59 * size plus a little space for growth.
60 */
61#define BL2_BASE STM32MP_BL2_BASE
62#define BL2_LIMIT (STM32MP_BL2_BASE + \
63 STM32MP_BL2_SIZE)
64
Yann Gautier8053f2b2024-05-21 11:46:59 +020065#define BL2_RO_BASE STM32MP_BL2_RO_BASE
66#define BL2_RO_LIMIT (STM32MP_BL2_RO_BASE + \
67 STM32MP_BL2_RO_SIZE)
68
69#define BL2_RW_BASE STM32MP_BL2_RW_BASE
70#define BL2_RW_LIMIT (STM32MP_BL2_RW_BASE + \
71 STM32MP_BL2_RW_SIZE)
72
73/*******************************************************************************
74 * BL31 specific defines.
75 ******************************************************************************/
Maxime Méréc6a33f52024-12-10 10:55:58 +010076#if ENABLE_PIE
Yann Gautier8053f2b2024-05-21 11:46:59 +020077#define BL31_BASE 0
Maxime Méréc6a33f52024-12-10 10:55:58 +010078#else
79#define BL31_BASE STM32MP_SYSRAM_BASE
80#endif
81
82#define BL31_LIMIT (BL31_BASE + (STM32MP_SYSRAM_SIZE / 2))
83
84#define BL31_PROGBITS_LIMIT (BL31_BASE + STM32MP_BL31_SIZE)
Yann Gautier8053f2b2024-05-21 11:46:59 +020085
Yann Gautiera3f46382023-06-14 10:40:59 +020086/*******************************************************************************
87 * BL33 specific defines.
88 ******************************************************************************/
89#define BL33_BASE STM32MP_BL33_BASE
90
91/*******************************************************************************
Yann Gautiera3f46382023-06-14 10:40:59 +020092 * Platform specific page table and MMU setup constants
93 ******************************************************************************/
94#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 33)
95#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 33)
96
97/*******************************************************************************
98 * Declarations and constants to access the mailboxes safely. Each mailbox is
99 * aligned on the biggest cache line size in the platform. This is known only
100 * to the platform as it might have a combination of integrated and external
101 * caches. Such alignment ensures that two maiboxes do not sit on the same cache
102 * line at any cache level. They could belong to different cpus/clusters &
103 * get written while being protected by different locks causing corruption of
104 * a valid mailbox address.
105 ******************************************************************************/
106#define CACHE_WRITEBACK_SHIFT 6
107#define CACHE_WRITEBACK_GRANULE (U(1) << CACHE_WRITEBACK_SHIFT)
108
Yann Gautierece4c252023-06-13 18:45:03 +0200109/*
110 * Secure Interrupt: based on the standard ARM mapping
111 */
112#define ARM_IRQ_SEC_PHY_TIMER U(29)
113
114#define ARM_IRQ_NON_SEC_SGI_0 U(0)
115
116#define ARM_IRQ_SEC_SGI_0 U(8)
117#define ARM_IRQ_SEC_SGI_1 U(9)
118#define ARM_IRQ_SEC_SGI_2 U(10)
119#define ARM_IRQ_SEC_SGI_3 U(11)
120#define ARM_IRQ_SEC_SGI_4 U(12)
121#define ARM_IRQ_SEC_SGI_5 U(13)
122#define ARM_IRQ_SEC_SGI_6 U(14)
123#define ARM_IRQ_SEC_SGI_7 U(15)
124
125/* Platform IRQ Priority */
126#define STM32MP_IRQ_SEC_SPI_PRIO U(0x10)
127
128/*
129 * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
130 * terminology. On a GICv2 system or mode, the lists will be merged and treated
131 * as Group 0 interrupts.
132 */
133#define PLATFORM_G1S_PROPS(grp) \
134 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, \
135 GIC_HIGHEST_SEC_PRIORITY, \
136 (grp), GIC_INTR_CFG_LEVEL), \
137 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, \
138 GIC_HIGHEST_SEC_PRIORITY, \
139 (grp), GIC_INTR_CFG_EDGE), \
140 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, \
141 GIC_HIGHEST_SEC_PRIORITY, \
142 (grp), GIC_INTR_CFG_EDGE), \
143 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, \
144 GIC_HIGHEST_SEC_PRIORITY, \
145 (grp), GIC_INTR_CFG_EDGE), \
146 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, \
147 GIC_HIGHEST_SEC_PRIORITY, \
148 (grp), GIC_INTR_CFG_EDGE), \
149 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, \
150 GIC_HIGHEST_SEC_PRIORITY, \
151 (grp), GIC_INTR_CFG_EDGE), \
152 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, \
153 GIC_HIGHEST_SEC_PRIORITY, \
154 (grp), GIC_INTR_CFG_EDGE)
155
156#define PLATFORM_G0_PROPS(grp) \
157 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, \
158 GIC_HIGHEST_SEC_PRIORITY, \
159 (grp), GIC_INTR_CFG_EDGE), \
160 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, \
161 GIC_HIGHEST_SEC_PRIORITY, \
162 (grp), GIC_INTR_CFG_EDGE)
163
Yann Gautiera3f46382023-06-14 10:40:59 +0200164#endif /* PLATFORM_DEF_H */