hotplug.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/errno.h>
  13. #include <asm/cacheflush.h>
  14. #include <asm/cp15.h>
  15. #include <mach/common.h>
  16. int platform_cpu_kill(unsigned int cpu)
  17. {
  18. return 1;
  19. }
  20. static inline void cpu_enter_lowpower(void)
  21. {
  22. unsigned int v;
  23. flush_cache_all();
  24. asm volatile(
  25. "mcr p15, 0, %1, c7, c5, 0\n"
  26. " mcr p15, 0, %1, c7, c10, 4\n"
  27. /*
  28. * Turn off coherency
  29. */
  30. " mrc p15, 0, %0, c1, c0, 1\n"
  31. " bic %0, %0, %3\n"
  32. " mcr p15, 0, %0, c1, c0, 1\n"
  33. " mrc p15, 0, %0, c1, c0, 0\n"
  34. " bic %0, %0, %2\n"
  35. " mcr p15, 0, %0, c1, c0, 0\n"
  36. : "=&r" (v)
  37. : "r" (0), "Ir" (CR_C), "Ir" (0x40)
  38. : "cc");
  39. }
  40. static inline void cpu_leave_lowpower(void)
  41. {
  42. unsigned int v;
  43. asm volatile(
  44. "mrc p15, 0, %0, c1, c0, 0\n"
  45. " orr %0, %0, %1\n"
  46. " mcr p15, 0, %0, c1, c0, 0\n"
  47. " mrc p15, 0, %0, c1, c0, 1\n"
  48. " orr %0, %0, %2\n"
  49. " mcr p15, 0, %0, c1, c0, 1\n"
  50. : "=&r" (v)
  51. : "Ir" (CR_C), "Ir" (0x40)
  52. : "cc");
  53. }
  54. /*
  55. * platform-specific code to shutdown a CPU
  56. *
  57. * Called with IRQs disabled
  58. */
  59. void platform_cpu_die(unsigned int cpu)
  60. {
  61. cpu_enter_lowpower();
  62. imx_enable_cpu(cpu, false);
  63. cpu_do_idle();
  64. cpu_leave_lowpower();
  65. /* We should never return from idle */
  66. panic("cpu %d unexpectedly exit from shutdown\n", cpu);
  67. }
  68. int platform_cpu_disable(unsigned int cpu)
  69. {
  70. /*
  71. * we don't allow CPU 0 to be shutdown (it is still too special
  72. * e.g. clock tick interrupts)
  73. */
  74. return cpu == 0 ? -EPERM : 0;
  75. }