blob: 1b129899a277f1853b6309782caac72f1f4a45d3 [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
Joseph Lo59b0f682012-08-16 17:31:51 +080020#include "sleep.h"
Colin Cross1cea7322010-02-21 17:46:23 -080021
Joseph Lo59b0f682012-08-16 17:31:51 +080022static void (*tegra_hotplug_shutdown)(void);
Colin Cross1cea7322010-02-21 17:46:23 -080023
Joseph Lob8119432013-01-03 14:43:00 +080024int 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 Cross1cea7322010-02-21 17:46:23 -080035/*
36 * platform-specific code to shutdown a CPU
37 *
38 * Called with IRQs disabled
39 */
Stephen Boydb96fc2f2015-10-19 13:05:33 -070040void tegra_cpu_die(unsigned int cpu)
Colin Cross1cea7322010-02-21 17:46:23 -080041{
Thierry Reding05ccf192014-07-11 11:00:37 +020042 if (!tegra_hotplug_shutdown) {
43 WARN(1, "hotplug is not yet initialized\n");
44 return;
45 }
46
Joseph Lo57886612013-01-03 14:42:59 +080047 /* Clean L1 data cache */
Joseph Loac2527b2013-07-03 17:50:38 +080048 tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS);
Colin Cross1cea7322010-02-21 17:46:23 -080049
Joseph Lo59b0f682012-08-16 17:31:51 +080050 /* Shut down the current CPU. */
51 tegra_hotplug_shutdown();
Russell Kingd4450262010-12-19 11:30:43 +000052
Joseph Lo59b0f682012-08-16 17:31:51 +080053 /* Should never return here. */
54 BUG();
Colin Cross1cea7322010-02-21 17:46:23 -080055}
56
Thierry Reding05ccf192014-07-11 11:00:37 +020057static int __init tegra_hotplug_init(void)
Joseph Lo453689e2012-08-16 17:31:52 +080058{
Hiroshi Doyu74696882013-02-13 19:15:48 +020059 if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
Thierry Reding05ccf192014-07-11 11:00:37 +020060 return 0;
61
62 if (!soc_is_tegra())
63 return 0;
Joseph Lo453689e2012-08-16 17:31:52 +080064
Thierry Reding304664e2014-07-11 09:52:41 +020065 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20)
Hiroshi Doyu74696882013-02-13 19:15:48 +020066 tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020067 if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30)
Hiroshi Doyu74696882013-02-13 19:15:48 +020068 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020069 if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114)
Joseph Lo33d5c012013-05-20 18:39:29 +080070 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding304664e2014-07-11 09:52:41 +020071 if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124)
Joseph Lo9997e622013-10-11 17:57:30 +080072 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Thierry Reding05ccf192014-07-11 11:00:37 +020073
74 return 0;
Joseph Lo59b0f682012-08-16 17:31:51 +080075}
Thierry Reding05ccf192014-07-11 11:00:37 +020076pure_initcall(tegra_hotplug_init);