aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-12-14 16:16:07 -0500
committerOlof Johansson <olof@lixom.net>2012-12-14 16:17:01 -0500
commitc91321e8ff338a88a9272dcd938f085955cd5846 (patch)
tree3285fcdc17b2275555ad28747364eae6c4aa2e11 /arch/arm
parent1f1ba836455b94494aaee9381ed9197ade2f770f (diff)
parent9560f840f301868b4b4b175e81afa96dc57611ac (diff)
ARM: arm-soc: Merge branch 'next/smp' into next/soc2
Merging in the smp-on-socfpga branch into soc2 since the topics are similar and it's a short branch in the first place. * next/smp: ARM: socfpga: mark secondary_trampoline as cpuinit socfpga: map uart into virtual address space so that early_printk() works ARM: socfpga: fix build break for allyesconfig ARM: socfpga: Enable SMP for socfpga Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'arch/arm')
-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.S25
-rw-r--r--arch/arm/mach-socfpga/platsmp.c116
-rw-r--r--arch/arm/mach-socfpga/socfpga.c54
8 files changed, 242 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..f09b1283ffca
--- /dev/null
+++ b/arch/arm/mach-socfpga/headsmp.S
@@ -0,0 +1,25 @@
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 __CPUINIT
14 .arch armv7-a
15
16#define CPU1_START_ADDR 0xffd08010
17
18ENTRY(secondary_trampoline)
19 movw r0, #:lower16:CPU1_START_ADDR
20 movt r0, #:upper16:CPU1_START_ADDR
21
22 ldr r1, [r0]
23 bx r1
24
25ENTRY(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..6732924a5fee 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -15,23 +15,73 @@
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 struct map_desc uart_io_desc __initdata = {
41 .virtual = 0xfec02000,
42 .pfn = __phys_to_pfn(0xffc02000),
43 .length = SZ_8K,
44 .type = MT_DEVICE,
45};
46
47static void __init socfpga_scu_map_io(void)
48{
49 unsigned long base;
50
51 /* Get SCU base */
52 asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
53
54 scu_io_desc.pfn = __phys_to_pfn(base);
55 iotable_init(&scu_io_desc, 1);
56}
57
58static void __init socfpga_map_io(void)
59{
60 socfpga_scu_map_io();
61 iotable_init(&uart_io_desc, 1);
62 early_printk("Early printk initialized\n");
63}
26 64
27const static struct of_device_id irq_match[] = { 65const static struct of_device_id irq_match[] = {
28 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, }, 66 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
29 {} 67 {}
30}; 68};
31 69
70void __init socfpga_sysmgr_init(void)
71{
72 struct device_node *np;
73
74 np = of_find_compatible_node(NULL, NULL, "altr,sys-mgr");
75 sys_manager_base_addr = of_iomap(np, 0);
76
77 np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr");
78 rst_manager_base_addr = of_iomap(np, 0);
79}
80
32static void __init gic_init_irq(void) 81static void __init gic_init_irq(void)
33{ 82{
34 of_irq_init(irq_match); 83 of_irq_init(irq_match);
84 socfpga_sysmgr_init();
35} 85}
36 86
37static void socfpga_cyclone5_restart(char mode, const char *cmd) 87static void socfpga_cyclone5_restart(char mode, const char *cmd)
@@ -53,6 +103,8 @@ static const char *altera_dt_match[] = {
53}; 103};
54 104
55DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA") 105DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
106 .smp = smp_ops(socfpga_smp_ops),
107 .map_io = socfpga_map_io,
56 .init_irq = gic_init_irq, 108 .init_irq = gic_init_irq,
57 .handle_irq = gic_handle_irq, 109 .handle_irq = gic_handle_irq,
58 .timer = &dw_apb_timer, 110 .timer = &dw_apb_timer,