hotplug.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 <mach/regs-pmu.h>
  20. #include "common.h"
  21. extern volatile int pen_release;
  22. static inline void cpu_enter_lowpower(void)
  23. {
  24. unsigned int v;
  25. flush_cache_all();
  26. asm volatile(
  27. " mcr p15, 0, %1, c7, c5, 0\n"
  28. " mcr p15, 0, %1, c7, c10, 4\n"
  29. /*
  30. * Turn off coherency
  31. */
  32. " mrc p15, 0, %0, c1, c0, 1\n"
  33. " bic %0, %0, %3\n"
  34. " mcr p15, 0, %0, c1, c0, 1\n"
  35. " mrc p15, 0, %0, c1, c0, 0\n"
  36. " bic %0, %0, %2\n"
  37. " mcr p15, 0, %0, c1, c0, 0\n"
  38. : "=&r" (v)
  39. : "r" (0), "Ir" (CR_C), "Ir" (0x40)
  40. : "cc");
  41. }
  42. static inline void cpu_leave_lowpower(void)
  43. {
  44. unsigned int v;
  45. asm volatile(
  46. "mrc p15, 0, %0, c1, c0, 0\n"
  47. " orr %0, %0, %1\n"
  48. " mcr p15, 0, %0, c1, c0, 0\n"
  49. " mrc p15, 0, %0, c1, c0, 1\n"
  50. " orr %0, %0, %2\n"
  51. " mcr p15, 0, %0, c1, c0, 1\n"
  52. : "=&r" (v)
  53. : "Ir" (CR_C), "Ir" (0x40)
  54. : "cc");
  55. }
  56. static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
  57. {
  58. for (;;) {
  59. /* make cpu1 to be turned off at next WFI command */
  60. if (cpu == 1)
  61. __raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
  62. /*
  63. * here's the WFI
  64. */
  65. asm(".word 0xe320f003\n"
  66. :
  67. :
  68. : "memory", "cc");
  69. if (pen_release == cpu_logical_map(cpu)) {
  70. /*
  71. * OK, proper wakeup, we're done
  72. */
  73. break;
  74. }
  75. /*
  76. * Getting here, means that we have come out of WFI without
  77. * having been woken up - this shouldn't happen
  78. *
  79. * Just note it happening - when we're woken, we can report
  80. * its occurrence.
  81. */
  82. (*spurious)++;
  83. }
  84. }
  85. /*
  86. * platform-specific code to shutdown a CPU
  87. *
  88. * Called with IRQs disabled
  89. */
  90. void __ref exynos_cpu_die(unsigned int cpu)
  91. {
  92. int spurious = 0;
  93. /*
  94. * we're ready for shutdown now, so do it
  95. */
  96. cpu_enter_lowpower();
  97. platform_do_lowpower(cpu, &spurious);
  98. /*
  99. * bring this CPU back into the world of cache
  100. * coherency, and then restore interrupts
  101. */
  102. cpu_leave_lowpower();
  103. if (spurious)
  104. pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
  105. }