blob: 29623b0b50571931db3607d430ff145d0eceac3d [file] [log] [blame]
Andrew Geissler220dafd2023-10-04 10:18:08 -05001From 33d86d23bcf2bbcb191e33e3130c3429650b9204 Mon Sep 17 00:00:00 2001
Patrick Williams92b42cb2022-09-03 06:53:57 -05002From: Vishnu Banavath <vishnu.banavath@arm.com>
3Date: Thu, 30 Jun 2022 18:36:26 +0100
4Subject: [PATCH] plat-n1sdp: add N1SDP platform support
5
Andrew Geissler220dafd2023-10-04 10:18:08 -05006Upstream-Status: Pending [Not submitted to upstream yet]
7Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
8
Patrick Williams92b42cb2022-09-03 06:53:57 -05009These changes are to add N1SDP platform to optee-os
10
11Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Andrew Geissler220dafd2023-10-04 10:18:08 -050012Signed-off-by: Mariam Elshakfy <mariam.elshakfy@arm.com>
Patrick Williams92b42cb2022-09-03 06:53:57 -050013
14diff --git a/core/arch/arm/plat-n1sdp/conf.mk b/core/arch/arm/plat-n1sdp/conf.mk
15new file mode 100644
16index 00000000..06b4975a
17--- /dev/null
18+++ b/core/arch/arm/plat-n1sdp/conf.mk
19@@ -0,0 +1,41 @@
20+include core/arch/arm/cpu/cortex-armv8-0.mk
21+
22+CFG_DEBUG_INFO = y
23+CFG_TEE_CORE_LOG_LEVEL = 4
24+
25+# Workaround 808870: Unconditional VLDM instructions might cause an
26+# alignment fault even though the address is aligned
27+# Either hard float must be disabled for AArch32 or strict alignment checks
28+# must be disabled
29+ifeq ($(CFG_SCTLR_ALIGNMENT_CHECK),y)
30+$(call force,CFG_TA_ARM32_NO_HARD_FLOAT_SUPPORT,y)
31+else
32+$(call force,CFG_SCTLR_ALIGNMENT_CHECK,n)
33+endif
34+
35+CFG_ARM64_core ?= y
36+
37+CFG_ARM_GICV3 = y
38+
39+# ARM debugger needs this
40+platform-cflags-debug-info = -gdwarf-4
41+platform-aflags-debug-info = -gdwarf-4
42+
43+CFG_CORE_SEL1_SPMC = y
44+CFG_WITH_ARM_TRUSTED_FW = y
45+
46+$(call force,CFG_GIC,y)
47+$(call force,CFG_PL011,y)
48+$(call force,CFG_SECURE_TIME_SOURCE_CNTPCT,y)
49+
50+CFG_CORE_HEAP_SIZE = 0x32000 # 200kb
51+
52+CFG_TEE_CORE_NB_CORE = 4
Patrick Williamsac13d5f2023-11-24 18:59:46 -060053+CFG_TZDRAM_START ?= 0xDE000000
54+CFG_TZDRAM_SIZE ?= 0x02000000
Patrick Williams92b42cb2022-09-03 06:53:57 -050055+
56+CFG_SHMEM_START ?= 0x83000000
57+CFG_SHMEM_SIZE ?= 0x00210000
58+# DRAM1 is defined above 4G
59+$(call force,CFG_CORE_LARGE_PHYS_ADDR,y)
60+$(call force,CFG_CORE_ARM64_PA_BITS,36)
61diff --git a/core/arch/arm/plat-n1sdp/main.c b/core/arch/arm/plat-n1sdp/main.c
62new file mode 100644
Andrew Geissler220dafd2023-10-04 10:18:08 -050063index 00000000..39360711
Patrick Williams92b42cb2022-09-03 06:53:57 -050064--- /dev/null
65+++ b/core/arch/arm/plat-n1sdp/main.c
Andrew Geissler220dafd2023-10-04 10:18:08 -050066@@ -0,0 +1,53 @@
Patrick Williams92b42cb2022-09-03 06:53:57 -050067+// SPDX-License-Identifier: BSD-2-Clause
68+/*
69+ * Copyright (c) 2022, Arm Limited.
70+ */
71+
72+#include <arm.h>
73+#include <console.h>
74+#include <drivers/gic.h>
75+#include <drivers/pl011.h>
Patrick Williams92b42cb2022-09-03 06:53:57 -050076+#include <drivers/tzc400.h>
77+#include <initcall.h>
78+#include <keep.h>
79+#include <kernel/boot.h>
80+#include <kernel/interrupt.h>
81+#include <kernel/misc.h>
82+#include <kernel/notif.h>
83+#include <kernel/panic.h>
84+#include <kernel/spinlock.h>
85+#include <kernel/tee_time.h>
86+#include <mm/core_memprot.h>
87+#include <mm/core_mmu.h>
88+#include <platform_config.h>
89+#include <sm/psci.h>
90+#include <stdint.h>
91+#include <string.h>
92+#include <trace.h>
93+
Patrick Williams92b42cb2022-09-03 06:53:57 -050094+static struct pl011_data console_data __nex_bss;
95+
96+register_phys_mem_pgdir(MEM_AREA_IO_SEC, CONSOLE_UART_BASE, PL011_REG_SIZE);
97+
98+register_ddr(DRAM0_BASE, DRAM0_SIZE);
99+
100+register_phys_mem_pgdir(MEM_AREA_IO_SEC, GICD_BASE, GIC_DIST_REG_SIZE);
101+register_phys_mem_pgdir(MEM_AREA_IO_SEC, GICC_BASE, GIC_DIST_REG_SIZE);
102+register_phys_mem_pgdir(MEM_AREA_IO_SEC, GICR_BASE, GIC_DIST_REG_SIZE);
103+
104+void main_init_gic(void)
105+{
Andrew Geissler220dafd2023-10-04 10:18:08 -0500106+ gic_init(GICC_BASE, GICD_BASE);
Patrick Williams92b42cb2022-09-03 06:53:57 -0500107+}
108+
109+void main_secondary_init_gic(void)
110+{
Andrew Geissler220dafd2023-10-04 10:18:08 -0500111+ gic_cpu_init();
Patrick Williams92b42cb2022-09-03 06:53:57 -0500112+}
113+
114+void console_init(void)
115+{
116+ pl011_init(&console_data, CONSOLE_UART_BASE, CONSOLE_UART_CLK_IN_HZ,
117+ CONSOLE_BAUDRATE);
118+ register_serial_console(&console_data.chip);
119+}
120diff --git a/core/arch/arm/plat-n1sdp/n1sdp_core_pos.S b/core/arch/arm/plat-n1sdp/n1sdp_core_pos.S
121new file mode 100644
122index 00000000..439d4e67
123--- /dev/null
124+++ b/core/arch/arm/plat-n1sdp/n1sdp_core_pos.S
125@@ -0,0 +1,32 @@
126+/* SPDX-License-Identifier: BSD-2-Clause */
127+/*
128+ * Copyright (c) 2022, Arm Limited
129+ */
130+
131+#include <asm.S>
132+#include <arm.h>
133+#include "platform_config.h"
134+
135+FUNC get_core_pos_mpidr , :
136+ mov x4, x0
137+
138+ /*
139+ * The MT bit in MPIDR is always set for n1sdp and the
140+ * affinity level 0 corresponds to thread affinity level.
141+ */
142+
143+ /* Extract individual affinity fields from MPIDR */
144+ ubfx x0, x4, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
145+ ubfx x1, x4, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
146+ ubfx x2, x4, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
147+ ubfx x3, x4, #MPIDR_AFF3_SHIFT, #MPIDR_AFFINITY_BITS
148+
149+ /* Compute linear position */
150+ mov x4, #N1SDP_MAX_CLUSTERS_PER_CHIP
151+ madd x2, x3, x4, x2
152+ mov x4, #N1SDP_MAX_CPUS_PER_CLUSTER
153+ madd x1, x2, x4, x1
154+ mov x4, #N1SDP_MAX_PE_PER_CPU
155+ madd x0, x1, x4, x0
156+ ret
157+END_FUNC get_core_pos_mpidr
158diff --git a/core/arch/arm/plat-n1sdp/platform_config.h b/core/arch/arm/plat-n1sdp/platform_config.h
159new file mode 100644
160index 00000000..81b99409
161--- /dev/null
162+++ b/core/arch/arm/plat-n1sdp/platform_config.h
163@@ -0,0 +1,49 @@
164+/* SPDX-License-Identifier: BSD-2-Clause */
165+/*
166+ * Copyright (c) 2022, Arm Limited
167+ */
168+
169+#ifndef PLATFORM_CONFIG_H
170+#define PLATFORM_CONFIG_H
171+
172+#include <mm/generic_ram_layout.h>
173+#include <stdint.h>
174+
175+/* Make stacks aligned to data cache line length */
176+#define STACK_ALIGNMENT 64
177+
178+ /* N1SDP topology related constants */
179+#define N1SDP_MAX_CPUS_PER_CLUSTER U(2)
180+#define PLAT_ARM_CLUSTER_COUNT U(2)
181+#define PLAT_N1SDP_CHIP_COUNT U(2)
182+#define N1SDP_MAX_CLUSTERS_PER_CHIP U(2)
183+#define N1SDP_MAX_PE_PER_CPU U(1)
184+
185+#define PLATFORM_CORE_COUNT (PLAT_N1SDP_CHIP_COUNT * \
186+ PLAT_ARM_CLUSTER_COUNT * \
187+ N1SDP_MAX_CPUS_PER_CLUSTER * \
188+ N1SDP_MAX_PE_PER_CPU)
189+
190+#define GIC_BASE 0x2c010000
191+
192+#define UART1_BASE 0x1C0A0000
193+#define UART1_CLK_IN_HZ 24000000 /*24MHz*/
194+
195+#define CONSOLE_UART_BASE UART1_BASE
196+#define CONSOLE_UART_CLK_IN_HZ UART1_CLK_IN_HZ
197+
198+#define DRAM0_BASE 0x80000000
199+#define DRAM0_SIZE 0x80000000
200+
201+#define GICD_BASE 0x30000000
202+#define GICC_BASE 0x2C000000
203+#define GICR_BASE 0x300C0000
204+
205+#ifndef UART_BAUDRATE
206+#define UART_BAUDRATE 115200
207+#endif
208+#ifndef CONSOLE_BAUDRATE
209+#define CONSOLE_BAUDRATE UART_BAUDRATE
210+#endif
211+
212+#endif /*PLATFORM_CONFIG_H*/
213diff --git a/core/arch/arm/plat-n1sdp/sub.mk b/core/arch/arm/plat-n1sdp/sub.mk
214new file mode 100644
215index 00000000..a0b49da1
216--- /dev/null
217+++ b/core/arch/arm/plat-n1sdp/sub.mk
218@@ -0,0 +1,3 @@
219+global-incdirs-y += .
220+srcs-y += main.c
221+srcs-y += n1sdp_core_pos.S
222--
2232.17.1