xref: /OK3568_Linux_fs/kernel/arch/arm/mach-tegra/hotplug.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  Copyright (C) 2002 ARM Ltd.
4*4882a593Smuzhiyun  *  All Rights Reserved
5*4882a593Smuzhiyun  *  Copyright (c) 2010, 2012-2013, NVIDIA Corporation. All rights reserved.
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #include <linux/clk/tegra.h>
9*4882a593Smuzhiyun #include <linux/kernel.h>
10*4882a593Smuzhiyun #include <linux/smp.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <soc/tegra/common.h>
13*4882a593Smuzhiyun #include <soc/tegra/fuse.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <asm/smp_plat.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include "common.h"
18*4882a593Smuzhiyun #include "sleep.h"
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun static void (*tegra_hotplug_shutdown)(void);
21*4882a593Smuzhiyun 
tegra_cpu_kill(unsigned cpu)22*4882a593Smuzhiyun int tegra_cpu_kill(unsigned cpu)
23*4882a593Smuzhiyun {
24*4882a593Smuzhiyun 	cpu = cpu_logical_map(cpu);
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun 	/* Clock gate the CPU */
27*4882a593Smuzhiyun 	tegra_wait_cpu_in_reset(cpu);
28*4882a593Smuzhiyun 	tegra_disable_cpu_clock(cpu);
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun 	return 1;
31*4882a593Smuzhiyun }
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /*
34*4882a593Smuzhiyun  * platform-specific code to shutdown a CPU
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * Called with IRQs disabled
37*4882a593Smuzhiyun  */
tegra_cpu_die(unsigned int cpu)38*4882a593Smuzhiyun void tegra_cpu_die(unsigned int cpu)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun 	if (!tegra_hotplug_shutdown) {
41*4882a593Smuzhiyun 		WARN(1, "hotplug is not yet initialized\n");
42*4882a593Smuzhiyun 		return;
43*4882a593Smuzhiyun 	}
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 	/* Clean L1 data cache */
46*4882a593Smuzhiyun 	tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS);
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	/* Shut down the current CPU. */
49*4882a593Smuzhiyun 	tegra_hotplug_shutdown();
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun 	/* Should never return here. */
52*4882a593Smuzhiyun 	BUG();
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun 
tegra_hotplug_init(void)55*4882a593Smuzhiyun static int __init tegra_hotplug_init(void)
56*4882a593Smuzhiyun {
57*4882a593Smuzhiyun 	if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
58*4882a593Smuzhiyun 		return 0;
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun 	if (!soc_is_tegra())
61*4882a593Smuzhiyun 		return 0;
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20)
64*4882a593Smuzhiyun 		tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
65*4882a593Smuzhiyun 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30)
66*4882a593Smuzhiyun 		tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
67*4882a593Smuzhiyun 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114)
68*4882a593Smuzhiyun 		tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
69*4882a593Smuzhiyun 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124)
70*4882a593Smuzhiyun 		tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun 	return 0;
73*4882a593Smuzhiyun }
74*4882a593Smuzhiyun pure_initcall(tegra_hotplug_init);
75