hotplug.c 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright 2011 Freescale Semiconductor, Inc.
  4. * Copyright 2011 Linaro Ltd.
  5. */
  6. #include <linux/errno.h>
  7. #include <linux/jiffies.h>
  8. #include <asm/cacheflush.h>
  9. #include <asm/cp15.h>
  10. #include <asm/proc-fns.h>
  11. #include "common.h"
  12. #include "hardware.h"
  13. /*
  14. * platform-specific code to shutdown a CPU
  15. *
  16. * Called with IRQs disabled
  17. */
  18. void imx_cpu_die(unsigned int cpu)
  19. {
  20. v7_exit_coherency_flush(louis);
  21. /*
  22. * We use the cpu jumping argument register to sync with
  23. * imx_cpu_kill() which is running on cpu0 and waiting for
  24. * the register being cleared to kill the cpu.
  25. */
  26. imx_set_cpu_arg(cpu, ~0);
  27. while (1)
  28. cpu_do_idle();
  29. }
  30. int imx_cpu_kill(unsigned int cpu)
  31. {
  32. unsigned long timeout = jiffies + msecs_to_jiffies(50);
  33. while (imx_get_cpu_arg(cpu) == 0)
  34. if (time_after(jiffies, timeout))
  35. return 0;
  36. imx_enable_cpu(cpu, false);
  37. imx_set_cpu_arg(cpu, 0);
  38. if (cpu_is_imx7d())
  39. imx_gpcv2_set_core1_pdn_pup_by_software(true);
  40. return 1;
  41. }