2009-11-28 15:17:18 +08:00
|
|
|
/*
|
|
|
|
* 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>
|
2015-05-14 15:46:40 +08:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_address.h>
|
2009-11-28 15:17:18 +08:00
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
2012-01-20 19:01:12 +08:00
|
|
|
#include <asm/smp_plat.h>
|
2009-11-28 15:17:18 +08:00
|
|
|
#include <asm/smp_scu.h>
|
2012-09-20 01:31:19 +08:00
|
|
|
|
2013-03-22 05:51:12 +08:00
|
|
|
#include "setup.h"
|
2009-11-28 15:17:18 +08:00
|
|
|
|
2013-03-19 22:41:55 +08:00
|
|
|
#include "db8500-regs.h"
|
2012-09-20 01:31:19 +08:00
|
|
|
|
2015-08-03 15:26:52 +08:00
|
|
|
/* Magic triggers in backup RAM */
|
|
|
|
#define UX500_CPU1_JUMPADDR_OFFSET 0x1FF4
|
|
|
|
#define UX500_CPU1_WAKEMAGIC_OFFSET 0x1FF0
|
2009-11-28 15:17:18 +08:00
|
|
|
|
2015-08-03 15:26:52 +08:00
|
|
|
static void wakeup_secondary(void)
|
2009-11-28 15:17:18 +08:00
|
|
|
{
|
2015-08-03 15:26:52 +08:00
|
|
|
struct device_node *np;
|
|
|
|
static void __iomem *backupram;
|
2010-09-15 17:45:51 +08:00
|
|
|
|
2015-08-03 15:26:52 +08:00
|
|
|
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;
|
2009-11-28 15:17:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2015-08-03 15:26:52 +08:00
|
|
|
* is waiting for. This will wake up the secondary core from WFE.
|
2009-11-28 15:17:18 +08:00
|
|
|
*/
|
2015-08-03 15:26:52 +08:00
|
|
|
writel(virt_to_phys(secondary_startup),
|
|
|
|
backupram + UX500_CPU1_JUMPADDR_OFFSET);
|
|
|
|
writel(0xA1FEED01,
|
|
|
|
backupram + UX500_CPU1_WAKEMAGIC_OFFSET);
|
2009-11-28 15:17:18 +08:00
|
|
|
|
|
|
|
/* make sure write buffer is drained */
|
|
|
|
mb();
|
2015-08-03 15:26:52 +08:00
|
|
|
iounmap(backupram);
|
2009-11-28 15:17:18 +08:00
|
|
|
}
|
|
|
|
|
2015-08-03 15:26:52 +08:00
|
|
|
static void __init ux500_smp_prepare_cpus(unsigned int max_cpus)
|
2009-11-28 15:17:18 +08:00
|
|
|
{
|
2015-05-14 15:46:40 +08:00
|
|
|
struct device_node *np;
|
2015-08-03 15:26:52 +08:00
|
|
|
static void __iomem *scu_base;
|
|
|
|
unsigned int ncores;
|
|
|
|
int i;
|
2009-11-28 15:17:18 +08:00
|
|
|
|
2015-05-14 15:46:40 +08:00
|
|
|
np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
|
2015-08-03 15:26:52 +08:00
|
|
|
if (!np) {
|
|
|
|
pr_err("No SCU base address\n");
|
|
|
|
return;
|
|
|
|
}
|
2015-05-14 15:46:40 +08:00
|
|
|
scu_base = of_iomap(np, 0);
|
|
|
|
of_node_put(np);
|
2015-08-03 15:26:52 +08:00
|
|
|
if (!scu_base) {
|
|
|
|
pr_err("No SCU remap\n");
|
2015-05-14 15:46:40 +08:00
|
|
|
return;
|
2009-11-28 15:17:18 +08:00
|
|
|
}
|
|
|
|
|
2015-08-03 15:26:52 +08:00
|
|
|
scu_enable(scu_base);
|
|
|
|
ncores = scu_get_core_count(scu_base);
|
2010-12-03 18:42:58 +08:00
|
|
|
for (i = 0; i < ncores; i++)
|
|
|
|
set_cpu_possible(i, true);
|
2015-08-03 15:26:52 +08:00
|
|
|
iounmap(scu_base);
|
2010-12-03 18:42:58 +08:00
|
|
|
}
|
2009-11-28 15:17:18 +08:00
|
|
|
|
2015-08-03 15:26:52 +08:00
|
|
|
static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
|
2010-12-03 18:42:58 +08:00
|
|
|
{
|
2010-12-03 19:09:48 +08:00
|
|
|
wakeup_secondary();
|
2015-08-03 15:26:52 +08:00
|
|
|
arch_send_wakeup_ipi_mask(cpumask_of(cpu));
|
|
|
|
return 0;
|
2009-11-28 15:17:18 +08:00
|
|
|
}
|
2011-09-08 20:15:22 +08:00
|
|
|
|
2015-11-15 09:39:53 +08:00
|
|
|
static const struct smp_operations ux500_smp_ops __initconst = {
|
2011-09-08 20:15:22 +08:00
|
|
|
.smp_prepare_cpus = ux500_smp_prepare_cpus,
|
|
|
|
.smp_boot_secondary = ux500_boot_secondary,
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
.cpu_die = ux500_cpu_die,
|
|
|
|
#endif
|
|
|
|
};
|
2015-08-03 15:26:52 +08:00
|
|
|
CPU_METHOD_OF_DECLARE(ux500_smp, "ste,dbx500-smp", &ux500_smp_ops);
|