platsmp.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2018 Nuvoton Technology corporation.
  3. // Copyright 2018 Google, Inc.
  4. #define pr_fmt(fmt) "nuvoton,npcm7xx-smp: " fmt
  5. #include <linux/delay.h>
  6. #include <linux/smp.h>
  7. #include <linux/io.h>
  8. #include <linux/of.h>
  9. #include <linux/of_address.h>
  10. #include <asm/cacheflush.h>
  11. #include <asm/smp.h>
  12. #include <asm/smp_plat.h>
  13. #include <asm/smp_scu.h>
  14. #define NPCM7XX_SCRPAD_REG 0x13c
  15. extern void npcm7xx_secondary_startup(void);
  16. static int npcm7xx_smp_boot_secondary(unsigned int cpu,
  17. struct task_struct *idle)
  18. {
  19. struct device_node *gcr_np;
  20. void __iomem *gcr_base;
  21. int ret = 0;
  22. gcr_np = of_find_compatible_node(NULL, NULL, "nuvoton,npcm750-gcr");
  23. if (!gcr_np) {
  24. pr_err("no gcr device node\n");
  25. ret = -ENODEV;
  26. goto out;
  27. }
  28. gcr_base = of_iomap(gcr_np, 0);
  29. if (!gcr_base) {
  30. pr_err("could not iomap gcr");
  31. ret = -ENOMEM;
  32. goto out;
  33. }
  34. /* give boot ROM kernel start address. */
  35. iowrite32(__pa_symbol(npcm7xx_secondary_startup), gcr_base +
  36. NPCM7XX_SCRPAD_REG);
  37. /* make sure the previous write is seen by all observers. */
  38. dsb_sev();
  39. iounmap(gcr_base);
  40. out:
  41. return ret;
  42. }
  43. static void __init npcm7xx_smp_prepare_cpus(unsigned int max_cpus)
  44. {
  45. struct device_node *scu_np;
  46. void __iomem *scu_base;
  47. scu_np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
  48. if (!scu_np) {
  49. pr_err("no scu device node\n");
  50. return;
  51. }
  52. scu_base = of_iomap(scu_np, 0);
  53. if (!scu_base) {
  54. pr_err("could not iomap scu");
  55. return;
  56. }
  57. scu_enable(scu_base);
  58. iounmap(scu_base);
  59. }
  60. static struct smp_operations npcm7xx_smp_ops __initdata = {
  61. .smp_prepare_cpus = npcm7xx_smp_prepare_cpus,
  62. .smp_boot_secondary = npcm7xx_smp_boot_secondary,
  63. };
  64. CPU_METHOD_OF_DECLARE(npcm7xx_smp, "nuvoton,npcm750-smp", &npcm7xx_smp_ops);