0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/io.h>
0012 #include <linux/of.h>
0013 #include <linux/of_address.h>
0014 #include <linux/smp.h>
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 static void __iomem *cpu_bootaddr;
0031
0032 static DEFINE_SPINLOCK(cpu_lock);
0033
0034 static int
0035 r9a06g032_smp_boot_secondary(unsigned int cpu,
0036 struct task_struct *idle)
0037 {
0038 if (!cpu_bootaddr)
0039 return -ENODEV;
0040
0041 spin_lock(&cpu_lock);
0042
0043 writel(__pa_symbol(secondary_startup), cpu_bootaddr);
0044 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
0045
0046 spin_unlock(&cpu_lock);
0047
0048 return 0;
0049 }
0050
0051 static void __init r9a06g032_smp_prepare_cpus(unsigned int max_cpus)
0052 {
0053 struct device_node *dn;
0054 int ret = -EINVAL, dns;
0055 u32 bootaddr;
0056
0057 dn = of_get_cpu_node(1, NULL);
0058 if (!dn) {
0059 pr_err("CPU#1: missing device tree node\n");
0060 return;
0061 }
0062
0063
0064
0065
0066
0067 if (of_find_property(dn, "cpu-release-addr", &dns)) {
0068 if (dns == sizeof(u64)) {
0069 u64 temp;
0070
0071 ret = of_property_read_u64(dn,
0072 "cpu-release-addr", &temp);
0073 bootaddr = temp;
0074 } else {
0075 ret = of_property_read_u32(dn,
0076 "cpu-release-addr",
0077 &bootaddr);
0078 }
0079 }
0080 of_node_put(dn);
0081 if (ret) {
0082 pr_err("CPU#1: invalid cpu-release-addr property\n");
0083 return;
0084 }
0085 pr_info("CPU#1: cpu-release-addr %08x\n", bootaddr);
0086
0087 cpu_bootaddr = ioremap(bootaddr, sizeof(bootaddr));
0088 }
0089
0090 static const struct smp_operations r9a06g032_smp_ops __initconst = {
0091 .smp_prepare_cpus = r9a06g032_smp_prepare_cpus,
0092 .smp_boot_secondary = r9a06g032_smp_boot_secondary,
0093 };
0094
0095 CPU_METHOD_OF_DECLARE(r9a06g032_smp,
0096 "renesas,r9a06g032-smp", &r9a06g032_smp_ops);