smp-r8a7779.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 HPBREG_BASE 0xfe700000
  21. #define AVECR 0x0040 /* ARM Reset Vector Address Register */
  22. #define R8A7779_SCU_BASE 0xf0000000
  23. static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
  24. {
  25. int ret = -EIO;
  26. cpu = cpu_logical_map(cpu);
  27. if (cpu)
  28. ret = rcar_sysc_power_up_cpu(cpu);
  29. return ret;
  30. }
  31. static void __init r8a7779_smp_prepare_cpus(unsigned int max_cpus)
  32. {
  33. void __iomem *base = ioremap(HPBREG_BASE, 0x1000);
  34. /* Map the reset vector (in headsmp-scu.S, headsmp.S) */
  35. writel(__pa(shmobile_boot_vector), base + AVECR);
  36. /* setup r8a7779 specific SCU bits */
  37. shmobile_smp_scu_prepare_cpus(R8A7779_SCU_BASE, max_cpus);
  38. iounmap(base);
  39. }
  40. #ifdef CONFIG_HOTPLUG_CPU
  41. static int r8a7779_platform_cpu_kill(unsigned int cpu)
  42. {
  43. int ret = -EIO;
  44. cpu = cpu_logical_map(cpu);
  45. if (cpu)
  46. ret = rcar_sysc_power_down_cpu(cpu);
  47. return ret ? ret : 1;
  48. }
  49. static int r8a7779_cpu_kill(unsigned int cpu)
  50. {
  51. if (shmobile_smp_scu_cpu_kill(cpu))
  52. return r8a7779_platform_cpu_kill(cpu);
  53. return 0;
  54. }
  55. #endif /* CONFIG_HOTPLUG_CPU */
  56. const struct smp_operations r8a7779_smp_ops __initconst = {
  57. .smp_prepare_cpus = r8a7779_smp_prepare_cpus,
  58. .smp_boot_secondary = r8a7779_boot_secondary,
  59. #ifdef CONFIG_HOTPLUG_CPU
  60. .cpu_die = shmobile_smp_scu_cpu_die,
  61. .cpu_kill = r8a7779_cpu_kill,
  62. #endif
  63. };