1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * SMP operations for Alpine platform.
4  *
5  * Copyright (C) 2015 Annapurna Labs Ltd.
6  */
7 
8 #include <linux/init.h>
9 #include <linux/errno.h>
10 #include <linux/io.h>
11 #include <linux/of.h>
12 
13 #include <asm/smp_plat.h>
14 
15 #include "alpine_cpu_pm.h"
16 
alpine_boot_secondary(unsigned int cpu,struct task_struct * idle)17 static int alpine_boot_secondary(unsigned int cpu, struct task_struct *idle)
18 {
19 	phys_addr_t addr;
20 
21 	addr = __pa_symbol(secondary_startup);
22 
23 	if (addr > (phys_addr_t)(uint32_t)(-1)) {
24 		pr_err("FAIL: resume address over 32bit (%pa)", &addr);
25 		return -EINVAL;
26 	}
27 
28 	return alpine_cpu_wakeup(cpu_logical_map(cpu), (uint32_t)addr);
29 }
30 
alpine_smp_prepare_cpus(unsigned int max_cpus)31 static void __init alpine_smp_prepare_cpus(unsigned int max_cpus)
32 {
33 	alpine_cpu_pm_init();
34 }
35 
36 static const struct smp_operations alpine_smp_ops __initconst = {
37 	.smp_prepare_cpus	= alpine_smp_prepare_cpus,
38 	.smp_boot_secondary	= alpine_boot_secondary,
39 };
40 CPU_METHOD_OF_DECLARE(alpine_smp, "al,alpine-smp", &alpine_smp_ops);
41