2010-12-14 15:56:55 +08:00
|
|
|
/*
|
|
|
|
* SMP support for R-Mobile / SH-Mobile
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Magnus Damm
|
2011-01-07 11:03:22 +08:00
|
|
|
* Copyright (C) 2011 Paul Mundt
|
2010-12-14 15:56:55 +08:00
|
|
|
*
|
|
|
|
* Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/io.h>
|
2012-05-16 14:46:03 +08:00
|
|
|
#include <linux/of.h>
|
2011-04-03 20:01:30 +08:00
|
|
|
#include <asm/hardware/gic.h>
|
2010-12-14 15:57:11 +08:00
|
|
|
#include <asm/mach-types.h>
|
|
|
|
#include <mach/common.h>
|
2012-05-16 14:45:25 +08:00
|
|
|
#include <mach/emev2.h>
|
2010-12-14 15:56:55 +08:00
|
|
|
|
2012-07-06 16:20:05 +08:00
|
|
|
#ifdef CONFIG_ARCH_SH73A0
|
2012-05-15 23:30:17 +08:00
|
|
|
#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \
|
|
|
|
of_machine_is_compatible("renesas,sh73a0"))
|
2012-07-06 16:20:05 +08:00
|
|
|
#else
|
|
|
|
#define is_sh73a0() (0)
|
|
|
|
#endif
|
|
|
|
|
2012-01-10 16:44:39 +08:00
|
|
|
#define is_r8a7779() machine_is_marzen()
|
2012-06-20 17:30:41 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_EMEV2
|
2012-05-16 14:46:03 +08:00
|
|
|
#define is_emev2() of_machine_is_compatible("renesas,emev2")
|
2012-06-20 17:30:41 +08:00
|
|
|
#else
|
|
|
|
#define is_emev2() (0)
|
|
|
|
#endif
|
2011-08-18 13:44:07 +08:00
|
|
|
|
2010-12-14 15:56:55 +08:00
|
|
|
static unsigned int __init shmobile_smp_get_core_count(void)
|
|
|
|
{
|
2011-08-18 13:44:07 +08:00
|
|
|
if (is_sh73a0())
|
2010-12-14 15:57:11 +08:00
|
|
|
return sh73a0_get_core_count();
|
|
|
|
|
2012-01-10 16:44:39 +08:00
|
|
|
if (is_r8a7779())
|
|
|
|
return r8a7779_get_core_count();
|
|
|
|
|
2012-05-16 14:45:25 +08:00
|
|
|
if (is_emev2())
|
|
|
|
return emev2_get_core_count();
|
|
|
|
|
2010-12-14 15:56:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init shmobile_smp_prepare_cpus(void)
|
|
|
|
{
|
2011-08-18 13:44:07 +08:00
|
|
|
if (is_sh73a0())
|
2010-12-14 15:57:11 +08:00
|
|
|
sh73a0_smp_prepare_cpus();
|
2012-01-10 16:44:39 +08:00
|
|
|
|
|
|
|
if (is_r8a7779())
|
|
|
|
r8a7779_smp_prepare_cpus();
|
2012-05-16 14:45:25 +08:00
|
|
|
|
|
|
|
if (is_emev2())
|
|
|
|
emev2_smp_prepare_cpus();
|
2010-12-14 15:56:55 +08:00
|
|
|
}
|
|
|
|
|
2011-12-28 15:47:16 +08:00
|
|
|
int shmobile_platform_cpu_kill(unsigned int cpu)
|
|
|
|
{
|
2012-01-10 16:44:39 +08:00
|
|
|
if (is_r8a7779())
|
|
|
|
return r8a7779_platform_cpu_kill(cpu);
|
|
|
|
|
2012-05-16 14:45:25 +08:00
|
|
|
if (is_emev2())
|
|
|
|
return emev2_platform_cpu_kill(cpu);
|
|
|
|
|
2011-12-28 15:47:16 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-12-14 15:56:55 +08:00
|
|
|
void __cpuinit platform_secondary_init(unsigned int cpu)
|
|
|
|
{
|
|
|
|
trace_hardirqs_off();
|
2010-12-14 15:57:11 +08:00
|
|
|
|
2011-08-18 13:44:07 +08:00
|
|
|
if (is_sh73a0())
|
2010-12-14 15:57:11 +08:00
|
|
|
sh73a0_secondary_init(cpu);
|
2012-01-10 16:44:39 +08:00
|
|
|
|
|
|
|
if (is_r8a7779())
|
|
|
|
r8a7779_secondary_init(cpu);
|
2012-05-16 14:45:25 +08:00
|
|
|
|
|
|
|
if (is_emev2())
|
|
|
|
emev2_secondary_init(cpu);
|
2010-12-14 15:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
|
|
|
|
{
|
2011-08-18 13:44:07 +08:00
|
|
|
if (is_sh73a0())
|
2010-12-14 15:57:11 +08:00
|
|
|
return sh73a0_boot_secondary(cpu);
|
|
|
|
|
2012-01-10 16:44:39 +08:00
|
|
|
if (is_r8a7779())
|
|
|
|
return r8a7779_boot_secondary(cpu);
|
|
|
|
|
2012-05-16 14:45:25 +08:00
|
|
|
if (is_emev2())
|
|
|
|
return emev2_boot_secondary(cpu);
|
|
|
|
|
2010-12-14 15:56:55 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init smp_init_cpus(void)
|
|
|
|
{
|
|
|
|
unsigned int ncores = shmobile_smp_get_core_count();
|
|
|
|
unsigned int i;
|
|
|
|
|
2011-10-21 05:04:18 +08:00
|
|
|
if (ncores > nr_cpu_ids) {
|
|
|
|
pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
|
|
|
|
ncores, nr_cpu_ids);
|
|
|
|
ncores = nr_cpu_ids;
|
|
|
|
}
|
|
|
|
|
2010-12-14 15:56:55 +08:00
|
|
|
for (i = 0; i < ncores; i++)
|
|
|
|
set_cpu_possible(i, true);
|
2011-04-03 20:01:30 +08:00
|
|
|
|
|
|
|
set_smp_cross_call(gic_raise_softirq);
|
2010-12-14 15:56:55 +08:00
|
|
|
}
|
|
|
|
|
2011-01-07 11:03:22 +08:00
|
|
|
void __init platform_smp_prepare_cpus(unsigned int max_cpus)
|
2010-12-14 15:56:55 +08:00
|
|
|
{
|
2011-01-07 11:03:22 +08:00
|
|
|
shmobile_smp_prepare_cpus();
|
2010-12-14 15:56:55 +08:00
|
|
|
}
|