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 vexpress, 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/init.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/device.h> |
| 16 | #include <linux/smp.h> |
| 17 | #include <linux/io.h> |
| 18 | #include <asm/localtimer.h> |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame^] | 19 | #include <asm/mach-types.h> |
| 20 | #include <mach/common.h> |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 21 | |
| 22 | static unsigned int __init shmobile_smp_get_core_count(void) |
| 23 | { |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame^] | 24 | if (machine_is_ag5evm()) |
| 25 | return sh73a0_get_core_count(); |
| 26 | |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 27 | return 1; |
| 28 | } |
| 29 | |
| 30 | static void __init shmobile_smp_prepare_cpus(void) |
| 31 | { |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame^] | 32 | if (machine_is_ag5evm()) |
| 33 | sh73a0_smp_prepare_cpus(); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | |
| 37 | void __cpuinit platform_secondary_init(unsigned int cpu) |
| 38 | { |
| 39 | trace_hardirqs_off(); |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame^] | 40 | |
| 41 | if (machine_is_ag5evm()) |
| 42 | sh73a0_secondary_init(cpu); |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 46 | { |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame^] | 47 | if (machine_is_ag5evm()) |
| 48 | return sh73a0_boot_secondary(cpu); |
| 49 | |
Magnus Damm | 1c51ed4 | 2010-12-14 16:56:55 +0900 | [diff] [blame] | 50 | return -ENOSYS; |
| 51 | } |
| 52 | |
| 53 | void __init smp_init_cpus(void) |
| 54 | { |
| 55 | unsigned int ncores = shmobile_smp_get_core_count(); |
| 56 | unsigned int i; |
| 57 | |
| 58 | for (i = 0; i < ncores; i++) |
| 59 | set_cpu_possible(i, true); |
| 60 | } |
| 61 | |
| 62 | void __init smp_prepare_cpus(unsigned int max_cpus) |
| 63 | { |
| 64 | unsigned int ncores = shmobile_smp_get_core_count(); |
| 65 | unsigned int cpu = smp_processor_id(); |
| 66 | int i; |
| 67 | |
| 68 | smp_store_cpu_info(cpu); |
| 69 | |
| 70 | if (max_cpus > ncores) |
| 71 | max_cpus = ncores; |
| 72 | |
| 73 | for (i = 0; i < max_cpus; i++) |
| 74 | set_cpu_present(i, true); |
| 75 | |
| 76 | if (max_cpus > 1) { |
| 77 | shmobile_smp_prepare_cpus(); |
| 78 | |
| 79 | /* |
| 80 | * Enable the local timer or broadcast device for the |
| 81 | * boot CPU, but only if we have more than one CPU. |
| 82 | */ |
| 83 | percpu_timer_setup(); |
| 84 | } |
| 85 | } |