platsmp.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/init.h>
  13. #include <linux/smp.h>
  14. #include <asm/page.h>
  15. #include <asm/smp_scu.h>
  16. #include <asm/mach/map.h>
  17. #include "common.h"
  18. #include "hardware.h"
  19. #define SCU_STANDBY_ENABLE (1 << 5)
  20. static void __iomem *scu_base;
  21. static struct map_desc scu_io_desc __initdata = {
  22. /* .virtual and .pfn are run-time assigned */
  23. .length = SZ_4K,
  24. .type = MT_DEVICE,
  25. };
  26. void __init imx_scu_map_io(void)
  27. {
  28. unsigned long base;
  29. /* Get SCU base */
  30. asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
  31. scu_io_desc.virtual = IMX_IO_P2V(base);
  32. scu_io_desc.pfn = __phys_to_pfn(base);
  33. iotable_init(&scu_io_desc, 1);
  34. scu_base = IMX_IO_ADDRESS(base);
  35. }
  36. void imx_scu_standby_enable(void)
  37. {
  38. u32 val = readl_relaxed(scu_base);
  39. val |= SCU_STANDBY_ENABLE;
  40. writel_relaxed(val, scu_base);
  41. }
  42. static int __cpuinit imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
  43. {
  44. imx_set_cpu_jump(cpu, v7_secondary_startup);
  45. imx_enable_cpu(cpu, true);
  46. return 0;
  47. }
  48. /*
  49. * Initialise the CPU possible map early - this describes the CPUs
  50. * which may be present or become present in the system.
  51. */
  52. static void __init imx_smp_init_cpus(void)
  53. {
  54. int i, ncores;
  55. ncores = scu_get_core_count(scu_base);
  56. for (i = ncores; i < NR_CPUS; i++)
  57. set_cpu_possible(i, false);
  58. }
  59. void imx_smp_prepare(void)
  60. {
  61. scu_enable(scu_base);
  62. }
  63. static void __init imx_smp_prepare_cpus(unsigned int max_cpus)
  64. {
  65. imx_smp_prepare();
  66. }
  67. struct smp_operations imx_smp_ops __initdata = {
  68. .smp_init_cpus = imx_smp_init_cpus,
  69. .smp_prepare_cpus = imx_smp_prepare_cpus,
  70. .smp_boot_secondary = imx_boot_secondary,
  71. #ifdef CONFIG_HOTPLUG_CPU
  72. .cpu_die = imx_cpu_die,
  73. .cpu_kill = imx_cpu_kill,
  74. #endif
  75. };