Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 1 | /* |
| 2 | * SMP support for R-Mobile / SH-Mobile |
| 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * |
| 6 | * Based on realview, Copyright (C) 2002 ARM Ltd, All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/smp.h> |
Magnus Damm | 1229835 | 2011-12-28 16:53:16 +0900 | [diff] [blame] | 15 | #include <linux/cpumask.h> |
| 16 | #include <linux/delay.h> |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 17 | #include <linux/of.h> |
Magnus Damm | 8b30679 | 2011-12-28 16:47:16 +0900 | [diff] [blame] | 18 | #include <mach/common.h> |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 19 | #include <mach/r8a7779.h> |
| 20 | #include <mach/emev2.h> |
Magnus Damm | 1229835 | 2011-12-28 16:53:16 +0900 | [diff] [blame] | 21 | #include <asm/cacheflush.h> |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 22 | #include <asm/mach-types.h> |
Magnus Damm | 1229835 | 2011-12-28 16:53:16 +0900 | [diff] [blame] | 23 | |
| 24 | static cpumask_t dead_cpus; |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 25 | |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 26 | void shmobile_cpu_die(unsigned int cpu) |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 27 | { |
Magnus Damm | 1229835 | 2011-12-28 16:53:16 +0900 | [diff] [blame] | 28 | /* hardware shutdown code running on the CPU that is being offlined */ |
| 29 | flush_cache_all(); |
| 30 | dsb(); |
| 31 | |
| 32 | /* notify platform_cpu_kill() that hardware shutdown is finished */ |
| 33 | cpumask_set_cpu(cpu, &dead_cpus); |
| 34 | |
| 35 | /* wait for SoC code in platform_cpu_kill() to shut off CPU core |
| 36 | * power. CPU bring up starts from the reset vector. |
| 37 | */ |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 38 | while (1) { |
| 39 | /* |
| 40 | * here's the WFI |
| 41 | */ |
| 42 | asm(".word 0xe320f003\n" |
| 43 | : |
| 44 | : |
| 45 | : "memory", "cc"); |
| 46 | } |
| 47 | } |
| 48 | |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 49 | int shmobile_cpu_disable(unsigned int cpu) |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 50 | { |
Magnus Damm | 1229835 | 2011-12-28 16:53:16 +0900 | [diff] [blame] | 51 | cpumask_clear_cpu(cpu, &dead_cpus); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 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 | } |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 58 | |
| 59 | int shmobile_cpu_is_dead(unsigned int cpu) |
| 60 | { |
| 61 | return cpumask_test_cpu(cpu, &dead_cpus); |
| 62 | } |