blob: 5a2b69cf5ba6d662851bb18e84a5b26670947dda [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
Paul Mundtc4135212011-01-07 12:03:22 +09005 * Copyright (C) 2011 Paul Mundt
Magnus Damm1c51ed42010-12-14 16:56:55 +09006 *
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>
Arnd Bergmann9601e872012-05-15 15:30:17 +000019#include <linux/of.h>
Russell King0f7b3322011-04-03 13:01:30 +010020#include <asm/hardware/gic.h>
Magnus Damm72f4d572010-12-14 16:57:11 +090021#include <asm/mach-types.h>
22#include <mach/common.h>
Magnus Damm1c51ed42010-12-14 16:56:55 +090023
Arnd Bergmann9601e872012-05-15 15:30:17 +000024#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \
25 of_machine_is_compatible("renesas,sh73a0"))
Magnus Dammf40aaf62012-01-10 17:44:39 +090026#define is_r8a7779() machine_is_marzen()
Magnus Damm28626632011-08-18 05:44:07 +000027
Magnus Damm1c51ed42010-12-14 16:56:55 +090028static unsigned int __init shmobile_smp_get_core_count(void)
29{
Magnus Damm28626632011-08-18 05:44:07 +000030 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090031 return sh73a0_get_core_count();
32
Magnus Dammf40aaf62012-01-10 17:44:39 +090033 if (is_r8a7779())
34 return r8a7779_get_core_count();
35
Magnus Damm1c51ed42010-12-14 16:56:55 +090036 return 1;
37}
38
39static void __init shmobile_smp_prepare_cpus(void)
40{
Magnus Damm28626632011-08-18 05:44:07 +000041 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090042 sh73a0_smp_prepare_cpus();
Magnus Dammf40aaf62012-01-10 17:44:39 +090043
44 if (is_r8a7779())
45 r8a7779_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090046}
47
Magnus Damm8b306792011-12-28 16:47:16 +090048int shmobile_platform_cpu_kill(unsigned int cpu)
49{
Magnus Dammf40aaf62012-01-10 17:44:39 +090050 if (is_r8a7779())
51 return r8a7779_platform_cpu_kill(cpu);
52
Magnus Damm8b306792011-12-28 16:47:16 +090053 return 1;
54}
55
Magnus Damm1c51ed42010-12-14 16:56:55 +090056void __cpuinit platform_secondary_init(unsigned int cpu)
57{
58 trace_hardirqs_off();
Magnus Damm72f4d572010-12-14 16:57:11 +090059
Magnus Damm28626632011-08-18 05:44:07 +000060 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090061 sh73a0_secondary_init(cpu);
Magnus Dammf40aaf62012-01-10 17:44:39 +090062
63 if (is_r8a7779())
64 r8a7779_secondary_init(cpu);
Magnus Damm1c51ed42010-12-14 16:56:55 +090065}
66
67int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
68{
Magnus Damm28626632011-08-18 05:44:07 +000069 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090070 return sh73a0_boot_secondary(cpu);
71
Magnus Dammf40aaf62012-01-10 17:44:39 +090072 if (is_r8a7779())
73 return r8a7779_boot_secondary(cpu);
74
Magnus Damm1c51ed42010-12-14 16:56:55 +090075 return -ENOSYS;
76}
77
78void __init smp_init_cpus(void)
79{
80 unsigned int ncores = shmobile_smp_get_core_count();
81 unsigned int i;
82
Russell Kinga06f9162011-10-20 22:04:18 +010083 if (ncores > nr_cpu_ids) {
84 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
85 ncores, nr_cpu_ids);
86 ncores = nr_cpu_ids;
87 }
88
Magnus Damm1c51ed42010-12-14 16:56:55 +090089 for (i = 0; i < ncores; i++)
90 set_cpu_possible(i, true);
Russell King0f7b3322011-04-03 13:01:30 +010091
92 set_smp_cross_call(gic_raise_softirq);
Magnus Damm1c51ed42010-12-14 16:56:55 +090093}
94
Paul Mundtc4135212011-01-07 12:03:22 +090095void __init platform_smp_prepare_cpus(unsigned int max_cpus)
Magnus Damm1c51ed42010-12-14 16:56:55 +090096{
Paul Mundtc4135212011-01-07 12:03:22 +090097 shmobile_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090098}