blob: 3c2c0f49073ee2f8c0ae316ee886577d3e5e6120 [file] [log] [blame]
Magnus Damm1c51ed42010-12-14 16:56:55 +09001/*
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 Damm72f4d572010-12-14 16:57:11 +090019#include <asm/mach-types.h>
20#include <mach/common.h>
Magnus Damm1c51ed42010-12-14 16:56:55 +090021
22static unsigned int __init shmobile_smp_get_core_count(void)
23{
Magnus Damm72f4d572010-12-14 16:57:11 +090024 if (machine_is_ag5evm())
25 return sh73a0_get_core_count();
26
Magnus Damm1c51ed42010-12-14 16:56:55 +090027 return 1;
28}
29
30static void __init shmobile_smp_prepare_cpus(void)
31{
Magnus Damm72f4d572010-12-14 16:57:11 +090032 if (machine_is_ag5evm())
33 sh73a0_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090034}
35
36
37void __cpuinit platform_secondary_init(unsigned int cpu)
38{
39 trace_hardirqs_off();
Magnus Damm72f4d572010-12-14 16:57:11 +090040
41 if (machine_is_ag5evm())
42 sh73a0_secondary_init(cpu);
Magnus Damm1c51ed42010-12-14 16:56:55 +090043}
44
45int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
46{
Magnus Damm72f4d572010-12-14 16:57:11 +090047 if (machine_is_ag5evm())
48 return sh73a0_boot_secondary(cpu);
49
Magnus Damm1c51ed42010-12-14 16:56:55 +090050 return -ENOSYS;
51}
52
53void __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
62void __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}