blob: 7121900466c912dd1bfb60dd176628ed21ef9577 [file] [log] [blame]
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +02001/*
2 * Copyright 2024 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8#include <platform_def.h>
Ghennadi Procopciucfb261e12024-09-25 14:03:33 +03009#include <s32cc-ncore.h>
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +020010
11.globl plat_crash_console_flush
12.globl plat_crash_console_init
13.globl plat_crash_console_putc
14.globl plat_is_my_cpu_primary
Ghennadi Procopciuc1e38cff2024-01-26 15:29:08 +020015.globl plat_my_core_pos
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +020016.globl plat_reset_handler
17.globl plat_secondary_cold_boot_setup
18.globl platform_mem_init
19.globl s32g2_core_pos_by_mpidr
20
21/* int plat_crash_console_init(void); */
22func plat_crash_console_init
23 mov_imm x0, UART_BASE
24 mov_imm x1, UART_CLOCK_HZ
25 mov_imm x2, UART_BAUDRATE
26 b console_linflex_core_init
27endfunc plat_crash_console_init
28
29/* int plat_crash_console_putc(int); */
30func plat_crash_console_putc
31 mov_imm x1, UART_BASE
32 b console_linflex_core_putc
33 ret
34endfunc plat_crash_console_putc
35
36/* void plat_crash_console_flush(void); */
37func plat_crash_console_flush
Ghennadi Procopciuc8b804e22024-08-06 23:41:45 +030038 mov_imm x0, UART_BASE
39 b console_linflex_core_flush
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +020040 ret
41endfunc plat_crash_console_flush
42
43/**
44 * unsigned int s32g2_core_pos_by_mpidr(u_register_t mpidr);
45 *
46 * In: x0 - MPIDR_EL1
47 * Out: x0
48 * Clobber list: x0, x1
49 */
50func s32g2_core_pos_by_mpidr
51 and x1, x0, #MPIDR_CPU_MASK
52 and x0, x0, #MPIDR_CLUSTER_MASK
53 lsr x0, x0, #MPIDR_AFF1_SHIFT
54 add x0, x1, x0, lsl #PLATFORM_MPIDR_CPU_MASK_BITS
55 ret
56endfunc s32g2_core_pos_by_mpidr
57
58/**
59 * unsigned int plat_my_core_pos(void);
60 *
61 * Out: x0
62 * Clobber list: x0, x1, x8
63 */
64func plat_my_core_pos
65 mov x8, x30
66 mrs x0, mpidr_el1
67 bl s32g2_core_pos_by_mpidr
68 mov x30, x8
69 ret
70endfunc plat_my_core_pos
71
72/**
73 * unsigned int plat_is_my_cpu_primary(void);
74 *
75 * Clobber list: x0, x1, x7, x8
76 */
77func plat_is_my_cpu_primary
78 mov x7, x30
79 bl plat_my_core_pos
80 cmp x0, #PLATFORM_PRIMARY_CPU
81 cset x0, eq
82 mov x30, x7
83 ret
84endfunc plat_is_my_cpu_primary
85
86
87/**
88 * void plat_secondary_cold_boot_setup (void);
89 */
90func plat_secondary_cold_boot_setup
91 ret
92endfunc plat_secondary_cold_boot_setup
93
94/**
95 * void plat_reset_handler(void);
96 *
97 * Set the CAIUTC[IsolEn] bit for the primary A53 cluster.
98 * This is so cache invalidate operations from the early TF-A boot code
99 * won't cause Ncore to crash.
100 *
101 * Clobber list: x0, x1, x2
102 */
103func plat_reset_handler
Ghennadi Procopciucfb261e12024-09-25 14:03:33 +0300104 mov x0, #NCORE_CAIU0_BASE_ADDR
105 ldr w1, [x0, #NCORE_CAIUTC_OFF]
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +0200106 movz w2, #1
Ghennadi Procopciucfb261e12024-09-25 14:03:33 +0300107 lsl w2, w2, #NCORE_CAIUTC_ISOLEN_SHIFT
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +0200108 orr w1, w1, w2
Ghennadi Procopciucfb261e12024-09-25 14:03:33 +0300109 str w1, [x0, #NCORE_CAIUTC_OFF]
Ghennadi Procopciuca9fee052024-01-30 16:19:47 +0200110 ret
111endfunc plat_reset_handler
112
113/* void platform_mem_init(void); */
114func platform_mem_init
115 mov x10, x30
116 mov x0, #BL31_BASE
117 mov x1, #(BL31_LIMIT & 0xFFFFU)
118 movk x1, #(BL31_LIMIT >> 16), lsl #16
119 sub x1, x1, x0
120 bl zeromem
121 mov x0, #BL33_BASE
122 mov x1, #(BL33_LIMIT & 0xFFFFU)
123 movk x1, #(BL33_LIMIT >> 16), lsl #16
124 sub x1, x1, x0
125 bl zeromem
126 mov x30, x10
127 ret
128endfunc platform_mem_init
129