Merge tag 'please-pull-misc-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / arch / blackfin / mach-bf561 / smp.c
CommitLineData
c51b4488 1/*
96f1050d
RG
2 * Copyright 2007-2009 Analog Devices Inc.
3 * Philippe Gerum <rpm@xenomai.org>
c51b4488 4 *
96f1050d 5 * Licensed under the GPL-2 or later.
c51b4488
GY
6 */
7
8#include <linux/init.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <linux/delay.h>
12#include <asm/smp.h>
13#include <asm/dma.h>
0d152c27 14#include <asm/time.h>
c51b4488 15
c51b4488
GY
16static DEFINE_SPINLOCK(boot_lock);
17
c51b4488
GY
18/*
19 * platform_init_cpus() - Tell the world about how many cores we
20 * have. This is called while setting up the architecture support
21 * (setup_arch()), so don't be too demanding here with respect to
22 * available kernel services.
23 */
24
25void __init platform_init_cpus(void)
26{
3cb8a39f
KM
27 struct cpumask mask;
28
29 cpumask_set_cpu(0, &mask); /* CoreA */
30 cpumask_set_cpu(1, &mask); /* CoreB */
31 init_cpu_possible(&mask);
c51b4488
GY
32}
33
34void __init platform_prepare_cpus(unsigned int max_cpus)
35{
3cb8a39f
KM
36 struct cpumask mask;
37
c6345ab1 38 bfin_relocate_coreb_l1_mem();
c51b4488
GY
39
40 /* Both cores ought to be present on a bf561! */
3cb8a39f
KM
41 cpumask_set_cpu(0, &mask); /* CoreA */
42 cpumask_set_cpu(1, &mask); /* CoreB */
43 init_cpu_present(&mask);
c51b4488
GY
44}
45
46int __init setup_profiling_timer(unsigned int multiplier) /* not supported */
47{
48 return -EINVAL;
49}
50
13dff62d 51void platform_secondary_init(unsigned int cpu)
c51b4488 52{
c51b4488 53 /* Clone setup for peripheral interrupt sources from CoreA. */
39c99969
MF
54 bfin_write_SICB_IMASK0(bfin_read_SIC_IMASK0());
55 bfin_write_SICB_IMASK1(bfin_read_SIC_IMASK1());
c51b4488
GY
56 SSYNC();
57
58 /* Clone setup for IARs from CoreA. */
39c99969
MF
59 bfin_write_SICB_IAR0(bfin_read_SIC_IAR0());
60 bfin_write_SICB_IAR1(bfin_read_SIC_IAR1());
61 bfin_write_SICB_IAR2(bfin_read_SIC_IAR2());
62 bfin_write_SICB_IAR3(bfin_read_SIC_IAR3());
63 bfin_write_SICB_IAR4(bfin_read_SIC_IAR4());
64 bfin_write_SICB_IAR5(bfin_read_SIC_IAR5());
65 bfin_write_SICB_IAR6(bfin_read_SIC_IAR6());
66 bfin_write_SICB_IAR7(bfin_read_SIC_IAR7());
0b39db28
GY
67 bfin_write_SICB_IWR0(IWR_DISABLE_ALL);
68 bfin_write_SICB_IWR1(IWR_DISABLE_ALL);
c51b4488
GY
69 SSYNC();
70
c51b4488 71 /* We are done with local CPU inits, unblock the boot CPU. */
c51b4488
GY
72 spin_lock(&boot_lock);
73 spin_unlock(&boot_lock);
74}
75
13dff62d 76int platform_boot_secondary(unsigned int cpu, struct task_struct *idle)
c51b4488
GY
77{
78 unsigned long timeout;
79
c51b4488
GY
80 printk(KERN_INFO "Booting Core B.\n");
81
82 spin_lock(&boot_lock);
83
94a038c2 84 if ((bfin_read_SYSCR() & COREB_SRAM_INIT) == 0) {
0b39db28 85 /* CoreB already running, sending ipi to wakeup it */
d0014be4 86 smp_send_reschedule(cpu);
0b39db28
GY
87 } else {
88 /* Kick CoreB, which should start execution from CORE_SRAM_BASE. */
94a038c2 89 bfin_write_SYSCR(bfin_read_SYSCR() & ~COREB_SRAM_INIT);
0b39db28
GY
90 SSYNC();
91 }
c51b4488 92
150382a5
SM
93 timeout = jiffies + HZ;
94 /* release the lock and let coreb run */
95 spin_unlock(&boot_lock);
c51b4488 96 while (time_before(jiffies, timeout)) {
682f5dc4 97 if (cpu_online(cpu))
c51b4488
GY
98 break;
99 udelay(100);
100 barrier();
101 }
102
682f5dc4 103 if (cpu_online(cpu)) {
578d36f5
YL
104 return 0;
105 } else
106 panic("CPU%u: processor failed to boot\n", cpu);
c51b4488
GY
107}
108
73a40064
YL
109static const char supple0[] = "IRQ_SUPPLE_0";
110static const char supple1[] = "IRQ_SUPPLE_1";
111void __init platform_request_ipi(int irq, void *handler)
c51b4488
GY
112{
113 int ret;
73a40064 114 const char *name = (irq == IRQ_SUPPLE_0) ? supple0 : supple1;
c51b4488 115
16df3666
BL
116 ret = request_irq(irq, handler, IRQF_PERCPU | IRQF_NO_SUSPEND |
117 IRQF_FORCE_RESUME, name, handler);
c51b4488 118 if (ret)
73a40064 119 panic("Cannot request %s for IPI service", name);
c51b4488
GY
120}
121
73a40064 122void platform_send_ipi(cpumask_t callmap, int irq)
c51b4488
GY
123{
124 unsigned int cpu;
73a40064 125 int offset = (irq == IRQ_SUPPLE_0) ? 6 : 8;
c51b4488 126
35168f51 127 for_each_cpu(cpu, &callmap) {
c51b4488
GY
128 BUG_ON(cpu >= 2);
129 SSYNC();
73a40064 130 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | (1 << (offset + cpu)));
c51b4488
GY
131 SSYNC();
132 }
133}
134
73a40064 135void platform_send_ipi_cpu(unsigned int cpu, int irq)
c51b4488 136{
73a40064 137 int offset = (irq == IRQ_SUPPLE_0) ? 6 : 8;
c51b4488
GY
138 BUG_ON(cpu >= 2);
139 SSYNC();
73a40064 140 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | (1 << (offset + cpu)));
c51b4488
GY
141 SSYNC();
142}
143
73a40064 144void platform_clear_ipi(unsigned int cpu, int irq)
c51b4488 145{
73a40064 146 int offset = (irq == IRQ_SUPPLE_0) ? 10 : 12;
c51b4488
GY
147 BUG_ON(cpu >= 2);
148 SSYNC();
73a40064 149 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | (1 << (offset + cpu)));
c51b4488
GY
150 SSYNC();
151}
0d152c27
YL
152
153/*
154 * Setup core B's local core timer.
155 * In SMP, core timer is used for clock event device.
156 */
13dff62d 157void bfin_local_timer_setup(void)
0d152c27
YL
158{
159#if defined(CONFIG_TICKSOURCE_CORETMR)
1907d8be
TG
160 struct irq_data *data = irq_get_irq_data(IRQ_CORETMR);
161 struct irq_chip *chip = irq_data_get_irq_chip(data);
91796c23 162
0d152c27
YL
163 bfin_coretmr_init();
164 bfin_coretmr_clockevent_init();
91796c23 165
1907d8be 166 chip->irq_unmask(data);
0d152c27
YL
167#else
168 /* Power down the core timer, just to play safe. */
169 bfin_write_TCNTL(0);
170#endif
171
172}
This page took 0.425278 seconds and 5 git commands to generate.