aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2012-05-16 02:45:25 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-05-17 18:14:02 -0400
commitbd5a875d90c878be4d23f54ea565253734ae2377 (patch)
tree98cc3435486ab8b55374d24051b262c21600b95b
parentc050fb10c425cf189da5ca9b84e948ec2fc99049 (diff)
mach-shmobile: Emma Mobile EV2 SMP support V3
This is V3 of Emma Mobile EV2 SMP support. At this point only the most basic form of SMP operation is supported. TWD and CPU Hotplug support is excluded. Tied to both the Emma Mobile EV2 and the KZM9D board due to the need to switch on board in platsmp.c and the newly introduced need for static mappings. The static mappings are needed to allow hardware acces early during boot when SMP is initialized. This early requirement forces us to also map in the SMU registers. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-rw-r--r--arch/arm/mach-shmobile/Makefile1
-rw-r--r--arch/arm/mach-shmobile/board-kzm9d.c1
-rw-r--r--arch/arm/mach-shmobile/clock-emev2.c18
-rw-r--r--arch/arm/mach-shmobile/include/mach/emev2.h7
-rw-r--r--arch/arm/mach-shmobile/platsmp.c17
-rw-r--r--arch/arm/mach-shmobile/setup-emev2.c24
-rw-r--r--arch/arm/mach-shmobile/smp-emev2.c97
7 files changed, 165 insertions, 0 deletions
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 87bc110a9bed..c795335931c9 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -19,6 +19,7 @@ smp-y := platsmp.o headsmp.o
19smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o 19smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o
20smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o 20smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o
21smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o 21smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o
22smp-$(CONFIG_ARCH_EMEV2) += smp-emev2.o
22 23
23# Pinmux setup 24# Pinmux setup
24pfc-y := 25pfc-y :=
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
index e743f9020435..42fc4794c9ed 100644
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ b/arch/arm/mach-shmobile/board-kzm9d.c
@@ -27,6 +27,7 @@
27#include <asm/hardware/gic.h> 27#include <asm/hardware/gic.h>
28 28
29MACHINE_START(KZM9D, "kzm9d") 29MACHINE_START(KZM9D, "kzm9d")
30 .map_io = emev2_map_io,
30 .init_early = emev2_add_early_devices, 31 .init_early = emev2_add_early_devices,
31 .nr_irqs = NR_IRQS_LEGACY, 32 .nr_irqs = NR_IRQS_LEGACY,
32 .init_irq = emev2_init_irq, 33 .init_irq = emev2_init_irq,
diff --git a/arch/arm/mach-shmobile/clock-emev2.c b/arch/arm/mach-shmobile/clock-emev2.c
index 73a121659314..5bc97de4a1ed 100644
--- a/arch/arm/mach-shmobile/clock-emev2.c
+++ b/arch/arm/mach-shmobile/clock-emev2.c
@@ -40,6 +40,7 @@
40#define USIB2SCLKDIV 0x65c 40#define USIB2SCLKDIV 0x65c
41#define USIB3SCLKDIV 0x660 41#define USIB3SCLKDIV 0x660
42#define STI_CLKSEL 0x688 42#define STI_CLKSEL 0x688
43#define SMU_GENERAL_REG0 0x7c0
43 44
44/* not pretty, but hey */ 45/* not pretty, but hey */
45static void __iomem *smu_base; 46static void __iomem *smu_base;
@@ -50,6 +51,11 @@ static void emev2_smu_write(unsigned long value, int offs)
50 iowrite32(value, smu_base + offs); 51 iowrite32(value, smu_base + offs);
51} 52}
52 53
54void emev2_set_boot_vector(unsigned long value)
55{
56 emev2_smu_write(value, SMU_GENERAL_REG0);
57}
58
53static struct clk_mapping smu_mapping = { 59static struct clk_mapping smu_mapping = {
54 .phys = EMEV2_SMU_BASE, 60 .phys = EMEV2_SMU_BASE,
55 .len = PAGE_SIZE, 61 .len = PAGE_SIZE,
@@ -194,6 +200,18 @@ static struct clk_lookup lookups[] = {
194void __init emev2_clock_init(void) 200void __init emev2_clock_init(void)
195{ 201{
196 int k, ret = 0; 202 int k, ret = 0;
203 static int is_setup;
204
205 /* yuck, this is ugly as hell, but the non-smp case of clocks
206 * code is now designed to rely on ioremap() instead of static
207 * entity maps. in the case of smp we need access to the SMU
208 * register earlier than ioremap() is actually working without
209 * any static maps. to enable SMP in ugly but with dynamic
210 * mappings we have to call emev2_clock_init() from different
211 * places depending on UP and SMP...
212 */
213 if (is_setup++)
214 return;
197 215
198 smu_base = ioremap(EMEV2_SMU_BASE, PAGE_SIZE); 216 smu_base = ioremap(EMEV2_SMU_BASE, PAGE_SIZE);
199 BUG_ON(!smu_base); 217 BUG_ON(!smu_base);
diff --git a/arch/arm/mach-shmobile/include/mach/emev2.h b/arch/arm/mach-shmobile/include/mach/emev2.h
index 92646c1de616..3fc718419854 100644
--- a/arch/arm/mach-shmobile/include/mach/emev2.h
+++ b/arch/arm/mach-shmobile/include/mach/emev2.h
@@ -1,9 +1,16 @@
1#ifndef __ASM_EMEV2_H__ 1#ifndef __ASM_EMEV2_H__
2#define __ASM_EMEV2_H__ 2#define __ASM_EMEV2_H__
3 3
4extern void emev2_map_io(void);
4extern void emev2_init_irq(void); 5extern void emev2_init_irq(void);
5extern void emev2_add_early_devices(void); 6extern void emev2_add_early_devices(void);
6extern void emev2_add_standard_devices(void); 7extern void emev2_add_standard_devices(void);
7extern void emev2_clock_init(void); 8extern void emev2_clock_init(void);
9extern void emev2_set_boot_vector(unsigned long value);
10extern unsigned int emev2_get_core_count(void);
11extern int emev2_platform_cpu_kill(unsigned int cpu);
12extern void emev2_secondary_init(unsigned int cpu);
13extern int emev2_boot_secondary(unsigned int cpu);
14extern void emev2_smp_prepare_cpus(void);
8 15
9#endif /* __ASM_EMEV2_H__ */ 16#endif /* __ASM_EMEV2_H__ */
diff --git a/arch/arm/mach-shmobile/platsmp.c b/arch/arm/mach-shmobile/platsmp.c
index 45fa3924c6a1..959b021e52be 100644
--- a/arch/arm/mach-shmobile/platsmp.c
+++ b/arch/arm/mach-shmobile/platsmp.c
@@ -19,9 +19,11 @@
19#include <asm/hardware/gic.h> 19#include <asm/hardware/gic.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <mach/common.h> 21#include <mach/common.h>
22#include <mach/emev2.h>
22 23
23#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2()) 24#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2())
24#define is_r8a7779() machine_is_marzen() 25#define is_r8a7779() machine_is_marzen()
26#define is_emev2() machine_is_kzm9d()
25 27
26static unsigned int __init shmobile_smp_get_core_count(void) 28static unsigned int __init shmobile_smp_get_core_count(void)
27{ 29{
@@ -31,6 +33,9 @@ static unsigned int __init shmobile_smp_get_core_count(void)
31 if (is_r8a7779()) 33 if (is_r8a7779())
32 return r8a7779_get_core_count(); 34 return r8a7779_get_core_count();
33 35
36 if (is_emev2())
37 return emev2_get_core_count();
38
34 return 1; 39 return 1;
35} 40}
36 41
@@ -41,6 +46,9 @@ static void __init shmobile_smp_prepare_cpus(void)
41 46
42 if (is_r8a7779()) 47 if (is_r8a7779())
43 r8a7779_smp_prepare_cpus(); 48 r8a7779_smp_prepare_cpus();
49
50 if (is_emev2())
51 emev2_smp_prepare_cpus();
44} 52}
45 53
46int shmobile_platform_cpu_kill(unsigned int cpu) 54int shmobile_platform_cpu_kill(unsigned int cpu)
@@ -48,6 +56,9 @@ int shmobile_platform_cpu_kill(unsigned int cpu)
48 if (is_r8a7779()) 56 if (is_r8a7779())
49 return r8a7779_platform_cpu_kill(cpu); 57 return r8a7779_platform_cpu_kill(cpu);
50 58
59 if (is_emev2())
60 return emev2_platform_cpu_kill(cpu);
61
51 return 1; 62 return 1;
52} 63}
53 64
@@ -60,6 +71,9 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
60 71
61 if (is_r8a7779()) 72 if (is_r8a7779())
62 r8a7779_secondary_init(cpu); 73 r8a7779_secondary_init(cpu);
74
75 if (is_emev2())
76 emev2_secondary_init(cpu);
63} 77}
64 78
65int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) 79int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
@@ -70,6 +84,9 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
70 if (is_r8a7779()) 84 if (is_r8a7779())
71 return r8a7779_boot_secondary(cpu); 85 return r8a7779_boot_secondary(cpu);
72 86
87 if (is_emev2())
88 return emev2_boot_secondary(cpu);
89
73 return -ENOSYS; 90 return -ENOSYS;
74} 91}
75 92
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index 9fff62336911..2a03a78abddd 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -34,6 +34,30 @@
34#include <asm/mach/time.h> 34#include <asm/mach/time.h>
35#include <asm/hardware/gic.h> 35#include <asm/hardware/gic.h>
36 36
37static struct map_desc emev2_io_desc[] __initdata = {
38#ifdef CONFIG_SMP
39 /* 128K entity map for 0xe0100000 (SMU) */
40 {
41 .virtual = 0xe0100000,
42 .pfn = __phys_to_pfn(0xe0100000),
43 .length = SZ_128K,
44 .type = MT_DEVICE
45 },
46 /* 2M mapping for SCU + L2 controller */
47 {
48 .virtual = 0xf0000000,
49 .pfn = __phys_to_pfn(0x1e000000),
50 .length = SZ_2M,
51 .type = MT_DEVICE
52 },
53#endif
54};
55
56void __init emev2_map_io(void)
57{
58 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
59}
60
37/* UART */ 61/* UART */
38static struct resource uart0_resources[] = { 62static struct resource uart0_resources[] = {
39 [0] = { 63 [0] = {
diff --git a/arch/arm/mach-shmobile/smp-emev2.c b/arch/arm/mach-shmobile/smp-emev2.c
new file mode 100644
index 000000000000..6a35c4a31e6c
--- /dev/null
+++ b/arch/arm/mach-shmobile/smp-emev2.c
@@ -0,0 +1,97 @@
1/*
2 * SMP support for Emma Mobile EV2
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Magnus Damm
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
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 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/smp.h>
23#include <linux/spinlock.h>
24#include <linux/io.h>
25#include <linux/delay.h>
26#include <mach/common.h>
27#include <mach/emev2.h>
28#include <asm/smp_plat.h>
29#include <asm/smp_scu.h>
30#include <asm/hardware/gic.h>
31#include <asm/cacheflush.h>
32
33#define EMEV2_SCU_BASE 0x1e000000
34
35static DEFINE_SPINLOCK(scu_lock);
36static void __iomem *scu_base;
37
38static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
39{
40 unsigned long tmp;
41
42 /* we assume this code is running on a different cpu
43 * than the one that is changing coherency setting */
44 spin_lock(&scu_lock);
45 tmp = readl(scu_base + 8);
46 tmp &= ~clr;
47 tmp |= set;
48 writel(tmp, scu_base + 8);
49 spin_unlock(&scu_lock);
50
51}
52
53unsigned int __init emev2_get_core_count(void)
54{
55 if (!scu_base) {
56 scu_base = ioremap(EMEV2_SCU_BASE, PAGE_SIZE);
57 emev2_clock_init(); /* need ioremapped SMU */
58 }
59
60 WARN_ON_ONCE(!scu_base);
61
62 return scu_base ? scu_get_core_count(scu_base) : 1;
63}
64
65int emev2_platform_cpu_kill(unsigned int cpu)
66{
67 return 0; /* not supported yet */
68}
69
70void __cpuinit emev2_secondary_init(unsigned int cpu)
71{
72 gic_secondary_init(0);
73}
74
75int __cpuinit emev2_boot_secondary(unsigned int cpu)
76{
77 cpu = cpu_logical_map(cpu);
78
79 /* enable cache coherency */
80 modify_scu_cpu_psr(0, 3 << (cpu * 8));
81
82 /* Tell ROM loader about our vector (in headsmp.S) */
83 emev2_set_boot_vector(__pa(shmobile_secondary_vector));
84
85 gic_raise_softirq(cpumask_of(cpu), 1);
86 return 0;
87}
88
89void __init emev2_smp_prepare_cpus(void)
90{
91 int cpu = cpu_logical_map(0);
92
93 scu_enable(scu_base);
94
95 /* enable cache coherency on CPU0 */
96 modify_scu_cpu_psr(0, 3 << (cpu * 8));
97}