blob: 293007579b8ef67332ecb1c5c600f3c5565bccc1 [file] [log] [blame]
Magnus Damm1c51ed42010-12-14 16:56:55 +09001/*
2 * SMP support for R-Mobile / SH-Mobile
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2010 Takashi Yoshii
6 *
7 * Based on vexpress, Copyright (c) 2003 ARM Limited, All Rights Reserved
8 *
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.
12 */
13#include <linux/linkage.h>
14#include <linux/init.h>
Russell King6ebbf2c2014-06-30 16:29:12 +010015#include <asm/assembler.h>
Magnus Damm6155f772010-12-20 11:04:50 +000016#include <asm/memory.h>
Magnus Damm1c51ed42010-12-14 16:56:55 +090017
Magnus Damme994d5e2012-05-09 16:24:59 +090018ENTRY(shmobile_invalidate_start)
19 bl v7_invalidate_l1
20 b secondary_startup
21ENDPROC(shmobile_invalidate_start)
22
Magnus Damm1c51ed42010-12-14 16:56:55 +090023/*
24 * Reset vector for secondary CPUs.
25 * This will be mapped at address 0 by SBAR register.
26 * We need _long_ jump to the physical address.
27 */
Tetsuyuki Kobayashic1d7e2e2013-07-10 10:56:36 +090028 .arm
Magnus Damm1c51ed42010-12-14 16:56:55 +090029 .align 12
Magnus Dammebe72ab2013-06-10 18:19:36 +090030ENTRY(shmobile_boot_vector)
31 ldr r0, 2f
Tetsuyuki Kobayashic1d7e2e2013-07-10 10:56:36 +090032 ldr r1, 1f
33 bx r1
34
Magnus Dammebe72ab2013-06-10 18:19:36 +090035ENDPROC(shmobile_boot_vector)
36
Tetsuyuki Kobayashi0b933cb2013-07-10 10:56:37 +090037 .align 2
Magnus Dammebe72ab2013-06-10 18:19:36 +090038 .globl shmobile_boot_fn
39shmobile_boot_fn:
401: .space 4
41 .globl shmobile_boot_arg
42shmobile_boot_arg:
432: .space 4
Magnus Damma84a5ab2013-08-08 07:14:07 +090044 .globl shmobile_boot_size
45shmobile_boot_size:
46 .long . - shmobile_boot_vector
Magnus Dammcc615912013-08-01 03:38:18 +090047
48/*
49 * Per-CPU SMP boot function/argument selection code based on MPIDR
50 */
51
52ENTRY(shmobile_smp_boot)
53 @ r0 = MPIDR_HWID_BITMASK
54 mrc p15, 0, r1, c0, c0, 5 @ r1 = MPIDR
55 and r0, r1, r0 @ r0 = cpu_logical_map() value
56 mov r1, #0 @ r1 = CPU index
57 adr r5, 1f @ array of per-cpu mpidr values
58 adr r6, 2f @ array of per-cpu functions
59 adr r7, 3f @ array of per-cpu arguments
60
61shmobile_smp_boot_find_mpidr:
62 ldr r8, [r5, r1, lsl #2]
63 cmp r8, r0
64 bne shmobile_smp_boot_next
65
66 ldr r9, [r6, r1, lsl #2]
67 cmp r9, #0
68 bne shmobile_smp_boot_found
69
70shmobile_smp_boot_next:
71 add r1, r1, #1
72 cmp r1, #CONFIG_NR_CPUS
73 blo shmobile_smp_boot_find_mpidr
74
75 b shmobile_smp_sleep
76
77shmobile_smp_boot_found:
78 ldr r0, [r7, r1, lsl #2]
Russell King6ebbf2c2014-06-30 16:29:12 +010079 ret r9
Magnus Dammcc615912013-08-01 03:38:18 +090080ENDPROC(shmobile_smp_boot)
81
82ENTRY(shmobile_smp_sleep)
83 wfi
84 b shmobile_smp_boot
85ENDPROC(shmobile_smp_sleep)
86
87 .globl shmobile_smp_mpidr
88shmobile_smp_mpidr:
891: .space CONFIG_NR_CPUS * 4
90 .globl shmobile_smp_fn
91shmobile_smp_fn:
922: .space CONFIG_NR_CPUS * 4
93 .globl shmobile_smp_arg
94shmobile_smp_arg:
953: .space CONFIG_NR_CPUS * 4