aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTsahee Zidenberg <tsahee@annapurnalabs.com>2015-03-12 07:53:06 -0400
committerArnd Bergmann <arnd@arndb.de>2015-03-16 10:24:12 -0400
commite9e06f2853dd86791e665b2aa3c8acb5b0007e07 (patch)
tree8ee22e89f2e01f9442cfecd9b2608851526f2b98
parent3c215e64eb00f1ea5c67de2141ba816cb3f3c682 (diff)
ARM: Alpine: smp support
This patch introduces support for waking up secondary CPU cores on Alpine platform. Signed-off-by: Barak Wasserstrom <barak@annapurnalabs.com> Signed-off-by: Tsahee Zidenberg <tsahee@annapurnalabs.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--arch/arm/mach-alpine/Kconfig2
-rw-r--r--arch/arm/mach-alpine/Makefile1
-rw-r--r--arch/arm/mach-alpine/alpine_cpu_pm.c70
-rw-r--r--arch/arm/mach-alpine/alpine_cpu_pm.h26
-rw-r--r--arch/arm/mach-alpine/alpine_cpu_resume.h38
-rw-r--r--arch/arm/mach-alpine/platsmp.c49
6 files changed, 186 insertions, 0 deletions
diff --git a/arch/arm/mach-alpine/Kconfig b/arch/arm/mach-alpine/Kconfig
index 44b9a8f4e5bb..79b26491a96c 100644
--- a/arch/arm/mach-alpine/Kconfig
+++ b/arch/arm/mach-alpine/Kconfig
@@ -4,5 +4,7 @@ config ARCH_ALPINE
4 select ARM_GIC 4 select ARM_GIC
5 select GENERIC_IRQ_CHIP 5 select GENERIC_IRQ_CHIP
6 select HAVE_ARM_ARCH_TIMER 6 select HAVE_ARM_ARCH_TIMER
7 select HAVE_SMP
8 select MFD_SYSCON
7 help 9 help
8 This enables support for the Annapurna Labs Alpine V1 boards. 10 This enables support for the Annapurna Labs Alpine V1 boards.
diff --git a/arch/arm/mach-alpine/Makefile b/arch/arm/mach-alpine/Makefile
index b7dbb12d89cd..b6674890be71 100644
--- a/arch/arm/mach-alpine/Makefile
+++ b/arch/arm/mach-alpine/Makefile
@@ -1 +1,2 @@
1obj-y += alpine_machine.o 1obj-y += alpine_machine.o
2obj-$(CONFIG_SMP) += platsmp.o alpine_cpu_pm.o
diff --git a/arch/arm/mach-alpine/alpine_cpu_pm.c b/arch/arm/mach-alpine/alpine_cpu_pm.c
new file mode 100644
index 000000000000..121c77c4b53c
--- /dev/null
+++ b/arch/arm/mach-alpine/alpine_cpu_pm.c
@@ -0,0 +1,70 @@
1/*
2 * Low-level power-management support for Alpine platform.
3 *
4 * Copyright (C) 2015 Annapurna Labs Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/io.h>
18#include <linux/of.h>
19#include <linux/of_address.h>
20#include <linux/regmap.h>
21#include <linux/mfd/syscon.h>
22
23#include "alpine_cpu_pm.h"
24#include "alpine_cpu_resume.h"
25
26/* NB registers */
27#define AL_SYSFAB_POWER_CONTROL(cpu) (0x2000 + (cpu)*0x100 + 0x20)
28
29static struct regmap *al_sysfabric;
30static struct al_cpu_resume_regs __iomem *al_cpu_resume_regs;
31static int wakeup_supported;
32
33int alpine_cpu_wakeup(unsigned int phys_cpu, uint32_t phys_resume_addr)
34{
35 if (!wakeup_supported)
36 return -ENOSYS;
37
38 /*
39 * Set CPU resume address -
40 * secure firmware running on boot will jump to this address
41 * after setting proper CPU mode, and initialiing e.g. secure
42 * regs (the same mode all CPUs are booted to - usually HYP)
43 */
44 writel(phys_resume_addr,
45 &al_cpu_resume_regs->per_cpu[phys_cpu].resume_addr);
46
47 /* Power-up the CPU */
48 regmap_write(al_sysfabric, AL_SYSFAB_POWER_CONTROL(phys_cpu), 0);
49
50 return 0;
51}
52
53void __init alpine_cpu_pm_init(void)
54{
55 struct device_node *np;
56 uint32_t watermark;
57
58 al_sysfabric = syscon_regmap_lookup_by_compatible("al,alpine-sysfabric-service");
59
60 np = of_find_compatible_node(NULL, NULL, "al,alpine-cpu-resume");
61 al_cpu_resume_regs = of_iomap(np, 0);
62
63 wakeup_supported = !IS_ERR(al_sysfabric) && al_cpu_resume_regs;
64
65 if (wakeup_supported) {
66 watermark = readl(&al_cpu_resume_regs->watermark);
67 wakeup_supported = (watermark & AL_CPU_RESUME_MAGIC_NUM_MASK)
68 == AL_CPU_RESUME_MAGIC_NUM;
69 }
70}
diff --git a/arch/arm/mach-alpine/alpine_cpu_pm.h b/arch/arm/mach-alpine/alpine_cpu_pm.h
new file mode 100644
index 000000000000..5179e697c492
--- /dev/null
+++ b/arch/arm/mach-alpine/alpine_cpu_pm.h
@@ -0,0 +1,26 @@
1/*
2 * Low-level power-management support for Alpine platform.
3 *
4 * Copyright (C) 2015 Annapurna Labs Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef __ALPINE_CPU_PM_H__
18#define __ALPINE_CPU_PM_H__
19
20/* Alpine CPU Power Management Services Initialization */
21void alpine_cpu_pm_init(void);
22
23/* Wake-up a CPU */
24int alpine_cpu_wakeup(unsigned int phys_cpu, uint32_t phys_resume_addr);
25
26#endif /* __ALPINE_CPU_PM_H__ */
diff --git a/arch/arm/mach-alpine/alpine_cpu_resume.h b/arch/arm/mach-alpine/alpine_cpu_resume.h
new file mode 100644
index 000000000000..c80150c0d2d8
--- /dev/null
+++ b/arch/arm/mach-alpine/alpine_cpu_resume.h
@@ -0,0 +1,38 @@
1/*
2 * Annapurna labs cpu-resume register structure.
3 *
4 * Copyright (C) 2015 Annapurna Labs Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef ALPINE_CPU_RESUME_H_
18#define ALPINE_CPU_RESUME_H_
19
20/* Per-cpu regs */
21struct al_cpu_resume_regs_per_cpu {
22 uint32_t flags;
23 uint32_t resume_addr;
24};
25
26/* general regs */
27struct al_cpu_resume_regs {
28 /* Watermark for validating the CPU resume struct */
29 uint32_t watermark;
30 uint32_t flags;
31 struct al_cpu_resume_regs_per_cpu per_cpu[];
32};
33
34/* The expected magic number for validating the resume addresses */
35#define AL_CPU_RESUME_MAGIC_NUM 0xf0e1d200
36#define AL_CPU_RESUME_MAGIC_NUM_MASK 0xffffff00
37
38#endif /* ALPINE_CPU_RESUME_H_ */
diff --git a/arch/arm/mach-alpine/platsmp.c b/arch/arm/mach-alpine/platsmp.c
new file mode 100644
index 000000000000..f78429f48bd6
--- /dev/null
+++ b/arch/arm/mach-alpine/platsmp.c
@@ -0,0 +1,49 @@
1/*
2 * SMP operations for Alpine platform.
3 *
4 * Copyright (C) 2015 Annapurna Labs Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/init.h>
18#include <linux/errno.h>
19#include <linux/io.h>
20#include <linux/of.h>
21
22#include <asm/smp_plat.h>
23
24#include "alpine_cpu_pm.h"
25
26static int alpine_boot_secondary(unsigned int cpu, struct task_struct *idle)
27{
28 phys_addr_t addr;
29
30 addr = virt_to_phys(secondary_startup);
31
32 if (addr > (phys_addr_t)(uint32_t)(-1)) {
33 pr_err("FAIL: resume address over 32bit (%pa)", &addr);
34 return -EINVAL;
35 }
36
37 return alpine_cpu_wakeup(cpu_logical_map(cpu), (uint32_t)addr);
38}
39
40static void __init alpine_smp_prepare_cpus(unsigned int max_cpus)
41{
42 alpine_cpu_pm_init();
43}
44
45static struct smp_operations alpine_smp_ops __initdata = {
46 .smp_prepare_cpus = alpine_smp_prepare_cpus,
47 .smp_boot_secondary = alpine_boot_secondary,
48};
49CPU_METHOD_OF_DECLARE(alpine_smp, "al,alpine-smp", &alpine_smp_ops);