Linux 5.6.13
[linux/fpc-iii.git] / arch / arm / mach-aspeed / platsmp.c
blob2324becf7991959d0ba6f737c9132669fba2ba9d
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 // Copyright (C) ASPEED Technology Inc.
3 // Copyright IBM Corp.
5 #include <linux/of_address.h>
6 #include <linux/io.h>
7 #include <linux/of.h>
8 #include <linux/smp.h>
10 #define BOOT_ADDR 0x00
11 #define BOOT_SIG 0x04
13 static struct device_node *secboot_node;
15 static int aspeed_g6_boot_secondary(unsigned int cpu, struct task_struct *idle)
17 void __iomem *base;
19 base = of_iomap(secboot_node, 0);
20 if (!base) {
21 pr_err("could not map the secondary boot base!");
22 return -ENODEV;
25 writel_relaxed(0, base + BOOT_ADDR);
26 writel_relaxed(__pa_symbol(secondary_startup_arm), base + BOOT_ADDR);
27 writel_relaxed((0xABBAAB00 | (cpu & 0xff)), base + BOOT_SIG);
29 dsb_sev();
31 iounmap(base);
33 return 0;
36 static void __init aspeed_g6_smp_prepare_cpus(unsigned int max_cpus)
38 void __iomem *base;
40 secboot_node = of_find_compatible_node(NULL, NULL, "aspeed,ast2600-smpmem");
41 if (!secboot_node) {
42 pr_err("secboot device node found!!\n");
43 return;
46 base = of_iomap(secboot_node, 0);
47 if (!base) {
48 pr_err("could not map the secondary boot base!");
49 return;
51 __raw_writel(0xBADABABA, base + BOOT_SIG);
53 iounmap(base);
56 static const struct smp_operations aspeed_smp_ops __initconst = {
57 .smp_prepare_cpus = aspeed_g6_smp_prepare_cpus,
58 .smp_boot_secondary = aspeed_g6_boot_secondary,
61 CPU_METHOD_OF_DECLARE(aspeed_smp, "aspeed,ast2600-smp", &aspeed_smp_ops);