Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 2 | /* |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 3 | * Copyright (C) 2002 ARM Ltd. |
| 4 | * All Rights Reserved |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 5 | * Copyright (c) 2010, 2012-2013, NVIDIA Corporation. All rights reserved. |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 6 | */ |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 7 | |
| 8 | #include <linux/clk/tegra.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 9 | #include <linux/kernel.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 10 | #include <linux/smp.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 11 | |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 12 | #include <soc/tegra/common.h> |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 13 | #include <soc/tegra/fuse.h> |
| 14 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 15 | #include <asm/smp_plat.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 16 | |
Thierry Reding | 5c753e0 | 2016-04-28 14:50:14 +0200 | [diff] [blame] | 17 | #include "common.h" |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 18 | #include "sleep.h" |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 19 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 20 | static void (*tegra_hotplug_shutdown)(void); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 21 | |
Joseph Lo | b811943 | 2013-01-03 14:43:00 +0800 | [diff] [blame] | 22 | int tegra_cpu_kill(unsigned cpu) |
| 23 | { |
| 24 | cpu = cpu_logical_map(cpu); |
| 25 | |
| 26 | /* Clock gate the CPU */ |
| 27 | tegra_wait_cpu_in_reset(cpu); |
| 28 | tegra_disable_cpu_clock(cpu); |
| 29 | |
| 30 | return 1; |
| 31 | } |
| 32 | |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 33 | /* |
| 34 | * platform-specific code to shutdown a CPU |
| 35 | * |
| 36 | * Called with IRQs disabled |
| 37 | */ |
Stephen Boyd | b96fc2f | 2015-10-19 13:05:33 -0700 | [diff] [blame] | 38 | void tegra_cpu_die(unsigned int cpu) |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 39 | { |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 40 | if (!tegra_hotplug_shutdown) { |
| 41 | WARN(1, "hotplug is not yet initialized\n"); |
| 42 | return; |
| 43 | } |
| 44 | |
Joseph Lo | 5788661 | 2013-01-03 14:42:59 +0800 | [diff] [blame] | 45 | /* Clean L1 data cache */ |
Joseph Lo | ac2527b | 2013-07-03 17:50:38 +0800 | [diff] [blame] | 46 | tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 47 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 48 | /* Shut down the current CPU. */ |
| 49 | tegra_hotplug_shutdown(); |
Russell King | d445026 | 2010-12-19 11:30:43 +0000 | [diff] [blame] | 50 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 51 | /* Should never return here. */ |
| 52 | BUG(); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 55 | static int __init tegra_hotplug_init(void) |
Joseph Lo | 453689e | 2012-08-16 17:31:52 +0800 | [diff] [blame] | 56 | { |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 57 | if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 58 | return 0; |
| 59 | |
| 60 | if (!soc_is_tegra()) |
| 61 | return 0; |
Joseph Lo | 453689e | 2012-08-16 17:31:52 +0800 | [diff] [blame] | 62 | |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 63 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20) |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 64 | tegra_hotplug_shutdown = tegra20_hotplug_shutdown; |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 65 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30) |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 66 | tegra_hotplug_shutdown = tegra30_hotplug_shutdown; |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 67 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114) |
Joseph Lo | 33d5c01 | 2013-05-20 18:39:29 +0800 | [diff] [blame] | 68 | tegra_hotplug_shutdown = tegra30_hotplug_shutdown; |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 69 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124) |
Joseph Lo | 9997e62 | 2013-10-11 17:57:30 +0800 | [diff] [blame] | 70 | tegra_hotplug_shutdown = tegra30_hotplug_shutdown; |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 71 | |
| 72 | return 0; |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 73 | } |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 74 | pure_initcall(tegra_hotplug_init); |