Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 1 | /* |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 2002 ARM Ltd. |
| 4 | * All Rights Reserved |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 5 | * Copyright (c) 2010, 2012 NVIDIA Corporation. All rights reserved. |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 12 | #include <linux/smp.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 13 | |
| 14 | #include <asm/cacheflush.h> |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 15 | #include <asm/smp_plat.h> |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 16 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 17 | #include "sleep.h" |
| 18 | #include "tegra_cpu_car.h" |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 19 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 20 | static void (*tegra_hotplug_shutdown)(void); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 21 | |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 22 | /* |
| 23 | * platform-specific code to shutdown a CPU |
| 24 | * |
| 25 | * Called with IRQs disabled |
| 26 | */ |
Marc Zyngier | a172573 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 27 | void __ref tegra_cpu_die(unsigned int cpu) |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 28 | { |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 29 | cpu = cpu_logical_map(cpu); |
Russell King | d445026 | 2010-12-19 11:30:43 +0000 | [diff] [blame] | 30 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 31 | /* Flush the L1 data cache. */ |
| 32 | flush_cache_all(); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 33 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 34 | /* Shut down the current CPU. */ |
| 35 | tegra_hotplug_shutdown(); |
Russell King | d445026 | 2010-12-19 11:30:43 +0000 | [diff] [blame] | 36 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 37 | /* Clock gate the CPU */ |
| 38 | tegra_wait_cpu_in_reset(cpu); |
| 39 | tegra_disable_cpu_clock(cpu); |
| 40 | |
| 41 | /* Should never return here. */ |
| 42 | BUG(); |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 43 | } |
| 44 | |
Olof Johansson | 25468fe | 2012-09-22 00:06:21 -0700 | [diff] [blame] | 45 | int tegra_cpu_disable(unsigned int cpu) |
Colin Cross | 1cea732 | 2010-02-21 17:46:23 -0800 | [diff] [blame] | 46 | { |
| 47 | /* |
| 48 | * we don't allow CPU 0 to be shutdown (it is still too special |
| 49 | * e.g. clock tick interrupts) |
| 50 | */ |
| 51 | return cpu == 0 ? -EPERM : 0; |
| 52 | } |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 53 | |
Joseph Lo | 453689e | 2012-08-16 17:31:52 +0800 | [diff] [blame] | 54 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC |
| 55 | extern void tegra20_hotplug_shutdown(void); |
| 56 | void __init tegra20_hotplug_init(void) |
| 57 | { |
| 58 | tegra_hotplug_shutdown = tegra20_hotplug_shutdown; |
| 59 | } |
| 60 | #endif |
| 61 | |
Joseph Lo | 59b0f68 | 2012-08-16 17:31:51 +0800 | [diff] [blame] | 62 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC |
| 63 | extern void tegra30_hotplug_shutdown(void); |
| 64 | void __init tegra30_hotplug_init(void) |
| 65 | { |
| 66 | tegra_hotplug_shutdown = tegra30_hotplug_shutdown; |
| 67 | } |
| 68 | #endif |