platsmp.c 3.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Copyright 2011 Freescale Semiconductor, Inc.
 * Copyright 2011 Linaro Ltd.
 *
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

#include <linux/init.h>
14 15
#include <linux/of_address.h>
#include <linux/of.h>
16
#include <linux/smp.h>
17

18
#include <asm/cacheflush.h>
19 20 21 22
#include <asm/page.h>
#include <asm/smp_scu.h>
#include <asm/mach/map.h>

23
#include "common.h"
24
#include "hardware.h"
25

26
u32 g_diag_reg;
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
static void __iomem *scu_base;

static struct map_desc scu_io_desc __initdata = {
	/* .virtual and .pfn are run-time assigned */
	.length		= SZ_4K,
	.type		= MT_DEVICE,
};

void __init imx_scu_map_io(void)
{
	unsigned long base;

	/* Get SCU base */
	asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));

	scu_io_desc.virtual = IMX_IO_P2V(base);
	scu_io_desc.pfn = __phys_to_pfn(base);
	iotable_init(&scu_io_desc, 1);

	scu_base = IMX_IO_ADDRESS(base);
}

49
static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
50 51 52 53 54 55 56 57 58 59
{
	imx_set_cpu_jump(cpu, v7_secondary_startup);
	imx_enable_cpu(cpu, true);
	return 0;
}

/*
 * Initialise the CPU possible map early - this describes the CPUs
 * which may be present or become present in the system.
 */
60
static void __init imx_smp_init_cpus(void)
61 62 63 64 65
{
	int i, ncores;

	ncores = scu_get_core_count(scu_base);

66 67
	for (i = ncores; i < NR_CPUS; i++)
		set_cpu_possible(i, false);
68 69 70 71 72 73 74
}

void imx_smp_prepare(void)
{
	scu_enable(scu_base);
}

75
static void __init imx_smp_prepare_cpus(unsigned int max_cpus)
76 77
{
	imx_smp_prepare();
78 79 80 81 82 83 84 85 86 87

	/*
	 * The diagnostic register holds the errata bits.  Mostly bootloader
	 * does not bring up secondary cores, so that when errata bits are set
	 * in bootloader, they are set only for boot cpu.  But on a SMP
	 * configuration, it should be equally done on every single core.
	 * Read the register from boot cpu here, and will replicate it into
	 * secondary cores when booting them.
	 */
	asm("mrc p15, 0, %0, c15, c0, 1" : "=r" (g_diag_reg) : : "cc");
88
	sync_cache_w(&g_diag_reg);
89
}
90

91
const struct smp_operations imx_smp_ops __initconst = {
92 93 94 95 96
	.smp_init_cpus		= imx_smp_init_cpus,
	.smp_prepare_cpus	= imx_smp_prepare_cpus,
	.smp_boot_secondary	= imx_boot_secondary,
#ifdef CONFIG_HOTPLUG_CPU
	.cpu_die		= imx_cpu_die,
97
	.cpu_kill		= imx_cpu_kill,
98 99
#endif
};
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119

#define DCFG_CCSR_SCRATCHRW1	0x200

static int ls1021a_boot_secondary(unsigned int cpu, struct task_struct *idle)
{
	arch_send_wakeup_ipi_mask(cpumask_of(cpu));

	return 0;
}

static void __init ls1021a_smp_prepare_cpus(unsigned int max_cpus)
{
	struct device_node *np;
	void __iomem *dcfg_base;
	unsigned long paddr;

	np = of_find_compatible_node(NULL, NULL, "fsl,ls1021a-dcfg");
	dcfg_base = of_iomap(np, 0);
	BUG_ON(!dcfg_base);

120
	paddr = __pa_symbol(secondary_startup);
121 122 123 124 125
	writel_relaxed(cpu_to_be32(paddr), dcfg_base + DCFG_CCSR_SCRATCHRW1);

	iounmap(dcfg_base);
}

126
const struct smp_operations ls1021a_smp_ops __initconst = {
127 128 129
	.smp_prepare_cpus	= ls1021a_smp_prepare_cpus,
	.smp_boot_secondary	= ls1021a_boot_secondary,
};