hotplug.c 1.9 KB

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