platsmp.c 2.0 KB
Newer Older
M
Magnus Damm 已提交
1 2 3 4
/*
 * SMP support for R-Mobile / SH-Mobile
 *
 * Copyright (C) 2010  Magnus Damm
5
 * Copyright (C) 2011  Paul Mundt
M
Magnus Damm 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * 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>
A
Arnd Bergmann 已提交
19
#include <linux/of.h>
20
#include <asm/hardware/gic.h>
21 22
#include <asm/mach-types.h>
#include <mach/common.h>
M
Magnus Damm 已提交
23

A
Arnd Bergmann 已提交
24 25
#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \
			of_machine_is_compatible("renesas,sh73a0"))
26
#define is_r8a7779() machine_is_marzen()
27

M
Magnus Damm 已提交
28 29
static unsigned int __init shmobile_smp_get_core_count(void)
{
30
	if (is_sh73a0())
31 32
		return sh73a0_get_core_count();

33 34 35
	if (is_r8a7779())
		return r8a7779_get_core_count();

M
Magnus Damm 已提交
36 37 38 39 40
	return 1;
}

static void __init shmobile_smp_prepare_cpus(void)
{
41
	if (is_sh73a0())
42
		sh73a0_smp_prepare_cpus();
43 44 45

	if (is_r8a7779())
		r8a7779_smp_prepare_cpus();
M
Magnus Damm 已提交
46 47
}

48 49
int shmobile_platform_cpu_kill(unsigned int cpu)
{
50 51 52
	if (is_r8a7779())
		return r8a7779_platform_cpu_kill(cpu);

53 54 55
	return 1;
}

M
Magnus Damm 已提交
56 57 58
void __cpuinit platform_secondary_init(unsigned int cpu)
{
	trace_hardirqs_off();
59

60
	if (is_sh73a0())
61
		sh73a0_secondary_init(cpu);
62 63 64

	if (is_r8a7779())
		r8a7779_secondary_init(cpu);
M
Magnus Damm 已提交
65 66 67 68
}

int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
{
69
	if (is_sh73a0())
70 71
		return sh73a0_boot_secondary(cpu);

72 73 74
	if (is_r8a7779())
		return r8a7779_boot_secondary(cpu);

M
Magnus Damm 已提交
75 76 77 78 79 80 81 82
	return -ENOSYS;
}

void __init smp_init_cpus(void)
{
	unsigned int ncores = shmobile_smp_get_core_count();
	unsigned int i;

83 84 85 86 87 88
	if (ncores > nr_cpu_ids) {
		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
			ncores, nr_cpu_ids);
		ncores = nr_cpu_ids;
	}

M
Magnus Damm 已提交
89 90
	for (i = 0; i < ncores; i++)
		set_cpu_possible(i, true);
91 92

	set_smp_cross_call(gic_raise_softirq);
M
Magnus Damm 已提交
93 94
}

95
void __init platform_smp_prepare_cpus(unsigned int max_cpus)
M
Magnus Damm 已提交
96
{
97
	shmobile_smp_prepare_cpus();
M
Magnus Damm 已提交
98
}