Lines Matching +full:cpu +full:- +full:intc

1 // SPDX-License-Identifier: GPL-2.0-only
83 static inline unsigned int reg_status(struct bcm7038_l1_chip *intc, in reg_status() argument
86 return (0 * intc->n_words + word) * sizeof(u32); in reg_status()
89 static inline unsigned int reg_mask_status(struct bcm7038_l1_chip *intc, in reg_mask_status() argument
92 return (1 * intc->n_words + word) * sizeof(u32); in reg_mask_status()
95 static inline unsigned int reg_mask_set(struct bcm7038_l1_chip *intc, in reg_mask_set() argument
98 return (2 * intc->n_words + word) * sizeof(u32); in reg_mask_set()
101 static inline unsigned int reg_mask_clr(struct bcm7038_l1_chip *intc, in reg_mask_clr() argument
104 return (3 * intc->n_words + word) * sizeof(u32); in reg_mask_clr()
125 struct bcm7038_l1_chip *intc = irq_desc_get_handler_data(desc); in bcm7038_l1_irq_handle() local
126 struct bcm7038_l1_cpu *cpu; in bcm7038_l1_irq_handle() local
131 cpu = intc->cpus[cpu_logical_map(smp_processor_id())]; in bcm7038_l1_irq_handle()
133 cpu = intc->cpus[0]; in bcm7038_l1_irq_handle()
138 for (idx = 0; idx < intc->n_words; idx++) { in bcm7038_l1_irq_handle()
143 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_irq_handle()
144 pending = l1_readl(cpu->map_base + reg_status(intc, idx)) & in bcm7038_l1_irq_handle()
145 ~cpu->mask_cache[idx]; in bcm7038_l1_irq_handle()
146 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_irq_handle()
149 generic_handle_domain_irq(intc->domain, base + hwirq); in bcm7038_l1_irq_handle()
157 struct bcm7038_l1_chip *intc = irq_data_get_irq_chip_data(d); in __bcm7038_l1_unmask() local
158 u32 word = d->hwirq / IRQS_PER_WORD; in __bcm7038_l1_unmask()
159 u32 mask = BIT(d->hwirq % IRQS_PER_WORD); in __bcm7038_l1_unmask()
161 intc->cpus[cpu_idx]->mask_cache[word] &= ~mask; in __bcm7038_l1_unmask()
162 l1_writel(mask, intc->cpus[cpu_idx]->map_base + in __bcm7038_l1_unmask()
163 reg_mask_clr(intc, word)); in __bcm7038_l1_unmask()
168 struct bcm7038_l1_chip *intc = irq_data_get_irq_chip_data(d); in __bcm7038_l1_mask() local
169 u32 word = d->hwirq / IRQS_PER_WORD; in __bcm7038_l1_mask()
170 u32 mask = BIT(d->hwirq % IRQS_PER_WORD); in __bcm7038_l1_mask()
172 intc->cpus[cpu_idx]->mask_cache[word] |= mask; in __bcm7038_l1_mask()
173 l1_writel(mask, intc->cpus[cpu_idx]->map_base + in __bcm7038_l1_mask()
174 reg_mask_set(intc, word)); in __bcm7038_l1_mask()
179 struct bcm7038_l1_chip *intc = irq_data_get_irq_chip_data(d); in bcm7038_l1_unmask() local
182 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_unmask()
183 __bcm7038_l1_unmask(d, intc->affinity[d->hwirq]); in bcm7038_l1_unmask()
184 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_unmask()
189 struct bcm7038_l1_chip *intc = irq_data_get_irq_chip_data(d); in bcm7038_l1_mask() local
192 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_mask()
193 __bcm7038_l1_mask(d, intc->affinity[d->hwirq]); in bcm7038_l1_mask()
194 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_mask()
201 struct bcm7038_l1_chip *intc = irq_data_get_irq_chip_data(d); in bcm7038_l1_set_affinity() local
203 irq_hw_number_t hw = d->hwirq; in bcm7038_l1_set_affinity()
209 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_set_affinity()
211 was_disabled = !!(intc->cpus[intc->affinity[hw]]->mask_cache[word] & in bcm7038_l1_set_affinity()
213 __bcm7038_l1_mask(d, intc->affinity[hw]); in bcm7038_l1_set_affinity()
214 intc->affinity[hw] = first_cpu; in bcm7038_l1_set_affinity()
218 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_set_affinity()
228 int cpu = smp_processor_id(); in bcm7038_l1_cpu_offline() local
231 /* This CPU was not on the affinity mask */ in bcm7038_l1_cpu_offline()
232 if (!cpumask_test_cpu(cpu, mask)) in bcm7038_l1_cpu_offline()
237 * Multiple CPU affinity, remove this CPU from the affinity in bcm7038_l1_cpu_offline()
241 cpumask_clear_cpu(cpu, &new_affinity); in bcm7038_l1_cpu_offline()
243 /* Only CPU, put on the lowest online CPU */ in bcm7038_l1_cpu_offline()
253 struct bcm7038_l1_chip *intc) in bcm7038_l1_init_one() argument
257 struct bcm7038_l1_cpu *cpu; in bcm7038_l1_init_one() local
262 return -EINVAL; in bcm7038_l1_init_one()
267 return -EINVAL; in bcm7038_l1_init_one()
268 else if (!intc->n_words) in bcm7038_l1_init_one()
269 intc->n_words = n_words; in bcm7038_l1_init_one()
270 else if (intc->n_words != n_words) in bcm7038_l1_init_one()
271 return -EINVAL; in bcm7038_l1_init_one()
273 ret = of_property_read_u32_array(dn , "brcm,int-fwd-mask", in bcm7038_l1_init_one()
274 intc->irq_fwd_mask, n_words); in bcm7038_l1_init_one()
275 if (ret != 0 && ret != -EINVAL) { in bcm7038_l1_init_one()
277 pr_err("invalid brcm,int-fwd-mask property\n"); in bcm7038_l1_init_one()
278 return -EINVAL; in bcm7038_l1_init_one()
281 cpu = intc->cpus[idx] = kzalloc(sizeof(*cpu) + n_words * sizeof(u32), in bcm7038_l1_init_one()
283 if (!cpu) in bcm7038_l1_init_one()
284 return -ENOMEM; in bcm7038_l1_init_one()
286 cpu->map_base = ioremap(res.start, sz); in bcm7038_l1_init_one()
287 if (!cpu->map_base) in bcm7038_l1_init_one()
288 return -ENOMEM; in bcm7038_l1_init_one()
291 l1_writel(~intc->irq_fwd_mask[i], in bcm7038_l1_init_one()
292 cpu->map_base + reg_mask_set(intc, i)); in bcm7038_l1_init_one()
293 l1_writel(intc->irq_fwd_mask[i], in bcm7038_l1_init_one()
294 cpu->map_base + reg_mask_clr(intc, i)); in bcm7038_l1_init_one()
295 cpu->mask_cache[i] = ~intc->irq_fwd_mask[i]; in bcm7038_l1_init_one()
301 return -EINVAL; in bcm7038_l1_init_one()
304 if (of_property_read_bool(dn, "brcm,irq-can-wake")) in bcm7038_l1_init_one()
308 intc); in bcm7038_l1_init_one()
326 struct bcm7038_l1_chip *intc; in bcm7038_l1_suspend() local
330 /* Wakeup interrupt should only come from the boot cpu */ in bcm7038_l1_suspend()
337 list_for_each_entry(intc, &bcm7038_l1_intcs_list, list) { in bcm7038_l1_suspend()
338 for (word = 0; word < intc->n_words; word++) { in bcm7038_l1_suspend()
339 val = intc->wake_mask[word] | intc->irq_fwd_mask[word]; in bcm7038_l1_suspend()
341 intc->cpus[boot_cpu]->map_base + reg_mask_set(intc, word)); in bcm7038_l1_suspend()
343 intc->cpus[boot_cpu]->map_base + reg_mask_clr(intc, word)); in bcm7038_l1_suspend()
352 struct bcm7038_l1_chip *intc; in bcm7038_l1_resume() local
361 list_for_each_entry(intc, &bcm7038_l1_intcs_list, list) { in bcm7038_l1_resume()
362 for (word = 0; word < intc->n_words; word++) { in bcm7038_l1_resume()
363 l1_writel(intc->cpus[boot_cpu]->mask_cache[word], in bcm7038_l1_resume()
364 intc->cpus[boot_cpu]->map_base + reg_mask_set(intc, word)); in bcm7038_l1_resume()
365 l1_writel(~intc->cpus[boot_cpu]->mask_cache[word], in bcm7038_l1_resume()
366 intc->cpus[boot_cpu]->map_base + reg_mask_clr(intc, word)); in bcm7038_l1_resume()
378 struct bcm7038_l1_chip *intc = irq_data_get_irq_chip_data(d); in bcm7038_l1_set_wake() local
380 u32 word = d->hwirq / IRQS_PER_WORD; in bcm7038_l1_set_wake()
381 u32 mask = BIT(d->hwirq % IRQS_PER_WORD); in bcm7038_l1_set_wake()
383 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_set_wake()
385 intc->wake_mask[word] |= mask; in bcm7038_l1_set_wake()
387 intc->wake_mask[word] &= ~mask; in bcm7038_l1_set_wake()
388 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_set_wake()
395 .name = "bcm7038-l1",
410 struct bcm7038_l1_chip *intc = d->host_data; in bcm7038_l1_map() local
414 if (intc->irq_fwd_mask[word] & mask) in bcm7038_l1_map()
415 return -EPERM; in bcm7038_l1_map()
418 irq_set_chip_data(virq, d->host_data); in bcm7038_l1_map()
431 struct bcm7038_l1_chip *intc; in bcm7038_l1_of_init() local
434 intc = kzalloc(sizeof(*intc), GFP_KERNEL); in bcm7038_l1_of_init()
435 if (!intc) in bcm7038_l1_of_init()
436 return -ENOMEM; in bcm7038_l1_of_init()
438 raw_spin_lock_init(&intc->lock); in bcm7038_l1_of_init()
440 ret = bcm7038_l1_init_one(dn, idx, intc); in bcm7038_l1_of_init()
444 pr_err("failed to remap intc L1 registers\n"); in bcm7038_l1_of_init()
449 intc->domain = irq_domain_add_linear(dn, IRQS_PER_WORD * intc->n_words, in bcm7038_l1_of_init()
451 intc); in bcm7038_l1_of_init()
452 if (!intc->domain) { in bcm7038_l1_of_init()
453 ret = -ENOMEM; in bcm7038_l1_of_init()
460 list_add_tail(&intc->list, &bcm7038_l1_intcs_list); in bcm7038_l1_of_init()
467 pr_info("registered BCM7038 L1 intc (%pOF, IRQs: %d)\n", in bcm7038_l1_of_init()
468 dn, IRQS_PER_WORD * intc->n_words); in bcm7038_l1_of_init()
474 struct bcm7038_l1_cpu *cpu = intc->cpus[idx]; in bcm7038_l1_of_init() local
476 if (cpu) { in bcm7038_l1_of_init()
477 if (cpu->map_base) in bcm7038_l1_of_init()
478 iounmap(cpu->map_base); in bcm7038_l1_of_init()
479 kfree(cpu); in bcm7038_l1_of_init()
483 kfree(intc); in bcm7038_l1_of_init()
487 IRQCHIP_DECLARE(bcm7038_l1, "brcm,bcm7038-l1-intc", bcm7038_l1_of_init);