mcpm_platsmp.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 <linux/irqchip/arm-gic.h>
  17. #include <asm/mcpm.h>
  18. #include <asm/smp.h>
  19. #include <asm/smp_plat.h>
  20. static void __init simple_smp_init_cpus(void)
  21. {
  22. }
  23. static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
  24. {
  25. unsigned int mpidr, pcpu, pcluster, ret;
  26. extern void secondary_startup(void);
  27. mpidr = cpu_logical_map(cpu);
  28. pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  29. pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  30. pr_debug("%s: logical CPU %d is physical CPU %d cluster %d\n",
  31. __func__, cpu, pcpu, pcluster);
  32. mcpm_set_entry_vector(pcpu, pcluster, NULL);
  33. ret = mcpm_cpu_power_up(pcpu, pcluster);
  34. if (ret)
  35. return ret;
  36. mcpm_set_entry_vector(pcpu, pcluster, secondary_startup);
  37. arch_send_wakeup_ipi_mask(cpumask_of(cpu));
  38. dsb_sev();
  39. return 0;
  40. }
  41. static void __cpuinit mcpm_secondary_init(unsigned int cpu)
  42. {
  43. mcpm_cpu_powered_up();
  44. gic_secondary_init(0);
  45. }
  46. #ifdef CONFIG_HOTPLUG_CPU
  47. static int mcpm_cpu_disable(unsigned int cpu)
  48. {
  49. /*
  50. * We assume all CPUs may be shut down.
  51. * This would be the hook to use for eventual Secure
  52. * OS migration requests as described in the PSCI spec.
  53. */
  54. return 0;
  55. }
  56. static void mcpm_cpu_die(unsigned int cpu)
  57. {
  58. unsigned int mpidr, pcpu, pcluster;
  59. mpidr = read_cpuid_mpidr();
  60. pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  61. pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  62. mcpm_set_entry_vector(pcpu, pcluster, NULL);
  63. mcpm_cpu_power_down();
  64. }
  65. #endif
  66. static struct smp_operations __initdata mcpm_smp_ops = {
  67. .smp_init_cpus = simple_smp_init_cpus,
  68. .smp_boot_secondary = mcpm_boot_secondary,
  69. .smp_secondary_init = mcpm_secondary_init,
  70. #ifdef CONFIG_HOTPLUG_CPU
  71. .cpu_disable = mcpm_cpu_disable,
  72. .cpu_die = mcpm_cpu_die,
  73. #endif
  74. };
  75. void __init mcpm_smp_set_ops(void)
  76. {
  77. smp_set_ops(&mcpm_smp_ops);
  78. }