blob: 88b8ab4f300ceb7fabf8a1e66c29b4964385d8b2 [file] [log] [blame]
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01001/*
2 * Copyright (C) 2002 ARM Ltd.
3 * Copyright (C) 2008 STMicroelctronics.
4 * Copyright (C) 2009 ST-Ericsson.
5 * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
6 *
7 * This file is based on arm realview platform
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#include <linux/init.h>
14#include <linux/errno.h>
15#include <linux/delay.h>
16#include <linux/device.h>
17#include <linux/smp.h>
18#include <linux/io.h>
Linus Walleij58202032015-05-14 09:46:40 +020019#include <linux/of.h>
20#include <linux/of_address.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010021
22#include <asm/cacheflush.h>
Will Deaconeb504392012-01-20 12:01:12 +010023#include <asm/smp_plat.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010024#include <asm/smp_scu.h>
Linus Walleij7a4f2602012-09-19 19:31:19 +020025
Arnd Bergmanne657bcf2013-03-21 22:51:12 +010026#include "setup.h"
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010027
Linus Walleij174e7792013-03-19 15:41:55 +010028#include "db8500-regs.h"
Linus Walleij7a4f2602012-09-19 19:31:19 +020029#include "id.h"
30
Linus Walleijc00def72015-08-03 09:26:52 +020031/* Magic triggers in backup RAM */
32#define UX500_CPU1_JUMPADDR_OFFSET 0x1FF4
33#define UX500_CPU1_WAKEMAGIC_OFFSET 0x1FF0
Linus Walleij2d6dd172015-05-14 09:20:23 +020034
Linus Walleijc00def72015-08-03 09:26:52 +020035static void wakeup_secondary(void)
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010036{
Linus Walleijc00def72015-08-03 09:26:52 +020037 struct device_node *np;
38 static void __iomem *backupram;
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010039
Linus Walleijc00def72015-08-03 09:26:52 +020040 np = of_find_compatible_node(NULL, NULL, "ste,dbx500-backupram");
41 if (!np) {
42 pr_err("No backupram base address\n");
43 return;
44 }
45 backupram = of_iomap(np, 0);
46 of_node_put(np);
47 if (!backupram) {
48 pr_err("No backupram remap\n");
49 return;
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010050 }
51
52 /*
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010053 * write the address of secondary startup into the backup ram register
54 * at offset 0x1FF4, then write the magic number 0xA1FEED01 to the
55 * backup ram register at offset 0x1FF0, which is what boot rom code
Linus Walleijc00def72015-08-03 09:26:52 +020056 * is waiting for. This will wake up the secondary core from WFE.
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010057 */
Linus Walleijc00def72015-08-03 09:26:52 +020058 writel(virt_to_phys(secondary_startup),
59 backupram + UX500_CPU1_JUMPADDR_OFFSET);
60 writel(0xA1FEED01,
61 backupram + UX500_CPU1_WAKEMAGIC_OFFSET);
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010062
63 /* make sure write buffer is drained */
64 mb();
Linus Walleijc00def72015-08-03 09:26:52 +020065 iounmap(backupram);
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010066}
67
Marc Zyngier5ac21a92011-09-08 13:15:22 +010068static void __init ux500_smp_prepare_cpus(unsigned int max_cpus)
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010069{
Linus Walleijc00def72015-08-03 09:26:52 +020070 struct device_node *np;
71 static void __iomem *scu_base;
72 unsigned int ncores;
73 int i;
74
75 np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
76 if (!np) {
77 pr_err("No SCU base address\n");
78 return;
79 }
80 scu_base = of_iomap(np, 0);
81 of_node_put(np);
82 if (!scu_base) {
83 pr_err("No SCU remap\n");
84 return;
85 }
86
Linus Walleij2d6dd172015-05-14 09:20:23 +020087 scu_enable(scu_base);
Linus Walleijc00def72015-08-03 09:26:52 +020088 ncores = scu_get_core_count(scu_base);
89 for (i = 0; i < ncores; i++)
90 set_cpu_possible(i, true);
91 iounmap(scu_base);
92}
93
94static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
95{
Russell King05c74a62010-12-03 11:09:48 +000096 wakeup_secondary();
Linus Walleijc00def72015-08-03 09:26:52 +020097 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
98 return 0;
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010099}
Marc Zyngier5ac21a92011-09-08 13:15:22 +0100100
Masahiro Yamada75305272015-11-15 10:39:53 +0900101static const struct smp_operations ux500_smp_ops __initconst = {
Marc Zyngier5ac21a92011-09-08 13:15:22 +0100102 .smp_prepare_cpus = ux500_smp_prepare_cpus,
Marc Zyngier5ac21a92011-09-08 13:15:22 +0100103 .smp_boot_secondary = ux500_boot_secondary,
104#ifdef CONFIG_HOTPLUG_CPU
105 .cpu_die = ux500_cpu_die,
106#endif
107};
Linus Walleijc00def72015-08-03 09:26:52 +0200108CPU_METHOD_OF_DECLARE(ux500_smp, "ste,dbx500-smp", &ux500_smp_ops);