smp-sh73a0.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * SMP support for R-Mobile / SH-Mobile - sh73a0 portion
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2010 Takashi Yoshii
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/smp.h>
  19. #include <linux/io.h>
  20. #include <linux/delay.h>
  21. #include <asm/smp_plat.h>
  22. #include <asm/smp_twd.h>
  23. #include "common.h"
  24. #include "sh73a0.h"
  25. #define WUPCR IOMEM(0xe6151010)
  26. #define SRESCR IOMEM(0xe6151018)
  27. #define PSTR IOMEM(0xe6151040)
  28. #define SBAR IOMEM(0xe6180020)
  29. #define APARMBAREA IOMEM(0xe6f10020)
  30. #define SH73A0_SCU_BASE 0xf0000000
  31. #if defined(CONFIG_HAVE_ARM_TWD) && !defined(CONFIG_ARCH_MULTIPLATFORM)
  32. static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);
  33. void __init sh73a0_register_twd(void)
  34. {
  35. twd_local_timer_register(&twd_local_timer);
  36. }
  37. #endif
  38. static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
  39. {
  40. unsigned int lcpu = cpu_logical_map(cpu);
  41. if (((__raw_readl(PSTR) >> (4 * lcpu)) & 3) == 3)
  42. __raw_writel(1 << lcpu, WUPCR); /* wake up */
  43. else
  44. __raw_writel(1 << lcpu, SRESCR); /* reset */
  45. return 0;
  46. }
  47. static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
  48. {
  49. /* Map the reset vector (in headsmp.S) */
  50. __raw_writel(0, APARMBAREA); /* 4k */
  51. __raw_writel(__pa(shmobile_boot_vector), SBAR);
  52. /* setup sh73a0 specific SCU bits */
  53. shmobile_scu_base = IOMEM(SH73A0_SCU_BASE);
  54. shmobile_smp_scu_prepare_cpus(max_cpus);
  55. }
  56. struct smp_operations sh73a0_smp_ops __initdata = {
  57. .smp_prepare_cpus = sh73a0_smp_prepare_cpus,
  58. .smp_boot_secondary = sh73a0_boot_secondary,
  59. #ifdef CONFIG_HOTPLUG_CPU
  60. .cpu_disable = shmobile_smp_cpu_disable,
  61. .cpu_die = shmobile_smp_scu_cpu_die,
  62. .cpu_kill = shmobile_smp_scu_cpu_kill,
  63. #endif
  64. };