hotplug.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /*
  41. * platform-specific code to shutdown a CPU
  42. *
  43. * Called with IRQs disabled
  44. */
  45. void platform_cpu_die(unsigned int cpu)
  46. {
  47. cpu_enter_lowpower();
  48. imx_enable_cpu(cpu, false);
  49. /* spin here until hardware takes it down */
  50. while (1)
  51. ;
  52. }
  53. int platform_cpu_disable(unsigned int cpu)
  54. {
  55. /*
  56. * we don't allow CPU 0 to be shutdown (it is still too special
  57. * e.g. clock tick interrupts)
  58. */
  59. return cpu == 0 ? -EPERM : 0;
  60. }