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