blob: 45fa3924c6a1e231e12f4b9aa230b0f5af41c849 [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>
Russell King0f7b3322011-04-03 13:01:30 +010019#include <asm/hardware/gic.h>
Magnus Damm72f4d572010-12-14 16:57:11 +090020#include <asm/mach-types.h>
21#include <mach/common.h>
Magnus Damm1c51ed42010-12-14 16:56:55 +090022
Magnus Damm28626632011-08-18 05:44:07 +000023#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2())
Magnus Dammf40aaf62012-01-10 17:44:39 +090024#define is_r8a7779() machine_is_marzen()
Magnus Damm28626632011-08-18 05:44:07 +000025
Magnus Damm1c51ed42010-12-14 16:56:55 +090026static unsigned int __init shmobile_smp_get_core_count(void)
27{
Magnus Damm28626632011-08-18 05:44:07 +000028 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090029 return sh73a0_get_core_count();
30
Magnus Dammf40aaf62012-01-10 17:44:39 +090031 if (is_r8a7779())
32 return r8a7779_get_core_count();
33
Magnus Damm1c51ed42010-12-14 16:56:55 +090034 return 1;
35}
36
37static void __init shmobile_smp_prepare_cpus(void)
38{
Magnus Damm28626632011-08-18 05:44:07 +000039 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090040 sh73a0_smp_prepare_cpus();
Magnus Dammf40aaf62012-01-10 17:44:39 +090041
42 if (is_r8a7779())
43 r8a7779_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090044}
45
Magnus Damm8b306792011-12-28 16:47:16 +090046int shmobile_platform_cpu_kill(unsigned int cpu)
47{
Magnus Dammf40aaf62012-01-10 17:44:39 +090048 if (is_r8a7779())
49 return r8a7779_platform_cpu_kill(cpu);
50
Magnus Damm8b306792011-12-28 16:47:16 +090051 return 1;
52}
53
Magnus Damm1c51ed42010-12-14 16:56:55 +090054void __cpuinit platform_secondary_init(unsigned int cpu)
55{
56 trace_hardirqs_off();
Magnus Damm72f4d572010-12-14 16:57:11 +090057
Magnus Damm28626632011-08-18 05:44:07 +000058 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090059 sh73a0_secondary_init(cpu);
Magnus Dammf40aaf62012-01-10 17:44:39 +090060
61 if (is_r8a7779())
62 r8a7779_secondary_init(cpu);
Magnus Damm1c51ed42010-12-14 16:56:55 +090063}
64
65int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
66{
Magnus Damm28626632011-08-18 05:44:07 +000067 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090068 return sh73a0_boot_secondary(cpu);
69
Magnus Dammf40aaf62012-01-10 17:44:39 +090070 if (is_r8a7779())
71 return r8a7779_boot_secondary(cpu);
72
Magnus Damm1c51ed42010-12-14 16:56:55 +090073 return -ENOSYS;
74}
75
76void __init smp_init_cpus(void)
77{
78 unsigned int ncores = shmobile_smp_get_core_count();
79 unsigned int i;
80
Russell Kinga06f9162011-10-20 22:04:18 +010081 if (ncores > nr_cpu_ids) {
82 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
83 ncores, nr_cpu_ids);
84 ncores = nr_cpu_ids;
85 }
86
Magnus Damm1c51ed42010-12-14 16:56:55 +090087 for (i = 0; i < ncores; i++)
88 set_cpu_possible(i, true);
Russell King0f7b3322011-04-03 13:01:30 +010089
90 set_smp_cross_call(gic_raise_softirq);
Magnus Damm1c51ed42010-12-14 16:56:55 +090091}
92
Paul Mundtc4135212011-01-07 12:03:22 +090093void __init platform_smp_prepare_cpus(unsigned int max_cpus)
Magnus Damm1c51ed42010-12-14 16:56:55 +090094{
Paul Mundtc4135212011-01-07 12:03:22 +090095 shmobile_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090096}