Debian Codegraph @

plat/nxp/s32/s32g274ardb2/plat_helpers.S

raw
1 /*
2 * Copyright 2024 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <asm_macros.S>
8 #include <platform_def.h>
9 #include <s32cc-ncore.h>
10
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
15 .globl plat_my_core_pos
16 .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); */
22 func 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
27 endfunc plat_crash_console_init
28
29 /* int plat_crash_console_putc(int); */
30 func plat_crash_console_putc
31 mov_imm x1, UART_BASE
32 b console_linflex_core_putc
33 ret
34 endfunc plat_crash_console_putc
35
36 /* void plat_crash_console_flush(void); */
37 func plat_crash_console_flush
38 mov_imm x0, UART_BASE
39 b console_linflex_core_flush
40 ret
41 endfunc 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 */
50 func 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
56 endfunc 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 */
64 func 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
70 endfunc plat_my_core_pos
71
72 /**
73 * unsigned int plat_is_my_cpu_primary(void);
74 *
75 * Clobber list: x0, x1, x7, x8
76 */
77 func 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
84 endfunc plat_is_my_cpu_primary
85
86
87 /**
88 * void plat_secondary_cold_boot_setup (void);
89 */
90 func plat_secondary_cold_boot_setup
91 ret
92 endfunc 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 */
103 func plat_reset_handler
104 mov x0, #NCORE_CAIU0_BASE_ADDR
105 ldr w1, [x0, #NCORE_CAIUTC_OFF]
106 movz w2, #1
107 lsl w2, w2, #NCORE_CAIUTC_ISOLEN_SHIFT
108 orr w1, w1, w2
109 str w1, [x0, #NCORE_CAIUTC_OFF]
110 ret
111 endfunc plat_reset_handler
112
113 /* void platform_mem_init(void); */
114 func 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
128 endfunc platform_mem_init
129