smp-sh73a0.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * SMP support for R-Mobile / SH-Mobile - sh73a0 portion
  4. *
  5. * Copyright (C) 2010 Magnus Damm
  6. * Copyright (C) 2010 Takashi Yoshii
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/smp.h>
  11. #include <linux/io.h>
  12. #include <linux/delay.h>
  13. #include <asm/smp_plat.h>
  14. #include "common.h"
  15. #include "sh73a0.h"
  16. #define CPG_BASE2 0xe6151000
  17. #define WUPCR 0x10 /* System-CPU Wake Up Control Register */
  18. #define SRESCR 0x18 /* System-CPU Software Reset Control Register */
  19. #define PSTR 0x40 /* System-CPU Power Status Register */
  20. #define SYSC_BASE 0xe6180000
  21. #define SBAR 0x20 /* SYS Boot Address Register */
  22. #define AP_BASE 0xe6f10000
  23. #define APARMBAREA 0x20 /* Address Translation Area Register */
  24. #define SH73A0_SCU_BASE 0xf0000000
  25. static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
  26. {
  27. unsigned int lcpu = cpu_logical_map(cpu);
  28. void __iomem *cpg2 = ioremap(CPG_BASE2, PAGE_SIZE);
  29. if (((readl(cpg2 + PSTR) >> (4 * lcpu)) & 3) == 3)
  30. writel(1 << lcpu, cpg2 + WUPCR); /* wake up */
  31. else
  32. writel(1 << lcpu, cpg2 + SRESCR); /* reset */
  33. iounmap(cpg2);
  34. return 0;
  35. }
  36. static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
  37. {
  38. void __iomem *ap = ioremap(AP_BASE, PAGE_SIZE);
  39. void __iomem *sysc = ioremap(SYSC_BASE, PAGE_SIZE);
  40. /* Map the reset vector (in headsmp.S) */
  41. writel(0, ap + APARMBAREA); /* 4k */
  42. writel(__pa(shmobile_boot_vector), sysc + SBAR);
  43. iounmap(sysc);
  44. iounmap(ap);
  45. /* setup sh73a0 specific SCU bits */
  46. shmobile_smp_scu_prepare_cpus(SH73A0_SCU_BASE, max_cpus);
  47. }
  48. const struct smp_operations sh73a0_smp_ops __initconst = {
  49. .smp_prepare_cpus = sh73a0_smp_prepare_cpus,
  50. .smp_boot_secondary = sh73a0_boot_secondary,
  51. #ifdef CONFIG_HOTPLUG_CPU
  52. .cpu_can_disable = shmobile_smp_cpu_can_disable,
  53. .cpu_die = shmobile_smp_scu_cpu_die,
  54. .cpu_kill = shmobile_smp_scu_cpu_kill,
  55. #endif
  56. };