hotplug.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Cloned from linux/arch/arm/mach-realview/hotplug.c
  3. *
  4. * Copyright (C) 2002 ARM Ltd.
  5. * All Rights Reserved
  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. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/smp.h>
  14. #include <linux/io.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/cp15.h>
  17. #include <asm/smp_plat.h>
  18. #include "common.h"
  19. #include "regs-pmu.h"
  20. static inline void cpu_leave_lowpower(void)
  21. {
  22. unsigned int v;
  23. asm volatile(
  24. "mrc p15, 0, %0, c1, c0, 0\n"
  25. " orr %0, %0, %1\n"
  26. " mcr p15, 0, %0, c1, c0, 0\n"
  27. " mrc p15, 0, %0, c1, c0, 1\n"
  28. " orr %0, %0, %2\n"
  29. " mcr p15, 0, %0, c1, c0, 1\n"
  30. : "=&r" (v)
  31. : "Ir" (CR_C), "Ir" (0x40)
  32. : "cc");
  33. }
  34. static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
  35. {
  36. u32 mpidr = cpu_logical_map(cpu);
  37. u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  38. for (;;) {
  39. /* Turn the CPU off on next WFI instruction. */
  40. exynos_cpu_power_down(core_id);
  41. wfi();
  42. if (pen_release == core_id) {
  43. /*
  44. * OK, proper wakeup, we're done
  45. */
  46. break;
  47. }
  48. /*
  49. * Getting here, means that we have come out of WFI without
  50. * having been woken up - this shouldn't happen
  51. *
  52. * Just note it happening - when we're woken, we can report
  53. * its occurrence.
  54. */
  55. (*spurious)++;
  56. }
  57. }
  58. /*
  59. * platform-specific code to shutdown a CPU
  60. *
  61. * Called with IRQs disabled
  62. */
  63. void __ref exynos_cpu_die(unsigned int cpu)
  64. {
  65. int spurious = 0;
  66. v7_exit_coherency_flush(louis);
  67. platform_do_lowpower(cpu, &spurious);
  68. /*
  69. * bring this CPU back into the world of cache
  70. * coherency, and then restore interrupts
  71. */
  72. cpu_leave_lowpower();
  73. if (spurious)
  74. pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
  75. }