David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2011 Freescale Semiconductor, Inc. |
| 4 | * Copyright 2011 Linaro Ltd. |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/errno.h> |
| 8 | #include <linux/jiffies.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 9 | #include <asm/cacheflush.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 10 | #include <asm/cp15.h> |
| 11 | #include <asm/proc-fns.h> |
| 12 | |
| 13 | #include "common.h" |
| 14 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 15 | /* |
| 16 | * platform-specific code to shutdown a CPU |
| 17 | * |
| 18 | * Called with IRQs disabled |
| 19 | */ |
| 20 | void imx_cpu_die(unsigned int cpu) |
| 21 | { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 22 | v7_exit_coherency_flush(louis); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 23 | /* |
| 24 | * We use the cpu jumping argument register to sync with |
| 25 | * imx_cpu_kill() which is running on cpu0 and waiting for |
| 26 | * the register being cleared to kill the cpu. |
| 27 | */ |
| 28 | imx_set_cpu_arg(cpu, ~0); |
| 29 | |
| 30 | while (1) |
| 31 | cpu_do_idle(); |
| 32 | } |
| 33 | |
| 34 | int imx_cpu_kill(unsigned int cpu) |
| 35 | { |
| 36 | unsigned long timeout = jiffies + msecs_to_jiffies(50); |
| 37 | |
| 38 | while (imx_get_cpu_arg(cpu) == 0) |
| 39 | if (time_after(jiffies, timeout)) |
| 40 | return 0; |
| 41 | imx_enable_cpu(cpu, false); |
| 42 | imx_set_cpu_arg(cpu, 0); |
| 43 | return 1; |
| 44 | } |