2 * arch/arm/mach-sti/platsmp.c
4 * Copyright (C) 2013 STMicroelectronics (R&D) Limited.
7 * Cloned from linux/arch/arm/mach-vexpress/platsmp.c
9 * Copyright (C) 2002 ARM Ltd.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <linux/delay.h>
19 #include <linux/smp.h>
22 #include <linux/of_address.h>
24 #include <asm/cacheflush.h>
25 #include <asm/smp_plat.h>
26 #include <asm/smp_scu.h>
30 static void write_pen_release(int val
)
34 sync_cache_w(&pen_release
);
37 static DEFINE_SPINLOCK(boot_lock
);
39 void sti_secondary_init(unsigned int cpu
)
44 * let the primary processor know we're out of the
45 * pen, then head off into the C entry point
47 write_pen_release(-1);
50 * Synchronise with the boot thread.
52 spin_lock(&boot_lock
);
53 spin_unlock(&boot_lock
);
56 int sti_boot_secondary(unsigned int cpu
, struct task_struct
*idle
)
58 unsigned long timeout
;
61 * set synchronisation state between this boot processor
62 * and the secondary one
64 spin_lock(&boot_lock
);
67 * The secondary processor is waiting to be released from
68 * the holding pen - release it, then wait for it to flag
69 * that it has been released by resetting pen_release.
71 * Note that "pen_release" is the hardware CPU ID, whereas
72 * "cpu" is Linux's internal ID.
74 write_pen_release(cpu_logical_map(cpu
));
77 * Send the secondary CPU a soft interrupt, thereby causing
78 * it to jump to the secondary entrypoint.
80 arch_send_wakeup_ipi_mask(cpumask_of(cpu
));
82 timeout
= jiffies
+ (1 * HZ
);
83 while (time_before(jiffies
, timeout
)) {
85 if (pen_release
== -1)
92 * now the secondary core is starting up let it run its
93 * calibrations, then wait for it to finish
95 spin_unlock(&boot_lock
);
97 return pen_release
!= -1 ? -ENOSYS
: 0;
100 void __init
sti_smp_prepare_cpus(unsigned int max_cpus
)
102 void __iomem
*scu_base
= NULL
;
103 struct device_node
*np
= of_find_compatible_node(
104 NULL
, NULL
, "arm,cortex-a9-scu");
106 scu_base
= of_iomap(np
, 0);
107 scu_enable(scu_base
);
112 struct smp_operations __initdata sti_smp_ops
= {
113 .smp_prepare_cpus
= sti_smp_prepare_cpus
,
114 .smp_secondary_init
= sti_secondary_init
,
115 .smp_boot_secondary
= sti_boot_secondary
,