2012-10-26 00:41:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2010-2011 Calxeda, Inc.
|
|
|
|
* Copyright 2012 Pavel Machek <pavel@denx.de>
|
|
|
|
* Based on platsmp.c, Copyright (C) 2002 ARM Ltd.
|
|
|
|
* Copyright (C) 2012 Altera Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_address.h>
|
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/smp_scu.h>
|
|
|
|
#include <asm/smp_plat.h>
|
|
|
|
|
|
|
|
#include "core.h"
|
|
|
|
|
2013-06-18 03:43:14 +08:00
|
|
|
static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
|
2012-10-26 00:41:39 +08:00
|
|
|
{
|
|
|
|
int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
|
|
|
|
|
arm: socfpga: fix fetching cpu1start_addr for SMP
When CPU1 is brought out of reset, it's MMU is not turned on yet, so it will
only be able to use physical addresses. For systems with that have the
MMU page configured for 0xC0000000, 0x80000000, or 0x40000000
"BIC 0x40000000" will work just fine, as it was just converting the
virtual address of &cpu1start_addr into a physical address, ie. 0xC0000000
became 0x80000000. So for systems where the SDRAM controller was able to do a
wrap-around access, this was working fine, as it was just dropping the MSB,
but for systems where out of bounds memory access is not allowed, this would
not allow CPU1 to correctly fetch &cpu1start_addr.
This patch fixes the secondary_trampoline code to correctly fetch the
physical address of cpu1start_addr directly. The patch will subtract the
correct PAGE_OFFSET from &cpu1start_addr. And since on this platform, the
physical memory will always start at 0x0, subtracting PAGE_OFFSET from
&cpu1start_addr will allow CPU1 to correctly fetch the value of cpu1start_addr.
While at it, change the name of cpu1start_addr to socfpga_cpu1start_addr
to avoid any future naming collisions for multiplatform image.
Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
---
v4: Updated commit log to correctly lay out the usage of PAGE_OFFSET and
add comments to the same effect.
v3: Used PAGE_OFFSET to get the physical address
v2: Correctly get the physical address instead of just a BIC hack.
2014-10-01 18:44:48 +08:00
|
|
|
if (socfpga_cpu1start_addr) {
|
2014-10-15 03:33:38 +08:00
|
|
|
/* This will put CPU #1 into reset. */
|
|
|
|
writel(RSTMGR_MPUMODRST_CPU1,
|
|
|
|
rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
|
|
|
|
|
2013-02-12 07:30:33 +08:00
|
|
|
memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
|
2012-10-26 00:41:39 +08:00
|
|
|
|
2014-10-15 03:33:38 +08:00
|
|
|
writel(virt_to_phys(socfpga_secondary_startup),
|
|
|
|
sys_manager_base_addr + (socfpga_cpu1start_addr & 0x000000ff));
|
2012-10-26 00:41:39 +08:00
|
|
|
|
2013-02-12 07:30:33 +08:00
|
|
|
flush_cache_all();
|
|
|
|
smp_wmb();
|
|
|
|
outer_clean_range(0, trampoline_size);
|
2012-10-26 00:41:39 +08:00
|
|
|
|
2014-10-15 03:33:38 +08:00
|
|
|
/* This will release CPU #1 out of reset. */
|
|
|
|
writel(0, rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
|
2013-02-12 07:30:33 +08:00
|
|
|
}
|
2012-10-26 00:41:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise the CPU possible map early - this describes the CPUs
|
|
|
|
* which may be present or become present in the system.
|
|
|
|
*/
|
|
|
|
static void __init socfpga_smp_init_cpus(void)
|
|
|
|
{
|
|
|
|
unsigned int i, ncores;
|
|
|
|
|
|
|
|
ncores = scu_get_core_count(socfpga_scu_base_addr);
|
|
|
|
|
|
|
|
for (i = 0; i < ncores; i++)
|
|
|
|
set_cpu_possible(i, true);
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
if (ncores > num_possible_cpus()) {
|
|
|
|
pr_warn("socfpga: no. of cores (%d) greater than configured"
|
|
|
|
"maximum of %d - clipping\n", ncores, num_possible_cpus());
|
|
|
|
ncores = num_possible_cpus();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ncores; i++)
|
|
|
|
set_cpu_possible(i, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
|
|
|
|
{
|
|
|
|
scu_enable(socfpga_scu_base_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* platform-specific code to shutdown a CPU
|
|
|
|
*
|
|
|
|
* Called with IRQs disabled
|
|
|
|
*/
|
|
|
|
static void socfpga_cpu_die(unsigned int cpu)
|
|
|
|
{
|
2014-10-15 03:33:38 +08:00
|
|
|
/* Do WFI. If we wake up early, go back into WFI */
|
|
|
|
while (1)
|
|
|
|
cpu_do_idle();
|
2012-10-26 00:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct smp_operations socfpga_smp_ops __initdata = {
|
|
|
|
.smp_init_cpus = socfpga_smp_init_cpus,
|
|
|
|
.smp_prepare_cpus = socfpga_smp_prepare_cpus,
|
|
|
|
.smp_boot_secondary = socfpga_boot_secondary,
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
.cpu_die = socfpga_cpu_die,
|
|
|
|
#endif
|
|
|
|
};
|