aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDinh Nguyen <dinguyen@altera.com>2012-10-25 12:41:39 -0400
committerArnd Bergmann <arnd@arndb.de>2012-10-26 08:59:39 -0400
commit9c4566a117a6fe404a0e49b27ac71b631945a70f (patch)
tree21802a1dc88b6dbd4ea39f7cc11b734c4f5465c9 /arch
parent6f0c0580b70c89094b3422ba81118c7b959c7556 (diff)
ARM: socfpga: Enable SMP for socfpga
Enable SMP for the SOCFPGA platform. Signed-off-by: Pavel Machek <pavel@denx.de> Signed-off-by: Dinh Nguyen <dinguyen@altera.com> Reviewed-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boot/dts/socfpga.dtsi10
-rw-r--r--arch/arm/configs/socfpga_defconfig3
-rw-r--r--arch/arm/mach-socfpga/Kconfig1
-rw-r--r--arch/arm/mach-socfpga/Makefile1
-rw-r--r--arch/arm/mach-socfpga/core.h34
-rw-r--r--arch/arm/mach-socfpga/headsmp.S24
-rw-r--r--arch/arm/mach-socfpga/platsmp.c116
-rw-r--r--arch/arm/mach-socfpga/socfpga.c45
8 files changed, 232 insertions, 2 deletions
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 0772f5739f59..19aec421bb26 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -143,5 +143,15 @@
143 reg-shift = <2>; 143 reg-shift = <2>;
144 reg-io-width = <4>; 144 reg-io-width = <4>;
145 }; 145 };
146
147 rstmgr@ffd05000 {
148 compatible = "altr,rst-mgr";
149 reg = <0xffd05000 0x1000>;
150 };
151
152 sysmgr@ffd08000 {
153 compatible = "altr,sys-mgr";
154 reg = <0xffd08000 0x4000>;
155 };
146 }; 156 };
147}; 157};
diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
index 0ac1293dba10..4e1ce211d43f 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -18,9 +18,10 @@ CONFIG_MODULE_UNLOAD=y
18CONFIG_ARCH_SOCFPGA=y 18CONFIG_ARCH_SOCFPGA=y
19CONFIG_MACH_SOCFPGA_CYCLONE5=y 19CONFIG_MACH_SOCFPGA_CYCLONE5=y
20CONFIG_ARM_THUMBEE=y 20CONFIG_ARM_THUMBEE=y
21# CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set
21# CONFIG_CACHE_L2X0 is not set 22# CONFIG_CACHE_L2X0 is not set
22CONFIG_HIGH_RES_TIMERS=y 23CONFIG_HIGH_RES_TIMERS=y
23CONFIG_VMSPLIT_2G=y 24CONFIG_SMP=y
24CONFIG_NR_CPUS=2 25CONFIG_NR_CPUS=2
25CONFIG_AEABI=y 26CONFIG_AEABI=y
26CONFIG_ZBOOT_ROM_TEXT=0x0 27CONFIG_ZBOOT_ROM_TEXT=0x0
diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index 803a3281feb5..566e804d4036 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -12,5 +12,6 @@ config ARCH_SOCFPGA
12 select GENERIC_CLOCKEVENTS 12 select GENERIC_CLOCKEVENTS
13 select GPIO_PL061 if GPIOLIB 13 select GPIO_PL061 if GPIOLIB
14 select HAVE_ARM_SCU 14 select HAVE_ARM_SCU
15 select HAVE_SMP
15 select SPARSE_IRQ 16 select SPARSE_IRQ
16 select USE_OF 17 select USE_OF
diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile
index 4fb93240971d..6dd7a93a90fe 100644
--- a/arch/arm/mach-socfpga/Makefile
+++ b/arch/arm/mach-socfpga/Makefile
@@ -3,3 +3,4 @@
3# 3#
4 4
5obj-y := socfpga.o 5obj-y := socfpga.o
6obj-$(CONFIG_SMP) += headsmp.o platsmp.o
diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h
new file mode 100644
index 000000000000..9941caa94931
--- /dev/null
+++ b/arch/arm/mach-socfpga/core.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright 2012 Pavel Machek <pavel@denx.de>
3 * Copyright (C) 2012 Altera Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef __MACH_CORE_H
21#define __MACH_CORE_H
22
23extern void secondary_startup(void);
24extern void __iomem *socfpga_scu_base_addr;
25
26extern void socfpga_init_clocks(void);
27extern void socfpga_sysmgr_init(void);
28
29extern struct smp_operations socfpga_smp_ops;
30extern char secondary_trampoline, secondary_trampoline_end;
31
32#define SOCFPGA_SCU_VIRT_BASE 0xfffec000
33
34#endif
diff --git a/arch/arm/mach-socfpga/headsmp.S b/arch/arm/mach-socfpga/headsmp.S
new file mode 100644
index 000000000000..17d6eaf9afff
--- /dev/null
+++ b/arch/arm/mach-socfpga/headsmp.S
@@ -0,0 +1,24 @@
1/*
2 * Copyright (c) 2003 ARM Limited
3 * Copyright (c) u-boot contributors
4 * Copyright (c) 2012 Pavel Machek <pavel@denx.de>
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 version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <linux/init.h>
12
13 __INIT
14
15#define CPU1_START_ADDR 0xffd08010
16
17ENTRY(secondary_trampoline)
18 movw r0, #:lower16:CPU1_START_ADDR
19 movt r0, #:upper16:CPU1_START_ADDR
20
21 ldr r1, [r0]
22 bx r1
23
24ENTRY(secondary_trampoline_end)
diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c
new file mode 100644
index 000000000000..68dd1b69512a
--- /dev/null
+++ b/arch/arm/mach-socfpga/platsmp.c
@@ -0,0 +1,116 @@
1/*
2 * Copyright 2010-2011 Calxeda, Inc.
3 * Copyright 2012 Pavel Machek <pavel@denx.de>
4 * Based on platsmp.c, Copyright (C) 2002 ARM Ltd.
5 * Copyright (C) 2012 Altera Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#include <linux/delay.h>
20#include <linux/init.h>
21#include <linux/smp.h>
22#include <linux/io.h>
23#include <linux/of.h>
24#include <linux/of_address.h>
25
26#include <asm/cacheflush.h>
27#include <asm/hardware/gic.h>
28#include <asm/smp_scu.h>
29#include <asm/smp_plat.h>
30
31#include "core.h"
32
33extern void __iomem *sys_manager_base_addr;
34extern void __iomem *rst_manager_base_addr;
35
36static void __cpuinit socfpga_secondary_init(unsigned int cpu)
37{
38 /*
39 * if any interrupts are already enabled for the primary
40 * core (e.g. timer irq), then they will not have been enabled
41 * for us: do so
42 */
43 gic_secondary_init(0);
44}
45
46static int __cpuinit socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
47{
48 int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
49
50 memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
51
52 __raw_writel(virt_to_phys(secondary_startup), (sys_manager_base_addr+0x10));
53
54 flush_cache_all();
55 smp_wmb();
56 outer_clean_range(0, trampoline_size);
57
58 /* This will release CPU #1 out of reset.*/
59 __raw_writel(0, rst_manager_base_addr + 0x10);
60
61 return 0;
62}
63
64/*
65 * Initialise the CPU possible map early - this describes the CPUs
66 * which may be present or become present in the system.
67 */
68static void __init socfpga_smp_init_cpus(void)
69{
70 unsigned int i, ncores;
71
72 ncores = scu_get_core_count(socfpga_scu_base_addr);
73
74 for (i = 0; i < ncores; i++)
75 set_cpu_possible(i, true);
76
77 /* sanity check */
78 if (ncores > num_possible_cpus()) {
79 pr_warn("socfpga: no. of cores (%d) greater than configured"
80 "maximum of %d - clipping\n", ncores, num_possible_cpus());
81 ncores = num_possible_cpus();
82 }
83
84 for (i = 0; i < ncores; i++)
85 set_cpu_possible(i, true);
86
87 set_smp_cross_call(gic_raise_softirq);
88}
89
90static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
91{
92 scu_enable(socfpga_scu_base_addr);
93}
94
95/*
96 * platform-specific code to shutdown a CPU
97 *
98 * Called with IRQs disabled
99 */
100static void socfpga_cpu_die(unsigned int cpu)
101{
102 cpu_do_idle();
103
104 /* We should have never returned from idle */
105 panic("cpu %d unexpectedly exit from shutdown\n", cpu);
106}
107
108struct smp_operations socfpga_smp_ops __initdata = {
109 .smp_init_cpus = socfpga_smp_init_cpus,
110 .smp_prepare_cpus = socfpga_smp_prepare_cpus,
111 .smp_secondary_init = socfpga_secondary_init,
112 .smp_boot_secondary = socfpga_boot_secondary,
113#ifdef CONFIG_HOTPLUG_CPU
114 .cpu_die = socfpga_cpu_die,
115#endif
116};
diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index f01e1ebf5396..ab81ea91a7c4 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -15,23 +15,64 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17#include <linux/dw_apb_timer.h> 17#include <linux/dw_apb_timer.h>
18#include <linux/of_address.h>
18#include <linux/of_irq.h> 19#include <linux/of_irq.h>
19#include <linux/of_platform.h> 20#include <linux/of_platform.h>
20 21
21#include <asm/hardware/cache-l2x0.h> 22#include <asm/hardware/cache-l2x0.h>
22#include <asm/hardware/gic.h> 23#include <asm/hardware/gic.h>
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
24 26
25extern void socfpga_init_clocks(void); 27#include "core.h"
28
29void __iomem *socfpga_scu_base_addr = ((void __iomem *)(SOCFPGA_SCU_VIRT_BASE));
30void __iomem *sys_manager_base_addr;
31void __iomem *rst_manager_base_addr;
32
33static struct map_desc scu_io_desc __initdata = {
34 .virtual = SOCFPGA_SCU_VIRT_BASE,
35 .pfn = 0, /* run-time */
36 .length = SZ_8K,
37 .type = MT_DEVICE,
38};
39
40static void __init socfpga_scu_map_io(void)
41{
42 unsigned long base;
43
44 /* Get SCU base */
45 asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
46
47 scu_io_desc.pfn = __phys_to_pfn(base);
48 iotable_init(&scu_io_desc, 1);
49}
50
51static void __init socfpga_map_io(void)
52{
53 socfpga_scu_map_io();
54}
26 55
27const static struct of_device_id irq_match[] = { 56const static struct of_device_id irq_match[] = {
28 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, }, 57 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
29 {} 58 {}
30}; 59};
31 60
61void __init socfpga_sysmgr_init(void)
62{
63 struct device_node *np;
64
65 np = of_find_compatible_node(NULL, NULL, "altr,sys-mgr");
66 sys_manager_base_addr = of_iomap(np, 0);
67
68 np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr");
69 rst_manager_base_addr = of_iomap(np, 0);
70}
71
32static void __init gic_init_irq(void) 72static void __init gic_init_irq(void)
33{ 73{
34 of_irq_init(irq_match); 74 of_irq_init(irq_match);
75 socfpga_sysmgr_init();
35} 76}
36 77
37static void socfpga_cyclone5_restart(char mode, const char *cmd) 78static void socfpga_cyclone5_restart(char mode, const char *cmd)
@@ -53,6 +94,8 @@ static const char *altera_dt_match[] = {
53}; 94};
54 95
55DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA") 96DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
97 .smp = smp_ops(socfpga_smp_ops),
98 .map_io = socfpga_map_io,
56 .init_irq = gic_init_irq, 99 .init_irq = gic_init_irq,
57 .handle_irq = gic_handle_irq, 100 .handle_irq = gic_handle_irq,
58 .timer = &dw_apb_timer, 101 .timer = &dw_apb_timer,