platsmp.c 1.6 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>
19
#include <asm/hardware/gic.h>
M
Magnus Damm 已提交
20
#include <asm/localtimer.h>
21 22
#include <asm/mach-types.h>
#include <mach/common.h>
M
Magnus Damm 已提交
23 24 25

static unsigned int __init shmobile_smp_get_core_count(void)
{
26 27 28
	if (machine_is_ag5evm())
		return sh73a0_get_core_count();

M
Magnus Damm 已提交
29 30 31 32 33
	return 1;
}

static void __init shmobile_smp_prepare_cpus(void)
{
34 35
	if (machine_is_ag5evm())
		sh73a0_smp_prepare_cpus();
M
Magnus Damm 已提交
36 37 38 39 40
}

void __cpuinit platform_secondary_init(unsigned int cpu)
{
	trace_hardirqs_off();
41 42 43

	if (machine_is_ag5evm())
		sh73a0_secondary_init(cpu);
M
Magnus Damm 已提交
44 45 46 47
}

int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
{
48 49 50
	if (machine_is_ag5evm())
		return sh73a0_boot_secondary(cpu);

M
Magnus Damm 已提交
51 52 53 54 55 56 57 58
	return -ENOSYS;
}

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

59 60 61 62 63 64
	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 已提交
65 66
	for (i = 0; i < ncores; i++)
		set_cpu_possible(i, true);
67 68

	set_smp_cross_call(gic_raise_softirq);
M
Magnus Damm 已提交
69 70
}

71
void __init platform_smp_prepare_cpus(unsigned int max_cpus)
M
Magnus Damm 已提交
72
{
73
	shmobile_smp_prepare_cpus();
M
Magnus Damm 已提交
74
}