xref: /linux/arch/arm/mach-tegra/hotplug.c (revision 57886616ca7bff844a6427436d0c8faf74653f73)
11cea7326SColin Cross /*
21cea7326SColin Cross  *
31cea7326SColin Cross  *  Copyright (C) 2002 ARM Ltd.
41cea7326SColin Cross  *  All Rights Reserved
559b0f682SJoseph Lo  *  Copyright (c) 2010, 2012 NVIDIA Corporation. All rights reserved.
61cea7326SColin Cross  *
71cea7326SColin Cross  * This program is free software; you can redistribute it and/or modify
81cea7326SColin Cross  * it under the terms of the GNU General Public License version 2 as
91cea7326SColin Cross  * published by the Free Software Foundation.
101cea7326SColin Cross  */
111cea7326SColin Cross #include <linux/kernel.h>
121cea7326SColin Cross #include <linux/smp.h>
131cea7326SColin Cross 
141cea7326SColin Cross #include <asm/cacheflush.h>
1559b0f682SJoseph Lo #include <asm/smp_plat.h>
161cea7326SColin Cross 
1759b0f682SJoseph Lo #include "sleep.h"
1859b0f682SJoseph Lo #include "tegra_cpu_car.h"
191cea7326SColin Cross 
2059b0f682SJoseph Lo static void (*tegra_hotplug_shutdown)(void);
211cea7326SColin Cross 
221cea7326SColin Cross /*
231cea7326SColin Cross  * platform-specific code to shutdown a CPU
241cea7326SColin Cross  *
251cea7326SColin Cross  * Called with IRQs disabled
261cea7326SColin Cross  */
27a1725732SMarc Zyngier void __ref tegra_cpu_die(unsigned int cpu)
281cea7326SColin Cross {
2959b0f682SJoseph Lo 	cpu = cpu_logical_map(cpu);
30d4450261SRussell King 
31*57886616SJoseph Lo 	/* Clean L1 data cache */
32*57886616SJoseph Lo 	tegra_disable_clean_inv_dcache();
331cea7326SColin Cross 
3459b0f682SJoseph Lo 	/* Shut down the current CPU. */
3559b0f682SJoseph Lo 	tegra_hotplug_shutdown();
36d4450261SRussell King 
3759b0f682SJoseph Lo 	/* Clock gate the CPU */
3859b0f682SJoseph Lo 	tegra_wait_cpu_in_reset(cpu);
3959b0f682SJoseph Lo 	tegra_disable_cpu_clock(cpu);
4059b0f682SJoseph Lo 
4159b0f682SJoseph Lo 	/* Should never return here. */
4259b0f682SJoseph Lo 	BUG();
431cea7326SColin Cross }
441cea7326SColin Cross 
4525468fe8SOlof Johansson int tegra_cpu_disable(unsigned int cpu)
461cea7326SColin Cross {
471cea7326SColin Cross 	/*
481cea7326SColin Cross 	 * we don't allow CPU 0 to be shutdown (it is still too special
491cea7326SColin Cross 	 * e.g. clock tick interrupts)
501cea7326SColin Cross 	 */
511cea7326SColin Cross 	return cpu == 0 ? -EPERM : 0;
521cea7326SColin Cross }
5359b0f682SJoseph Lo 
54453689e4SJoseph Lo #ifdef CONFIG_ARCH_TEGRA_2x_SOC
55453689e4SJoseph Lo extern void tegra20_hotplug_shutdown(void);
56453689e4SJoseph Lo void __init tegra20_hotplug_init(void)
57453689e4SJoseph Lo {
58453689e4SJoseph Lo 	tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
59453689e4SJoseph Lo }
60453689e4SJoseph Lo #endif
61453689e4SJoseph Lo 
6259b0f682SJoseph Lo #ifdef CONFIG_ARCH_TEGRA_3x_SOC
6359b0f682SJoseph Lo extern void tegra30_hotplug_shutdown(void);
6459b0f682SJoseph Lo void __init tegra30_hotplug_init(void)
6559b0f682SJoseph Lo {
6659b0f682SJoseph Lo 	tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
6759b0f682SJoseph Lo }
6859b0f682SJoseph Lo #endif
69