^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) // Copyright (C) ASPEED Technology Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) // Copyright IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/of_address.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define BOOT_ADDR 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define BOOT_SIG 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static struct device_node *secboot_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int aspeed_g6_boot_secondary(unsigned int cpu, struct task_struct *idle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) base = of_iomap(secboot_node, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if (!base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) pr_err("could not map the secondary boot base!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) writel_relaxed(0, base + BOOT_ADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) writel_relaxed(__pa_symbol(secondary_startup_arm), base + BOOT_ADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) writel_relaxed((0xABBAAB00 | (cpu & 0xff)), base + BOOT_SIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) dsb_sev();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) iounmap(base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static void __init aspeed_g6_smp_prepare_cpus(unsigned int max_cpus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) secboot_node = of_find_compatible_node(NULL, NULL, "aspeed,ast2600-smpmem");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (!secboot_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) pr_err("secboot device node found!!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) base = of_iomap(secboot_node, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (!base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) pr_err("could not map the secondary boot base!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) __raw_writel(0xBADABABA, base + BOOT_SIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) iounmap(base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static const struct smp_operations aspeed_smp_ops __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .smp_prepare_cpus = aspeed_g6_smp_prepare_cpus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .smp_boot_secondary = aspeed_g6_boot_secondary,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) CPU_METHOD_OF_DECLARE(aspeed_smp, "aspeed,ast2600-smp", &aspeed_smp_ops);