2 * SMP support for R-Mobile / SH-Mobile
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2010 Takashi Yoshii
7 * Based on vexpress, Copyright (c) 2003 ARM Limited, All Rights Reserved
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/init.h>
14 #include <linux/linkage.h>
15 #include <linux/threads.h>
16 #include <asm/assembler.h>
17 #include <asm/memory.h>
19 #define SCTLR_MMU 0x01
20 #define BOOTROM_ADDRESS 0xE6340000
21 #define RWTCSRA_ADDRESS 0xE6020004
22 #define RWTCSRA_WOVF 0x10
25 * Reset vector for secondary CPUs.
26 * This will be mapped at address 0 by SBAR register.
27 * We need _long_ jump to the physical address.
31 ENTRY(shmobile_boot_vector)
35 ENDPROC(shmobile_boot_vector)
38 .globl shmobile_boot_fn
41 .globl shmobile_boot_size
43 .long . - shmobile_boot_vector
45 #ifdef CONFIG_ARCH_RCAR_GEN2
47 * Reset vector for R-Car Gen2 and RZ/G1 secondary CPUs.
48 * This will be mapped at address 0 by SBAR register.
50 ENTRY(shmobile_boot_vector_gen2)
51 mrc p15, 0, r0, c0, c0, 5 @ r0 = MPIDR
52 ldr r1, shmobile_boot_cpu_gen2
54 bne shmobile_smp_continue_gen2
56 mrc p15, 0, r1, c1, c0, 0 @ r1 = SCTLR
57 and r0, r1, #SCTLR_MMU
59 beq shmobile_smp_continue_gen2
64 and r0, r1, #RWTCSRA_WOVF
66 bne shmobile_smp_continue_gen2
71 shmobile_smp_continue_gen2:
72 ldr r1, shmobile_boot_fn_gen2
75 ENDPROC(shmobile_boot_vector_gen2)
82 .globl shmobile_boot_cpu_gen2
83 shmobile_boot_cpu_gen2:
87 .globl shmobile_boot_fn_gen2
88 shmobile_boot_fn_gen2:
90 .globl shmobile_boot_size_gen2
91 shmobile_boot_size_gen2:
92 .long . - shmobile_boot_vector_gen2
93 #endif /* CONFIG_ARCH_RCAR_GEN2 */
96 * Per-CPU SMP boot function/argument selection code based on MPIDR
99 ENTRY(shmobile_smp_boot)
100 mrc p15, 0, r1, c0, c0, 5 @ r1 = MPIDR
101 and r0, r1, #0xffffff @ MPIDR_HWID_BITMASK
102 @ r0 = cpu_logical_map() value
103 mov r1, #0 @ r1 = CPU index
105 ldmia r2, {r5, r6, r7}
106 add r5, r5, r2 @ array of per-cpu mpidr values
107 add r6, r6, r2 @ array of per-cpu functions
108 add r7, r7, r2 @ array of per-cpu arguments
110 shmobile_smp_boot_find_mpidr:
111 ldr r8, [r5, r1, lsl #2]
113 bne shmobile_smp_boot_next
115 ldr r9, [r6, r1, lsl #2]
117 bne shmobile_smp_boot_found
119 shmobile_smp_boot_next:
122 blo shmobile_smp_boot_find_mpidr
126 shmobile_smp_boot_found:
127 ldr r0, [r7, r1, lsl #2]
129 ENDPROC(shmobile_smp_boot)
131 ENTRY(shmobile_smp_sleep)
134 ENDPROC(shmobile_smp_sleep)
137 1: .long shmobile_smp_mpidr - .
138 .long shmobile_smp_fn - 1b
139 .long shmobile_smp_arg - 1b
142 .globl shmobile_smp_mpidr
145 .globl shmobile_smp_fn
148 .globl shmobile_smp_arg