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 |
Paul Mundt | c413521 | 2011-01-07 12:03:22 +0900 | [diff] [blame] | 5 | * Copyright (C) 2011 Paul Mundt |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 6 | * |
| 7 | * Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/errno.h> |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/smp.h> |
| 18 | #include <linux/io.h> |
Russell King | 0f7b332 | 2011-04-03 13:01:30 +0100 | [diff] [blame] | 19 | #include <asm/hardware/gic.h> |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 20 | #include <asm/localtimer.h> |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 21 | #include <asm/mach-types.h> |
| 22 | #include <mach/common.h> |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 23 | |
Magnus Damm | 2862663 | 2011-08-18 05:44:07 +0000 | [diff] [blame^] | 24 | #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2()) |
| 25 | |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 26 | static unsigned int __init shmobile_smp_get_core_count(void) |
| 27 | { |
Magnus Damm | 2862663 | 2011-08-18 05:44:07 +0000 | [diff] [blame^] | 28 | if (is_sh73a0()) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 29 | return sh73a0_get_core_count(); |
| 30 | |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 31 | return 1; |
| 32 | } |
| 33 | |
| 34 | static void __init shmobile_smp_prepare_cpus(void) |
| 35 | { |
Magnus Damm | 2862663 | 2011-08-18 05:44:07 +0000 | [diff] [blame^] | 36 | if (is_sh73a0()) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 37 | sh73a0_smp_prepare_cpus(); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 38 | } |
| 39 | |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 40 | void __cpuinit platform_secondary_init(unsigned int cpu) |
| 41 | { |
| 42 | trace_hardirqs_off(); |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 43 | |
Magnus Damm | 2862663 | 2011-08-18 05:44:07 +0000 | [diff] [blame^] | 44 | if (is_sh73a0()) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 45 | sh73a0_secondary_init(cpu); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 49 | { |
Magnus Damm | 2862663 | 2011-08-18 05:44:07 +0000 | [diff] [blame^] | 50 | if (is_sh73a0()) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 51 | return sh73a0_boot_secondary(cpu); |
| 52 | |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 53 | return -ENOSYS; |
| 54 | } |
| 55 | |
| 56 | void __init smp_init_cpus(void) |
| 57 | { |
| 58 | unsigned int ncores = shmobile_smp_get_core_count(); |
| 59 | unsigned int i; |
| 60 | |
| 61 | for (i = 0; i < ncores; i++) |
| 62 | set_cpu_possible(i, true); |
Russell King | 0f7b332 | 2011-04-03 13:01:30 +0100 | [diff] [blame] | 63 | |
| 64 | set_smp_cross_call(gic_raise_softirq); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 65 | } |
| 66 | |
Paul Mundt | c413521 | 2011-01-07 12:03:22 +0900 | [diff] [blame] | 67 | void __init platform_smp_prepare_cpus(unsigned int max_cpus) |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 68 | { |
Paul Mundt | c413521 | 2011-01-07 12:03:22 +0900 | [diff] [blame] | 69 | shmobile_smp_prepare_cpus(); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 70 | } |