platsmp.c 2.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (C) 2002 ARM Ltd.
 * Copyright (C) 2008 STMicroelctronics.
 * Copyright (C) 2009 ST-Ericsson.
 * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
 *
 * This file is based on arm realview platform
 *
 * 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 20
#include <linux/of.h>
#include <linux/of_address.h>
21 22

#include <asm/cacheflush.h>
23
#include <asm/smp_plat.h>
24
#include <asm/smp_scu.h>
25

26
#include "setup.h"
27

28
#include "db8500-regs.h"
29 30
#include "id.h"

31 32 33
/* Magic triggers in backup RAM */
#define UX500_CPU1_JUMPADDR_OFFSET 0x1FF4
#define UX500_CPU1_WAKEMAGIC_OFFSET 0x1FF0
34

35
static void wakeup_secondary(void)
36
{
37 38
	struct device_node *np;
	static void __iomem *backupram;
39

40 41 42 43 44 45 46 47 48 49
	np = of_find_compatible_node(NULL, NULL, "ste,dbx500-backupram");
	if (!np) {
		pr_err("No backupram base address\n");
		return;
	}
	backupram = of_iomap(np, 0);
	of_node_put(np);
	if (!backupram) {
		pr_err("No backupram remap\n");
		return;
50 51 52 53 54 55
	}

	/*
	 * write the address of secondary startup into the backup ram register
	 * at offset 0x1FF4, then write the magic number 0xA1FEED01 to the
	 * backup ram register at offset 0x1FF0, which is what boot rom code
56
	 * is waiting for. This will wake up the secondary core from WFE.
57
	 */
58 59 60 61
	writel(virt_to_phys(secondary_startup),
	       backupram + UX500_CPU1_JUMPADDR_OFFSET);
	writel(0xA1FEED01,
	       backupram + UX500_CPU1_WAKEMAGIC_OFFSET);
62 63 64

	/* make sure write buffer is drained */
	mb();
65
	iounmap(backupram);
66 67
}

68
static void __init ux500_smp_prepare_cpus(unsigned int max_cpus)
69
{
70
	struct device_node *np;
71 72 73
	static void __iomem *scu_base;
	unsigned int ncores;
	int i;
74

75
	np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
76 77 78 79
	if (!np) {
		pr_err("No SCU base address\n");
		return;
	}
80 81
	scu_base = of_iomap(np, 0);
	of_node_put(np);
82 83
	if (!scu_base) {
		pr_err("No SCU remap\n");
84
		return;
85 86
	}

87 88
	scu_enable(scu_base);
	ncores = scu_get_core_count(scu_base);
89 90
	for (i = 0; i < ncores; i++)
		set_cpu_possible(i, true);
91
	iounmap(scu_base);
92
}
93

94
static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
95
{
96
	wakeup_secondary();
97 98
	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
	return 0;
99
}
100

101
static const struct smp_operations ux500_smp_ops __initconst = {
102 103 104 105 106 107
	.smp_prepare_cpus	= ux500_smp_prepare_cpus,
	.smp_boot_secondary	= ux500_boot_secondary,
#ifdef CONFIG_HOTPLUG_CPU
	.cpu_die		= ux500_cpu_die,
#endif
};
108
CPU_METHOD_OF_DECLARE(ux500_smp, "ste,dbx500-smp", &ux500_smp_ops);