1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2018 MediaTek Inc.
6 #include <linux/linkage.h>
7 #include <asm/proc-armv/ptrace.h>
9 #define WAIT_CODE_SRAM_BASE 0x0010ff00
11 #define SLAVE_JUMP_REG 0x10202034
12 #define SLAVE1_MAGIC_REG 0x10202038
13 #define SLAVE1_MAGIC_NUM 0x534c4131
15 #define GIC_CPU_BASE 0x10320000
19 #ifndef CONFIG_SPL_BUILD
20 /* Return to U-Boot via saved link register */
25 * set CNTFRQ = 20Mhz, set CNTVOFF = 0
29 mcr p15, 0, r0, c14, c0, 0
32 mrc p15, 0, r1, c1, c1, 0 @ Get Secure Config
34 mcr p15, 0, r0, c1, c1, 0 @ Set Non Secure bit
37 mcrr p15, 4, r0, r0, c14 @ CNTVOFF = 0
39 mcr p15, 0, r1, c1, c1, 0 @ Set Secure bit
44 mrc p15, 0, r0, c1, c0, 1
46 mcr p15, 0, r0, c1, c0, 1
48 /* if MP core, handle secondary cores */
49 mrc p15, 0, r0, c0, c0, 5
50 ands r1, r0, #0x40000000
52 /* read slave CPU number */
54 beq go @ Go if core0 on primary core tile
62 /* enable GIC as cores will be waken up by IPI */
73 /* copy wait code into SRAM */
74 ldr r0, =slave_cpu_wait
75 ldm r0, {r1 - r8} @ slave_cpu_wait has eight insns
76 ldr r0, =WAIT_CODE_SRAM_BASE
79 /* pass args to slave_cpu_wait */
80 ldr r0, =SLAVE1_MAGIC_REG
81 ldr r1, =SLAVE1_MAGIC_NUM
83 /* jump to wait code in SRAM */
84 ldr pc, =WAIT_CODE_SRAM_BASE
87 ENDPROC(lowlevel_init)
89 /* This function will be copied into SRAM */
95 movw r0, #:lower16:SLAVE_JUMP_REG
96 movt r0, #:upper16:SLAVE_JUMP_REG
99 ENDPROC(slave_cpu_wait)