platsmp.c 1.4 KB

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