1 /* SPDX-License-Identifier: GPL-2.0
3 * SMP support for R-Mobile / SH-Mobile
5 * Copyright (C) 2010 Magnus Damm
6 * Copyright (C) 2010 Takashi Yoshii
8 * Based on vexpress, Copyright (c) 2003 ARM Limited, All Rights Reserved
10 #include <linux/init.h>
11 #include <linux/linkage.h>
12 #include <linux/threads.h>
13 #include <asm/assembler.h>
14 #include <asm/memory.h>
16 #define SCTLR_MMU 0x01
17 #define BOOTROM_ADDRESS 0xE6340000
18 #define RWTCSRA_ADDRESS 0xE6020004
19 #define RWTCSRA_WOVF 0x10
22 * Reset vector for secondary CPUs.
23 * This will be mapped at address 0 by SBAR register.
24 * We need _long_ jump to the physical address.
28 ENTRY(shmobile_boot_vector)
32 ENDPROC(shmobile_boot_vector)
35 .globl shmobile_boot_fn
38 .globl shmobile_boot_size
40 .long . - shmobile_boot_vector
42 #ifdef CONFIG_ARCH_RCAR_GEN2
44 * Reset vector for R-Car Gen2 and RZ/G1 secondary CPUs.
45 * This will be mapped at address 0 by SBAR register.
47 ENTRY(shmobile_boot_vector_gen2)
48 mrc p15, 0, r0, c0, c0, 5 @ r0 = MPIDR
49 ldr r1, shmobile_boot_cpu_gen2
51 bne shmobile_smp_continue_gen2
53 mrc p15, 0, r1, c1, c0, 0 @ r1 = SCTLR
54 and r0, r1, #SCTLR_MMU
56 beq shmobile_smp_continue_gen2
61 and r0, r1, #RWTCSRA_WOVF
63 bne shmobile_smp_continue_gen2
68 shmobile_smp_continue_gen2:
69 ldr r1, shmobile_boot_fn_gen2
72 ENDPROC(shmobile_boot_vector_gen2)
79 .globl shmobile_boot_cpu_gen2
80 shmobile_boot_cpu_gen2:
84 .globl shmobile_boot_fn_gen2
85 shmobile_boot_fn_gen2:
87 .globl shmobile_boot_size_gen2
88 shmobile_boot_size_gen2:
89 .long . - shmobile_boot_vector_gen2
90 #endif /* CONFIG_ARCH_RCAR_GEN2 */
93 * Per-CPU SMP boot function/argument selection code based on MPIDR
96 ENTRY(shmobile_smp_boot)
97 mrc p15, 0, r1, c0, c0, 5 @ r1 = MPIDR
98 and r0, r1, #0xffffff @ MPIDR_HWID_BITMASK
99 @ r0 = cpu_logical_map() value
100 mov r1, #0 @ r1 = CPU index
102 ldmia r2, {r5, r6, r7}
103 add r5, r5, r2 @ array of per-cpu mpidr values
104 add r6, r6, r2 @ array of per-cpu functions
105 add r7, r7, r2 @ array of per-cpu arguments
107 shmobile_smp_boot_find_mpidr:
108 ldr r8, [r5, r1, lsl #2]
110 bne shmobile_smp_boot_next
112 ldr r9, [r6, r1, lsl #2]
114 bne shmobile_smp_boot_found
116 shmobile_smp_boot_next:
119 blo shmobile_smp_boot_find_mpidr
123 shmobile_smp_boot_found:
124 ldr r0, [r7, r1, lsl #2]
126 ENDPROC(shmobile_smp_boot)
128 ENTRY(shmobile_smp_sleep)
131 ENDPROC(shmobile_smp_sleep)
134 1: .long shmobile_smp_mpidr - .
135 .long shmobile_smp_fn - 1b
136 .long shmobile_smp_arg - 1b
139 .globl shmobile_smp_mpidr
142 .globl shmobile_smp_fn
145 .globl shmobile_smp_arg