smp-r8a7779.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * SMP support for R-Mobile / SH-Mobile - r8a7779 portion
  4. *
  5. * Copyright (C) 2011 Renesas Solutions Corp.
  6. * Copyright (C) 2011 Magnus Damm
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/smp.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/io.h>
  13. #include <linux/delay.h>
  14. #include <linux/soc/renesas/rcar-sysc.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/smp_plat.h>
  17. #include <asm/smp_scu.h>
  18. #include "common.h"
  19. #include "r8a7779.h"
  20. #define AVECR IOMEM(0xfe700040)
  21. #define R8A7779_SCU_BASE 0xf0000000
  22. static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
  23. {
  24. int ret = -EIO;
  25. cpu = cpu_logical_map(cpu);
  26. if (cpu)
  27. ret = rcar_sysc_power_up_cpu(cpu);
  28. return ret;
  29. }
  30. static void __init r8a7779_smp_prepare_cpus(unsigned int max_cpus)
  31. {
  32. /* Map the reset vector (in headsmp-scu.S, headsmp.S) */
  33. __raw_writel(__pa(shmobile_boot_vector), AVECR);
  34. /* setup r8a7779 specific SCU bits */
  35. shmobile_smp_scu_prepare_cpus(R8A7779_SCU_BASE, max_cpus);
  36. }
  37. #ifdef CONFIG_HOTPLUG_CPU
  38. static int r8a7779_platform_cpu_kill(unsigned int cpu)
  39. {
  40. int ret = -EIO;
  41. cpu = cpu_logical_map(cpu);
  42. if (cpu)
  43. ret = rcar_sysc_power_down_cpu(cpu);
  44. return ret ? ret : 1;
  45. }
  46. static int r8a7779_cpu_kill(unsigned int cpu)
  47. {
  48. if (shmobile_smp_scu_cpu_kill(cpu))
  49. return r8a7779_platform_cpu_kill(cpu);
  50. return 0;
  51. }
  52. #endif /* CONFIG_HOTPLUG_CPU */
  53. const struct smp_operations r8a7779_smp_ops __initconst = {
  54. .smp_prepare_cpus = r8a7779_smp_prepare_cpus,
  55. .smp_boot_secondary = r8a7779_boot_secondary,
  56. #ifdef CONFIG_HOTPLUG_CPU
  57. .cpu_die = shmobile_smp_scu_cpu_die,
  58. .cpu_kill = r8a7779_cpu_kill,
  59. #endif
  60. };