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 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 20 | #include "sleep.h" |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 21 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 22 | static void (*tegra_hotplug_shutdown)(void); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 23 | |
Joseph Lo | b811943 | 2013-01-03 14:43:00 +0800 | [diff] [blame] | 24 | int tegra_cpu_kill(unsigned cpu) |
| 25 | { |
| 26 | cpu = cpu_logical_map(cpu); |
| 27 | |
| 28 | /* Clock gate the CPU */ |
| 29 | tegra_wait_cpu_in_reset(cpu); |
| 30 | tegra_disable_cpu_clock(cpu); |
| 31 | |
| 32 | return 1; |
| 33 | } |
| 34 | |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 35 | /* |
| 36 | * platform-specific code to shutdown a CPU |
| 37 | * |
| 38 | * Called with IRQs disabled |
| 39 | */ |
Marc Zyngier | a172573 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 40 | void __ref tegra_cpu_die(unsigned int cpu) |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 41 | { |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 42 | if (!tegra_hotplug_shutdown) { |
| 43 | WARN(1, "hotplug is not yet initialized\n"); |
| 44 | return; |
| 45 | } |
| 46 | |
Joseph Lo | 5788661 | 2013-01-03 14:42:59 +0800 | [diff] [blame] | 47 | /* Clean L1 data cache */ |
Joseph Lo | ac2527b | 2013-07-03 17:50:38 +0800 | [diff] [blame] | 48 | tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 49 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 50 | /* Shut down the current CPU. */ |
| 51 | tegra_hotplug_shutdown(); |
Russell King | d445026 | 2010-12-19 11:30:43 +0000 | [diff] [blame] | 52 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 53 | /* Should never return here. */ |
| 54 | BUG(); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 57 | static int __init tegra_hotplug_init(void) |
Joseph Lo | 453689e | 2012-08-16 17:31:52 +0800 | [diff] [blame] | 58 | { |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 59 | if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 60 | return 0; |
| 61 | |
| 62 | if (!soc_is_tegra()) |
| 63 | return 0; |
Joseph Lo | 453689e | 2012-08-16 17:31:52 +0800 | [diff] [blame] | 64 | |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 65 | 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] | 66 | tegra_hotplug_shutdown = tegra20_hotplug_shutdown; |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 67 | 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] | 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_114_SOC) && tegra_get_chip_id() == TEGRA114) |
Joseph Lo | 33d5c01 | 2013-05-20 18:39:29 +0800 | [diff] [blame] | 70 | tegra_hotplug_shutdown = tegra30_hotplug_shutdown; |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 71 | 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] | 72 | tegra_hotplug_shutdown = tegra30_hotplug_shutdown; |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 73 | |
| 74 | return 0; |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 75 | } |
Thierry Reding | 05ccf19 | 2014-07-11 11:00:37 +0200 | [diff] [blame] | 76 | pure_initcall(tegra_hotplug_init); |