mcpm_platsmp.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * linux/arch/arm/mach-vexpress/mcpm_platsmp.c
  3. *
  4. * Created by: Nicolas Pitre, November 2012
  5. * Copyright: (C) 2012-2013 Linaro Limited
  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 version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * Code to handle secondary CPU bringup and hotplug for the cluster power API.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/smp.h>
  15. #include <linux/spinlock.h>
  16. #include <asm/mcpm.h>
  17. #include <asm/smp.h>
  18. #include <asm/smp_plat.h>
  19. static void __init simple_smp_init_cpus(void)
  20. {
  21. }
  22. static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
  23. {
  24. unsigned int mpidr, pcpu, pcluster, ret;
  25. extern void secondary_startup(void);
  26. mpidr = cpu_logical_map(cpu);
  27. pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  28. pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  29. pr_debug("%s: logical CPU %d is physical CPU %d cluster %d\n",
  30. __func__, cpu, pcpu, pcluster);
  31. mcpm_set_entry_vector(pcpu, pcluster, NULL);
  32. ret = mcpm_cpu_power_up(pcpu, pcluster);
  33. if (ret)
  34. return ret;
  35. mcpm_set_entry_vector(pcpu, pcluster, secondary_startup);
  36. arch_send_wakeup_ipi_mask(cpumask_of(cpu));
  37. dsb_sev();
  38. return 0;
  39. }
  40. static void __cpuinit mcpm_secondary_init(unsigned int cpu)
  41. {
  42. mcpm_cpu_powered_up();
  43. }
  44. #ifdef CONFIG_HOTPLUG_CPU
  45. static int mcpm_cpu_disable(unsigned int cpu)
  46. {
  47. /*
  48. * We assume all CPUs may be shut down.
  49. * This would be the hook to use for eventual Secure
  50. * OS migration requests as described in the PSCI spec.
  51. */
  52. return 0;
  53. }
  54. static void mcpm_cpu_die(unsigned int cpu)
  55. {
  56. unsigned int mpidr, pcpu, pcluster;
  57. mpidr = read_cpuid_mpidr();
  58. pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  59. pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  60. mcpm_set_entry_vector(pcpu, pcluster, NULL);
  61. mcpm_cpu_power_down();
  62. }
  63. #endif
  64. static struct smp_operations __initdata mcpm_smp_ops = {
  65. .smp_init_cpus = simple_smp_init_cpus,
  66. .smp_boot_secondary = mcpm_boot_secondary,
  67. .smp_secondary_init = mcpm_secondary_init,
  68. #ifdef CONFIG_HOTPLUG_CPU
  69. .cpu_disable = mcpm_cpu_disable,
  70. .cpu_die = mcpm_cpu_die,
  71. #endif
  72. };
  73. void __init mcpm_smp_set_ops(void)
  74. {
  75. smp_set_ops(&mcpm_smp_ops);
  76. }