blob: 8ec70782607296ae8a61c49eae8ac3f154864134 [file] [log] [blame]
Colin Cross1cea7322010-02-21 17:46:23 -08001/*
Colin Cross1cea7322010-02-21 17:46:23 -08002 * Copyright (C) 2002 ARM Ltd.
3 * All Rights Reserved
Hiroshi Doyu74696882013-02-13 19:15:48 +02004 * Copyright (c) 2010, 2012-2013, NVIDIA Corporation. All rights reserved.
Colin Cross1cea7322010-02-21 17:46:23 -08005 *
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 Redinga0524ac2014-07-11 09:44:49 +020010
11#include <linux/clk/tegra.h>
Colin Cross1cea7322010-02-21 17:46:23 -080012#include <linux/kernel.h>
Colin Cross1cea7322010-02-21 17:46:23 -080013#include <linux/smp.h>
Colin Cross1cea7322010-02-21 17:46:23 -080014
Thierry Reding05ccf192014-07-11 11:00:37 +020015#include <soc/tegra/common.h>
Thierry Reding304664e2014-07-11 09:52:41 +020016#include <soc/tegra/fuse.h>
17
Joseph Lo59b0f682012-08-16 17:31:51 +080018#include <asm/smp_plat.h>
Colin Cross1cea7322010-02-21 17:46:23 -080019
Thierry Reding5c753e02016-04-28 14:50:14 +020020#include "common.h"
Joseph Lo59b0f682012-08-16 17:31:51 +080021#include "sleep.h"
Colin Cross1cea7322010-02-21 17:46:23 -080022
Joseph Lo59b0f682012-08-16 17:31:51 +080023static void (*tegra_hotplug_shutdown)(void);
Colin Cross1cea7322010-02-21 17:46:23 -080024
Joseph Lob8119432013-01-03 14:43:00 +080025int 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 Cross1cea7322010-02-21 17:46:23 -080036/*
37 * platform-specific code to shutdown a CPU
38 *
39 * Called with IRQs disabled
40 */
Stephen Boydb96fc2f2015-10-19 13:05:33 -070041void tegra_cpu_die(unsigned int cpu)
Colin Cross1cea7322010-02-21 17:46:23 -080042{
Thierry Reding05ccf192014-07-11 11:00:37 +020043 if (!tegra_hotplug_shutdown) {
44 WARN(1, "hotplug is not yet initialized\n");
45 return;
46 }
47
Joseph Lo57886612013-01-03 14:42:59 +080048 /* Clean L1 data cache */
Joseph Loac2527b2013-07-03 17:50:38 +080049 tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS);
Colin Cross1cea7322010-02-21 17:46:23 -080050
Joseph Lo59b0f682012-08-16 17:31:51 +080051 /* Shut down the current CPU. */
52 tegra_hotplug_shutdown();
Russell Kingd4450262010-12-19 11:30:43 +000053
Joseph Lo59b0f682012-08-16 17:31:51 +080054 /* Should never return here. */
55 BUG();
Colin Cross1cea7322010-02-21 17:46:23 -080056}
57
Thierry Reding05ccf192014-07-11 11:00:37 +020058static int __init tegra_hotplug_init(void)
Joseph Lo453689e2012-08-16 17:31:52 +080059{
Hiroshi Doyu74696882013-02-13 19:15:48 +020060 if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
Thierry Reding05ccf192014-07-11 11:00:37 +020061 return 0;
62
63 if (!soc_is_tegra())
64 return 0;
Joseph Lo453689e2012-08-16 17:31:52 +080065
Thierry Reding304664e2014-07-11 09:52:41 +020066 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20)
Hiroshi Doyu74696882013-02-13 19:15:48 +020067 tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020068 if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30)
Hiroshi Doyu74696882013-02-13 19:15:48 +020069 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020070 if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114)
Joseph Lo33d5c012013-05-20 18:39:29 +080071 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020072 if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124)
Joseph Lo9997e622013-10-11 17:57:30 +080073 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding05ccf192014-07-11 11:00:37 +020074
75 return 0;
Joseph Lo59b0f682012-08-16 17:31:51 +080076}
Thierry Reding05ccf192014-07-11 11:00:37 +020077pure_initcall(tegra_hotplug_init);