blob: a8b76e4eccff1be8b59c90307b178b37c0d235da [file] [log] [blame]
Marc Zyngierd329de32013-01-02 15:24:22 +00001/*
2 * Spin Table SMP initialisation
3 *
4 * Copyright (C) 2013 ARM Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/init.h>
20#include <linux/of.h>
21#include <linux/smp.h>
22
23#include <asm/cacheflush.h>
Mark Rutlandcd1aebf2013-10-24 20:30:15 +010024#include <asm/cpu_ops.h>
Marc Zyngierd329de32013-01-02 15:24:22 +000025
26static phys_addr_t cpu_release_addr[NR_CPUS];
27
Mark Rutlandcd1aebf2013-10-24 20:30:15 +010028static int smp_spin_table_cpu_init(struct device_node *dn, unsigned int cpu)
Marc Zyngierd329de32013-01-02 15:24:22 +000029{
30 /*
31 * Determine the address from which the CPU is polling.
32 */
33 if (of_property_read_u64(dn, "cpu-release-addr",
34 &cpu_release_addr[cpu])) {
35 pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
36 cpu);
37
38 return -1;
39 }
40
41 return 0;
42}
43
Mark Rutlandcd1aebf2013-10-24 20:30:15 +010044static int smp_spin_table_cpu_prepare(unsigned int cpu)
Marc Zyngierd329de32013-01-02 15:24:22 +000045{
46 void **release_addr;
47
48 if (!cpu_release_addr[cpu])
49 return -ENODEV;
50
51 release_addr = __va(cpu_release_addr[cpu]);
52 release_addr[0] = (void *)__pa(secondary_holding_pen);
53 __flush_dcache_area(release_addr, sizeof(release_addr[0]));
54
55 /*
56 * Send an event to wake up the secondary CPU.
57 */
58 sev();
59
60 return 0;
61}
62
Mark Rutlandcd1aebf2013-10-24 20:30:15 +010063const struct cpu_operations smp_spin_table_ops = {
Marc Zyngierd329de32013-01-02 15:24:22 +000064 .name = "spin-table",
Mark Rutlandcd1aebf2013-10-24 20:30:15 +010065 .cpu_init = smp_spin_table_cpu_init,
66 .cpu_prepare = smp_spin_table_cpu_prepare,
Marc Zyngierd329de32013-01-02 15:24:22 +000067};