blob: 5c907c2c04e0aeac370b1becb4f9f5f0be796d5a [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Colin Cross1cea7322010-02-21 17:46:23 -08002/*
Colin Cross1cea7322010-02-21 17:46:23 -08003 * Copyright (C) 2002 ARM Ltd.
4 * All Rights Reserved
Hiroshi Doyu74696882013-02-13 19:15:48 +02005 * Copyright (c) 2010, 2012-2013, NVIDIA Corporation. All rights reserved.
Colin Cross1cea7322010-02-21 17:46:23 -08006 */
Thierry Redinga0524ac2014-07-11 09:44:49 +02007
8#include <linux/clk/tegra.h>
Colin Cross1cea7322010-02-21 17:46:23 -08009#include <linux/kernel.h>
Colin Cross1cea7322010-02-21 17:46:23 -080010#include <linux/smp.h>
Colin Cross1cea7322010-02-21 17:46:23 -080011
Thierry Reding05ccf192014-07-11 11:00:37 +020012#include <soc/tegra/common.h>
Thierry Reding304664e2014-07-11 09:52:41 +020013#include <soc/tegra/fuse.h>
14
Joseph Lo59b0f682012-08-16 17:31:51 +080015#include <asm/smp_plat.h>
Colin Cross1cea7322010-02-21 17:46:23 -080016
Thierry Reding5c753e02016-04-28 14:50:14 +020017#include "common.h"
Joseph Lo59b0f682012-08-16 17:31:51 +080018#include "sleep.h"
Colin Cross1cea7322010-02-21 17:46:23 -080019
Joseph Lo59b0f682012-08-16 17:31:51 +080020static void (*tegra_hotplug_shutdown)(void);
Colin Cross1cea7322010-02-21 17:46:23 -080021
Joseph Lob8119432013-01-03 14:43:00 +080022int 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 Cross1cea7322010-02-21 17:46:23 -080033/*
34 * platform-specific code to shutdown a CPU
35 *
36 * Called with IRQs disabled
37 */
Stephen Boydb96fc2f2015-10-19 13:05:33 -070038void tegra_cpu_die(unsigned int cpu)
Colin Cross1cea7322010-02-21 17:46:23 -080039{
Thierry Reding05ccf192014-07-11 11:00:37 +020040 if (!tegra_hotplug_shutdown) {
41 WARN(1, "hotplug is not yet initialized\n");
42 return;
43 }
44
Joseph Lo57886612013-01-03 14:42:59 +080045 /* Clean L1 data cache */
Joseph Loac2527b2013-07-03 17:50:38 +080046 tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS);
Colin Cross1cea7322010-02-21 17:46:23 -080047
Joseph Lo59b0f682012-08-16 17:31:51 +080048 /* Shut down the current CPU. */
49 tegra_hotplug_shutdown();
Russell Kingd4450262010-12-19 11:30:43 +000050
Joseph Lo59b0f682012-08-16 17:31:51 +080051 /* Should never return here. */
52 BUG();
Colin Cross1cea7322010-02-21 17:46:23 -080053}
54
Thierry Reding05ccf192014-07-11 11:00:37 +020055static int __init tegra_hotplug_init(void)
Joseph Lo453689e2012-08-16 17:31:52 +080056{
Hiroshi Doyu74696882013-02-13 19:15:48 +020057 if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
Thierry Reding05ccf192014-07-11 11:00:37 +020058 return 0;
59
60 if (!soc_is_tegra())
61 return 0;
Joseph Lo453689e2012-08-16 17:31:52 +080062
Thierry Reding304664e2014-07-11 09:52:41 +020063 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20)
Hiroshi Doyu74696882013-02-13 19:15:48 +020064 tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020065 if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30)
Hiroshi Doyu74696882013-02-13 19:15:48 +020066 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020067 if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114)
Joseph Lo33d5c012013-05-20 18:39:29 +080068 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020069 if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124)
Joseph Lo9997e622013-10-11 17:57:30 +080070 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding05ccf192014-07-11 11:00:37 +020071
72 return 0;
Joseph Lo59b0f682012-08-16 17:31:51 +080073}
Thierry Reding05ccf192014-07-11 11:00:37 +020074pure_initcall(tegra_hotplug_init);