0001-plat-n1sdp-add-N1SDP-platform-support.patch 7.0 KB

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