Skip to content

Commit 9fb29c7

Browse files
sugayataichi-sniarndb
authored andcommitted
ARM: milbeaut: Add basic support for Milbeaut m10v SoC
This adds the basic M10V SoC support under arch/arm. Since all cores are activated in the custom bootloader before booting linux, it is necessary to wait for the secondary-cores using cpu-enable- method and special sram. Signed-off-by: Sugaya Taichi <sugaya.taichi@socionext.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent f2a3aa1 commit 9fb29c7

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

arch/arm/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ source "arch/arm/mach-mediatek/Kconfig"
750750

751751
source "arch/arm/mach-meson/Kconfig"
752752

753+
source "arch/arm/mach-milbeaut/Kconfig"
754+
753755
source "arch/arm/mach-mmp/Kconfig"
754756

755757
source "arch/arm/mach-moxart/Kconfig"

arch/arm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ machine-$(CONFIG_ARCH_MV78XX0) += mv78xx0
190190
machine-$(CONFIG_ARCH_MVEBU) += mvebu
191191
machine-$(CONFIG_ARCH_MXC) += imx
192192
machine-$(CONFIG_ARCH_MEDIATEK) += mediatek
193+
machine-$(CONFIG_ARCH_MILBEAUT) += milbeaut
193194
machine-$(CONFIG_ARCH_MXS) += mxs
194195
machine-$(CONFIG_ARCH_NETX) += netx
195196
machine-$(CONFIG_ARCH_NOMADIK) += nomadik

arch/arm/mach-milbeaut/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
menuconfig ARCH_MILBEAUT
3+
bool "Socionext Milbeaut SoCs"
4+
depends on ARCH_MULTI_V7
5+
select ARM_GIC
6+
help
7+
This enables support for Socionext Milbeaut SoCs
8+
9+
if ARCH_MILBEAUT
10+
11+
config ARCH_MILBEAUT_M10V
12+
bool "Milbeaut SC2000/M10V platform"
13+
select ARM_ARCH_TIMER
14+
select MILBEAUT_TIMER
15+
select PINCTRL
16+
select PINCTRL_MILBEAUT
17+
help
18+
Support for Socionext's MILBEAUT M10V based systems
19+
20+
endif

arch/arm/mach-milbeaut/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-$(CONFIG_SMP) += platsmp.o

arch/arm/mach-milbeaut/platsmp.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright: (C) 2018 Socionext Inc.
4+
* Copyright: (C) 2015 Linaro Ltd.
5+
*/
6+
7+
#include <linux/cpu_pm.h>
8+
#include <linux/irqchip/arm-gic.h>
9+
#include <linux/of_address.h>
10+
#include <linux/suspend.h>
11+
12+
#include <asm/cacheflush.h>
13+
#include <asm/cp15.h>
14+
#include <asm/idmap.h>
15+
#include <asm/smp_plat.h>
16+
#include <asm/suspend.h>
17+
18+
#define M10V_MAX_CPU 4
19+
#define KERNEL_UNBOOT_FLAG 0x12345678
20+
21+
static void __iomem *m10v_smp_base;
22+
23+
static int m10v_boot_secondary(unsigned int l_cpu, struct task_struct *idle)
24+
{
25+
unsigned int mpidr, cpu, cluster;
26+
27+
if (!m10v_smp_base)
28+
return -ENXIO;
29+
30+
mpidr = cpu_logical_map(l_cpu);
31+
cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
32+
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
33+
34+
if (cpu >= M10V_MAX_CPU)
35+
return -EINVAL;
36+
37+
pr_info("%s: cpu %u l_cpu %u cluster %u\n",
38+
__func__, cpu, l_cpu, cluster);
39+
40+
writel(__pa_symbol(secondary_startup), m10v_smp_base + cpu * 4);
41+
arch_send_wakeup_ipi_mask(cpumask_of(l_cpu));
42+
43+
return 0;
44+
}
45+
46+
static void m10v_smp_init(unsigned int max_cpus)
47+
{
48+
unsigned int mpidr, cpu, cluster;
49+
struct device_node *np;
50+
51+
np = of_find_compatible_node(NULL, NULL, "socionext,milbeaut-smp-sram");
52+
if (!np)
53+
return;
54+
55+
m10v_smp_base = of_iomap(np, 0);
56+
if (!m10v_smp_base)
57+
return;
58+
59+
mpidr = read_cpuid_mpidr();
60+
cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
61+
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
62+
pr_info("MCPM boot on cpu_%u cluster_%u\n", cpu, cluster);
63+
64+
for (cpu = 0; cpu < M10V_MAX_CPU; cpu++)
65+
writel(KERNEL_UNBOOT_FLAG, m10v_smp_base + cpu * 4);
66+
}
67+
68+
static void m10v_cpu_die(unsigned int l_cpu)
69+
{
70+
gic_cpu_if_down(0);
71+
v7_exit_coherency_flush(louis);
72+
wfi();
73+
}
74+
75+
static int m10v_cpu_kill(unsigned int l_cpu)
76+
{
77+
unsigned int mpidr, cpu;
78+
79+
mpidr = cpu_logical_map(l_cpu);
80+
cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
81+
82+
writel(KERNEL_UNBOOT_FLAG, m10v_smp_base + cpu * 4);
83+
84+
return 1;
85+
}
86+
87+
static struct smp_operations m10v_smp_ops __initdata = {
88+
.smp_prepare_cpus = m10v_smp_init,
89+
.smp_boot_secondary = m10v_boot_secondary,
90+
.cpu_die = m10v_cpu_die,
91+
.cpu_kill = m10v_cpu_kill,
92+
};
93+
CPU_METHOD_OF_DECLARE(m10v_smp, "socionext,milbeaut-m10v-smp", &m10v_smp_ops);
94+
95+
static int m10v_pm_valid(suspend_state_t state)
96+
{
97+
return (state == PM_SUSPEND_STANDBY) || (state == PM_SUSPEND_MEM);
98+
}
99+
100+
typedef void (*phys_reset_t)(unsigned long);
101+
static phys_reset_t phys_reset;
102+
103+
static int m10v_die(unsigned long arg)
104+
{
105+
setup_mm_for_reboot();
106+
asm("wfi");
107+
/* Boot just like a secondary */
108+
phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
109+
phys_reset(virt_to_phys(cpu_resume));
110+
111+
return 0;
112+
}
113+
114+
static int m10v_pm_enter(suspend_state_t state)
115+
{
116+
switch (state) {
117+
case PM_SUSPEND_STANDBY:
118+
asm("wfi");
119+
break;
120+
case PM_SUSPEND_MEM:
121+
cpu_pm_enter();
122+
cpu_suspend(0, m10v_die);
123+
cpu_pm_exit();
124+
break;
125+
}
126+
return 0;
127+
}
128+
129+
static const struct platform_suspend_ops m10v_pm_ops = {
130+
.valid = m10v_pm_valid,
131+
.enter = m10v_pm_enter,
132+
};
133+
134+
struct clk *m10v_clclk_register(struct device *cpu_dev);
135+
136+
static int __init m10v_pm_init(void)
137+
{
138+
if (of_machine_is_compatible("socionext,milbeaut-evb"))
139+
suspend_set_ops(&m10v_pm_ops);
140+
141+
return 0;
142+
}
143+
late_initcall(m10v_pm_init);

0 commit comments

Comments
 (0)