1
2
3
4#include <linux/irq.h>
5#include <linux/init.h>
6
7#include <asm/mipsregs.h>
8#include <asm/mipsmtregs.h>
9#include <asm/smtc.h>
10#include <asm/smtc_ipi.h>
11
12
13
14
15
16
17
18static void msmtc_send_ipi_single(int cpu, unsigned int action)
19{
20
21 smtc_send_ipi(cpu, LINUX_SMP_IPI, action);
22}
23
24static void msmtc_send_ipi_mask(const struct cpumask *mask, unsigned int action)
25{
26 unsigned int i;
27
28 for_each_cpu(i, mask)
29 msmtc_send_ipi_single(i, action);
30}
31
32
33
34
35static void __cpuinit msmtc_init_secondary(void)
36{
37 int myvpe;
38
39
40 myvpe = read_c0_tcbind() & TCBIND_CURVPE;
41 if (myvpe != 0) {
42
43 clear_c0_status(ST0_IM);
44 set_c0_status((0x100 << cp0_compare_irq)
45 | (0x100 << MIPS_CPU_IPI_IRQ));
46 if (cp0_perfcount_irq >= 0)
47 set_c0_status(0x100 << cp0_perfcount_irq);
48 }
49
50 smtc_init_secondary();
51}
52
53
54
55
56static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle)
57{
58 smtc_boot_secondary(cpu, idle);
59}
60
61
62
63
64static void __cpuinit msmtc_smp_finish(void)
65{
66 smtc_smp_finish();
67}
68
69
70
71
72
73static void msmtc_cpus_done(void)
74{
75}
76
77
78
79
80
81
82
83
84static void __init msmtc_smp_setup(void)
85{
86
87
88
89
90
91 smp_num_siblings = smtc_build_cpu_map(0);
92}
93
94static void __init msmtc_prepare_cpus(unsigned int max_cpus)
95{
96 smtc_prepare_cpus(max_cpus);
97}
98
99struct plat_smp_ops msmtc_smp_ops = {
100 .send_ipi_single = msmtc_send_ipi_single,
101 .send_ipi_mask = msmtc_send_ipi_mask,
102 .init_secondary = msmtc_init_secondary,
103 .smp_finish = msmtc_smp_finish,
104 .cpus_done = msmtc_cpus_done,
105 .boot_secondary = msmtc_boot_secondary,
106 .smp_setup = msmtc_smp_setup,
107 .prepare_cpus = msmtc_prepare_cpus,
108};
109
110#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
111
112
113
114
115
116int plat_set_irq_affinity(struct irq_data *d, const struct cpumask *affinity,
117 bool force)
118{
119 cpumask_t tmask;
120 int cpu = 0;
121 void smtc_set_irq_affinity(unsigned int irq, cpumask_t aff);
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 cpumask_copy(&tmask, affinity);
143 for_each_cpu(cpu, affinity) {
144 if ((cpu_data[cpu].vpe_id != 0) || !cpu_online(cpu))
145 cpu_clear(cpu, tmask);
146 }
147 cpumask_copy(d->affinity, &tmask);
148
149 if (cpus_empty(tmask))
150
151
152
153
154 printk(KERN_WARNING
155 "IRQ affinity leaves no legal CPU for IRQ %d\n", d->irq);
156
157
158 smtc_set_irq_affinity(d->irq, tmask);
159
160 return IRQ_SET_MASK_OK_NOCOPY;
161}
162#endif
163