1 // SPDX-License-Identifier: GPL-2.0
3 * R9A06G032 Second CA7 enabler.
5 * Copyright (C) 2018 Renesas Electronics Europe Limited
7 * Michel Pollet <michel.pollet@bp.renesas.com>, <buserror@gmail.com>
8 * Derived from actions,s500-smp
13 #include <linux/of_address.h>
14 #include <linux/smp.h>
17 * The second CPU is parked in ROM at boot time. It requires waking it after
18 * writing an address into the BOOTADDR register of sysctrl.
20 * So the default value of the "cpu-release-addr" corresponds to BOOTADDR...
22 * *However* the BOOTADDR register is not available when the kernel
23 * starts in NONSEC mode.
25 * So for NONSEC mode, the bootloader re-parks the second CPU into a pen
26 * in SRAM, and changes the "cpu-release-addr" of linux's DT to a SRAM address,
27 * which is not restricted.
30 static void __iomem
*cpu_bootaddr
;
32 static DEFINE_SPINLOCK(cpu_lock
);
35 r9a06g032_smp_boot_secondary(unsigned int cpu
,
36 struct task_struct
*idle
)
43 writel(__pa_symbol(secondary_startup
), cpu_bootaddr
);
44 arch_send_wakeup_ipi_mask(cpumask_of(cpu
));
46 spin_unlock(&cpu_lock
);
51 static void __init
r9a06g032_smp_prepare_cpus(unsigned int max_cpus
)
53 struct device_node
*dn
;
54 int ret
= -EINVAL
, dns
;
57 dn
= of_get_cpu_node(1, NULL
);
59 pr_err("CPU#1: missing device tree node\n");
63 * Determine the address from which the CPU is polling.
64 * The bootloader *does* change this property.
65 * Note: The property can be either 64 or 32 bits, so handle both cases
67 if (of_find_property(dn
, "cpu-release-addr", &dns
)) {
68 if (dns
== sizeof(u64
)) {
71 ret
= of_property_read_u64(dn
,
72 "cpu-release-addr", &temp
);
75 ret
= of_property_read_u32(dn
,
82 pr_err("CPU#1: invalid cpu-release-addr property\n");
85 pr_info("CPU#1: cpu-release-addr %08x\n", bootaddr
);
87 cpu_bootaddr
= ioremap(bootaddr
, sizeof(bootaddr
));
90 static const struct smp_operations r9a06g032_smp_ops __initconst
= {
91 .smp_prepare_cpus
= r9a06g032_smp_prepare_cpus
,
92 .smp_boot_secondary
= r9a06g032_smp_boot_secondary
,
95 CPU_METHOD_OF_DECLARE(r9a06g032_smp
,
96 "renesas,r9a06g032-smp", &r9a06g032_smp_ops
);