blob: 3f3325d4206d8592ab861ee951267aa83ebeaa3f [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 Damm1c51ed42010-12-14 16:56:55 +090020#include <asm/localtimer.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
Magnus Damm28626632011-08-18 05:44:07 +000024#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2())
25
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 Damm1c51ed42010-12-14 16:56:55 +090031 return 1;
32}
33
34static void __init shmobile_smp_prepare_cpus(void)
35{
Magnus Damm28626632011-08-18 05:44:07 +000036 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090037 sh73a0_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090038}
39
Magnus Damm8b306792011-12-28 16:47:16 +090040int shmobile_platform_cpu_kill(unsigned int cpu)
41{
42 return 1;
43}
44
Magnus Damm1c51ed42010-12-14 16:56:55 +090045void __cpuinit platform_secondary_init(unsigned int cpu)
46{
47 trace_hardirqs_off();
Magnus Damm72f4d572010-12-14 16:57:11 +090048
Magnus Damm28626632011-08-18 05:44:07 +000049 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090050 sh73a0_secondary_init(cpu);
Magnus Damm1c51ed42010-12-14 16:56:55 +090051}
52
53int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
54{
Magnus Damm28626632011-08-18 05:44:07 +000055 if (is_sh73a0())
Magnus Damm72f4d572010-12-14 16:57:11 +090056 return sh73a0_boot_secondary(cpu);
57
Magnus Damm1c51ed42010-12-14 16:56:55 +090058 return -ENOSYS;
59}
60
61void __init smp_init_cpus(void)
62{
63 unsigned int ncores = shmobile_smp_get_core_count();
64 unsigned int i;
65
Russell Kinga06f9162011-10-20 22:04:18 +010066 if (ncores > nr_cpu_ids) {
67 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
68 ncores, nr_cpu_ids);
69 ncores = nr_cpu_ids;
70 }
71
Magnus Damm1c51ed42010-12-14 16:56:55 +090072 for (i = 0; i < ncores; i++)
73 set_cpu_possible(i, true);
Russell King0f7b3322011-04-03 13:01:30 +010074
75 set_smp_cross_call(gic_raise_softirq);
Magnus Damm1c51ed42010-12-14 16:56:55 +090076}
77
Paul Mundtc4135212011-01-07 12:03:22 +090078void __init platform_smp_prepare_cpus(unsigned int max_cpus)
Magnus Damm1c51ed42010-12-14 16:56:55 +090079{
Paul Mundtc4135212011-01-07 12:03:22 +090080 shmobile_smp_prepare_cpus();
Magnus Damm1c51ed42010-12-14 16:56:55 +090081}