blob: 8da9f78475da21f81ef314bbd7e9e04939398378 [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 */
10#include <linux/kernel.h>
Colin Cross1cea7322010-02-21 17:46:23 -080011#include <linux/smp.h>
Prashant Gaikwad89572c72013-01-11 13:16:21 +053012#include <linux/clk/tegra.h>
Colin Cross1cea7322010-02-21 17:46:23 -080013
14#include <asm/cacheflush.h>
Joseph Lo59b0f682012-08-16 17:31:51 +080015#include <asm/smp_plat.h>
Colin Cross1cea7322010-02-21 17:46:23 -080016
Hiroshi Doyu74696882013-02-13 19:15:48 +020017#include "fuse.h"
Joseph Lo59b0f682012-08-16 17:31:51 +080018#include "sleep.h"
Colin Cross1cea7322010-02-21 17:46:23 -080019
Joseph Lo59b0f682012-08-16 17:31:51 +080020static void (*tegra_hotplug_shutdown)(void);
Colin Cross1cea7322010-02-21 17:46:23 -080021
Joseph Lob8119432013-01-03 14:43:00 +080022int tegra_cpu_kill(unsigned cpu)
23{
24 cpu = cpu_logical_map(cpu);
25
26 /* Clock gate the CPU */
27 tegra_wait_cpu_in_reset(cpu);
28 tegra_disable_cpu_clock(cpu);
29
30 return 1;
31}
32
Colin Cross1cea7322010-02-21 17:46:23 -080033/*
34 * platform-specific code to shutdown a CPU
35 *
36 * Called with IRQs disabled
37 */
Marc Zyngiera1725732011-09-08 13:15:22 +010038void __ref tegra_cpu_die(unsigned int cpu)
Colin Cross1cea7322010-02-21 17:46:23 -080039{
Joseph Lo57886612013-01-03 14:42:59 +080040 /* Clean L1 data cache */
41 tegra_disable_clean_inv_dcache();
Colin Cross1cea7322010-02-21 17:46:23 -080042
Joseph Lo59b0f682012-08-16 17:31:51 +080043 /* Shut down the current CPU. */
44 tegra_hotplug_shutdown();
Russell Kingd4450262010-12-19 11:30:43 +000045
Joseph Lo59b0f682012-08-16 17:31:51 +080046 /* Should never return here. */
47 BUG();
Colin Cross1cea7322010-02-21 17:46:23 -080048}
49
Olof Johansson25468fe2012-09-22 00:06:21 -070050int tegra_cpu_disable(unsigned int cpu)
Colin Cross1cea7322010-02-21 17:46:23 -080051{
52 /*
53 * we don't allow CPU 0 to be shutdown (it is still too special
54 * e.g. clock tick interrupts)
55 */
56 return cpu == 0 ? -EPERM : 0;
57}
Joseph Lo59b0f682012-08-16 17:31:51 +080058
Hiroshi Doyu74696882013-02-13 19:15:48 +020059void __init tegra_hotplug_init(void)
Joseph Lo453689e2012-08-16 17:31:52 +080060{
Hiroshi Doyu74696882013-02-13 19:15:48 +020061 if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
62 return;
Joseph Lo453689e2012-08-16 17:31:52 +080063
Hiroshi Doyu74696882013-02-13 19:15:48 +020064 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20)
65 tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
66 if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_chip_id == TEGRA30)
67 tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
Joseph Lo59b0f682012-08-16 17:31:51 +080068}