hotplug.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2002 ARM Ltd.
  3. * All Rights Reserved
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/errno.h>
  11. #include <linux/smp.h>
  12. #include <asm/cp15.h>
  13. #include <asm/smp_plat.h>
  14. static inline void cpu_enter_lowpower(void)
  15. {
  16. unsigned int v;
  17. asm volatile(
  18. " mcr p15, 0, %1, c7, c5, 0\n"
  19. " mcr p15, 0, %1, c7, c10, 4\n"
  20. /*
  21. * Turn off coherency
  22. */
  23. " mrc p15, 0, %0, c1, c0, 1\n"
  24. " bic %0, %0, #0x20\n"
  25. " mcr p15, 0, %0, c1, c0, 1\n"
  26. " mrc p15, 0, %0, c1, c0, 0\n"
  27. " bic %0, %0, %2\n"
  28. " mcr p15, 0, %0, c1, c0, 0\n"
  29. : "=&r" (v)
  30. : "r" (0), "Ir" (CR_C)
  31. : "cc");
  32. }
  33. static inline void cpu_leave_lowpower(void)
  34. {
  35. unsigned int v;
  36. asm volatile( "mrc p15, 0, %0, c1, c0, 0\n"
  37. " orr %0, %0, %1\n"
  38. " mcr p15, 0, %0, c1, c0, 0\n"
  39. " mrc p15, 0, %0, c1, c0, 1\n"
  40. " orr %0, %0, #0x20\n"
  41. " mcr p15, 0, %0, c1, c0, 1\n"
  42. : "=&r" (v)
  43. : "Ir" (CR_C)
  44. : "cc");
  45. }
  46. static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
  47. {
  48. /*
  49. * there is no power-control hardware on this platform, so all
  50. * we can do is put the core into WFI; this is safe as the calling
  51. * code will have already disabled interrupts
  52. */
  53. for (;;) {
  54. /*
  55. * here's the WFI
  56. */
  57. asm(".word 0xe320f003\n"
  58. :
  59. :
  60. : "memory", "cc");
  61. if (pen_release == cpu_logical_map(cpu)) {
  62. /*
  63. * OK, proper wakeup, we're done
  64. */
  65. break;
  66. }
  67. /*
  68. * Getting here, means that we have come out of WFI without
  69. * having been woken up - this shouldn't happen
  70. *
  71. * Just note it happening - when we're woken, we can report
  72. * its occurrence.
  73. */
  74. (*spurious)++;
  75. }
  76. }
  77. /*
  78. * platform-specific code to shutdown a CPU
  79. *
  80. * Called with IRQs disabled
  81. */
  82. void ox820_cpu_die(unsigned int cpu)
  83. {
  84. int spurious = 0;
  85. /*
  86. * we're ready for shutdown now, so do it
  87. */
  88. cpu_enter_lowpower();
  89. platform_do_lowpower(cpu, &spurious);
  90. /*
  91. * bring this CPU back into the world of cache
  92. * coherency, and then restore interrupts
  93. */
  94. cpu_leave_lowpower();
  95. if (spurious)
  96. pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
  97. }