platsmp.c 1.8 KB

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