hotplug.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/cp15.h>
  14. #include "common.h"
  15. static inline void cpu_enter_lowpower(void)
  16. {
  17. unsigned int v;
  18. asm volatile(
  19. "mcr p15, 0, %1, c7, c5, 0\n"
  20. " mcr p15, 0, %1, c7, c10, 4\n"
  21. /*
  22. * Turn off coherency
  23. */
  24. " mrc p15, 0, %0, c1, c0, 1\n"
  25. " bic %0, %0, %3\n"
  26. " mcr p15, 0, %0, c1, c0, 1\n"
  27. " mrc p15, 0, %0, c1, c0, 0\n"
  28. " bic %0, %0, %2\n"
  29. " mcr p15, 0, %0, c1, c0, 0\n"
  30. : "=&r" (v)
  31. : "r" (0), "Ir" (CR_C), "Ir" (0x40)
  32. : "cc");
  33. }
  34. /*
  35. * platform-specific code to shutdown a CPU
  36. *
  37. * Called with IRQs disabled
  38. */
  39. void imx_cpu_die(unsigned int cpu)
  40. {
  41. cpu_enter_lowpower();
  42. /*
  43. * We use the cpu jumping argument register to sync with
  44. * imx_cpu_kill() which is running on cpu0 and waiting for
  45. * the register being cleared to kill the cpu.
  46. */
  47. imx_set_cpu_arg(cpu, ~0);
  48. cpu_do_idle();
  49. }
  50. int imx_cpu_kill(unsigned int cpu)
  51. {
  52. unsigned long timeout = jiffies + msecs_to_jiffies(50);
  53. while (imx_get_cpu_arg(cpu) == 0)
  54. if (time_after(jiffies, timeout))
  55. return 0;
  56. imx_enable_cpu(cpu, false);
  57. imx_set_cpu_arg(cpu, 0);
  58. return 1;
  59. }