11cea7326SColin Cross /* 21cea7326SColin Cross * Copyright (C) 2002 ARM Ltd. 31cea7326SColin Cross * All Rights Reserved 47469688eSHiroshi Doyu * Copyright (c) 2010, 2012-2013, NVIDIA Corporation. All rights reserved. 51cea7326SColin Cross * 61cea7326SColin Cross * This program is free software; you can redistribute it and/or modify 71cea7326SColin Cross * it under the terms of the GNU General Public License version 2 as 81cea7326SColin Cross * published by the Free Software Foundation. 91cea7326SColin Cross */ 10a0524accSThierry Reding 11a0524accSThierry Reding #include <linux/clk/tegra.h> 121cea7326SColin Cross #include <linux/kernel.h> 131cea7326SColin Cross #include <linux/smp.h> 141cea7326SColin Cross 1505ccf196SThierry Reding #include <soc/tegra/common.h> 16304664eaSThierry Reding #include <soc/tegra/fuse.h> 17304664eaSThierry Reding 1859b0f682SJoseph Lo #include <asm/smp_plat.h> 191cea7326SColin Cross 20*5c753e04SThierry Reding #include "common.h" 2159b0f682SJoseph Lo #include "sleep.h" 221cea7326SColin Cross 2359b0f682SJoseph Lo static void (*tegra_hotplug_shutdown)(void); 241cea7326SColin Cross 25b8119431SJoseph Lo int tegra_cpu_kill(unsigned cpu) 26b8119431SJoseph Lo { 27b8119431SJoseph Lo cpu = cpu_logical_map(cpu); 28b8119431SJoseph Lo 29b8119431SJoseph Lo /* Clock gate the CPU */ 30b8119431SJoseph Lo tegra_wait_cpu_in_reset(cpu); 31b8119431SJoseph Lo tegra_disable_cpu_clock(cpu); 32b8119431SJoseph Lo 33b8119431SJoseph Lo return 1; 34b8119431SJoseph Lo } 35b8119431SJoseph Lo 361cea7326SColin Cross /* 371cea7326SColin Cross * platform-specific code to shutdown a CPU 381cea7326SColin Cross * 391cea7326SColin Cross * Called with IRQs disabled 401cea7326SColin Cross */ 41b96fc2f3SStephen Boyd void tegra_cpu_die(unsigned int cpu) 421cea7326SColin Cross { 4305ccf196SThierry Reding if (!tegra_hotplug_shutdown) { 4405ccf196SThierry Reding WARN(1, "hotplug is not yet initialized\n"); 4505ccf196SThierry Reding return; 4605ccf196SThierry Reding } 4705ccf196SThierry Reding 4857886616SJoseph Lo /* Clean L1 data cache */ 49ac2527bfSJoseph Lo tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS); 501cea7326SColin Cross 5159b0f682SJoseph Lo /* Shut down the current CPU. */ 5259b0f682SJoseph Lo tegra_hotplug_shutdown(); 53d4450261SRussell King 5459b0f682SJoseph Lo /* Should never return here. */ 5559b0f682SJoseph Lo BUG(); 561cea7326SColin Cross } 571cea7326SColin Cross 5805ccf196SThierry Reding static int __init tegra_hotplug_init(void) 59453689e4SJoseph Lo { 607469688eSHiroshi Doyu if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) 6105ccf196SThierry Reding return 0; 6205ccf196SThierry Reding 6305ccf196SThierry Reding if (!soc_is_tegra()) 6405ccf196SThierry Reding return 0; 65453689e4SJoseph Lo 66304664eaSThierry Reding if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20) 677469688eSHiroshi Doyu tegra_hotplug_shutdown = tegra20_hotplug_shutdown; 68304664eaSThierry Reding if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30) 6959b0f682SJoseph Lo tegra_hotplug_shutdown = tegra30_hotplug_shutdown; 70304664eaSThierry Reding if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114) 7133d5c019SJoseph Lo tegra_hotplug_shutdown = tegra30_hotplug_shutdown; 72304664eaSThierry Reding if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124) 739997e626SJoseph Lo tegra_hotplug_shutdown = tegra30_hotplug_shutdown; 7405ccf196SThierry Reding 7505ccf196SThierry Reding return 0; 7659b0f682SJoseph Lo } 7705ccf196SThierry Reding pure_initcall(tegra_hotplug_init); 78