Lines Matching +full:parent +full:- +full:interrupt +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Broadcom BCM7120 style Level 2 interrupt controller driver
19 #include <linux/interrupt.h>
28 /* Register offset in the L2 interrupt controller */
58 struct bcm7120_l2_intc_data *b = data->b; in bcm7120_l2_intc_irq_handle()
64 for (idx = 0; idx < b->n_words; idx++) { in bcm7120_l2_intc_irq_handle()
65 int base = idx * IRQS_PER_WORD; in bcm7120_l2_intc_irq_handle() local
70 gc = irq_get_domain_generic_chip(b->domain, base); in bcm7120_l2_intc_irq_handle()
71 scoped_guard (raw_spinlock, &gc->lock) { in bcm7120_l2_intc_irq_handle()
72 pending = irq_reg_readl(gc, b->stat_offset[idx]) & gc->mask_cache & in bcm7120_l2_intc_irq_handle()
73 data->irq_map_mask[idx]; in bcm7120_l2_intc_irq_handle()
77 generic_handle_domain_irq(b->domain, base + hwirq); in bcm7120_l2_intc_irq_handle()
85 struct bcm7120_l2_intc_data *b = gc->private; in bcm7120_l2_intc_suspend()
86 struct irq_chip_type *ct = gc->chip_types; in bcm7120_l2_intc_suspend()
88 guard(raw_spinlock)(&gc->lock); in bcm7120_l2_intc_suspend()
89 if (b->can_wake) in bcm7120_l2_intc_suspend()
90 irq_reg_writel(gc, gc->mask_cache | gc->wake_active, ct->regs.mask); in bcm7120_l2_intc_suspend()
95 struct irq_chip_type *ct = gc->chip_types; in bcm7120_l2_intc_resume()
98 guard(raw_spinlock)(&gc->lock); in bcm7120_l2_intc_resume()
99 irq_reg_writel(gc, gc->mask_cache, ct->regs.mask); in bcm7120_l2_intc_resume()
106 struct bcm7120_l1_intc_data *l1_data = &data->l1_data[irq]; in bcm7120_l2_intc_init_one()
112 pr_err("failed to map interrupt %d\n", irq); in bcm7120_l2_intc_init_one()
113 return -EINVAL; in bcm7120_l2_intc_init_one()
116 /* For multiple parent IRQs with multiple words, this looks like: in bcm7120_l2_intc_init_one()
119 * We need to associate a given parent interrupt with its corresponding in bcm7120_l2_intc_init_one()
121 * have the same handler being called for multiple parent interrupts. in bcm7120_l2_intc_init_one()
125 for (idx = 0; idx < data->n_words; idx++) { in bcm7120_l2_intc_init_one()
126 if (data->map_mask_prop) { in bcm7120_l2_intc_init_one()
127 l1_data->irq_map_mask[idx] |= in bcm7120_l2_intc_init_one()
128 be32_to_cpup(data->map_mask_prop + in bcm7120_l2_intc_init_one()
129 irq * data->n_words + idx); in bcm7120_l2_intc_init_one()
131 l1_data->irq_map_mask[idx] = 0xffffffff; in bcm7120_l2_intc_init_one()
133 valid_mask[idx] |= l1_data->irq_map_mask[idx]; in bcm7120_l2_intc_init_one()
136 l1_data->b = data; in bcm7120_l2_intc_init_one()
140 if (data->can_wake) in bcm7120_l2_intc_init_one()
151 data->map_base[0] = of_iomap(dn, 0); in bcm7120_l2_intc_iomap_7120()
152 if (!data->map_base[0]) { in bcm7120_l2_intc_iomap_7120()
154 return -ENOMEM; in bcm7120_l2_intc_iomap_7120()
157 data->pair_base[0] = data->map_base[0]; in bcm7120_l2_intc_iomap_7120()
158 data->en_offset[0] = IRQEN; in bcm7120_l2_intc_iomap_7120()
159 data->stat_offset[0] = IRQSTAT; in bcm7120_l2_intc_iomap_7120()
160 data->n_words = 1; in bcm7120_l2_intc_iomap_7120()
162 ret = of_property_read_u32_array(dn, "brcm,int-fwd-mask", in bcm7120_l2_intc_iomap_7120()
163 data->irq_fwd_mask, data->n_words); in bcm7120_l2_intc_iomap_7120()
164 if (ret != 0 && ret != -EINVAL) { in bcm7120_l2_intc_iomap_7120()
166 pr_err("invalid brcm,int-fwd-mask property\n"); in bcm7120_l2_intc_iomap_7120()
167 return -EINVAL; in bcm7120_l2_intc_iomap_7120()
170 data->map_mask_prop = of_get_property(dn, "brcm,int-map-mask", &ret); in bcm7120_l2_intc_iomap_7120()
171 if (!data->map_mask_prop || in bcm7120_l2_intc_iomap_7120()
172 (ret != (sizeof(__be32) * data->num_parent_irqs * data->n_words))) { in bcm7120_l2_intc_iomap_7120()
173 pr_err("invalid brcm,int-map-mask property\n"); in bcm7120_l2_intc_iomap_7120()
174 return -EINVAL; in bcm7120_l2_intc_iomap_7120()
189 void __iomem *base = min(en, stat); in bcm7120_l2_intc_iomap_3380() local
191 data->map_base[map_idx + 0] = en; in bcm7120_l2_intc_iomap_3380()
192 data->map_base[map_idx + 1] = stat; in bcm7120_l2_intc_iomap_3380()
194 if (!base) in bcm7120_l2_intc_iomap_3380()
197 data->pair_base[gc_idx] = base; in bcm7120_l2_intc_iomap_3380()
198 data->en_offset[gc_idx] = en - base; in bcm7120_l2_intc_iomap_3380()
199 data->stat_offset[gc_idx] = stat - base; in bcm7120_l2_intc_iomap_3380()
204 return -EINVAL; in bcm7120_l2_intc_iomap_3380()
207 data->n_words = gc_idx; in bcm7120_l2_intc_iomap_3380()
212 struct device_node *parent, in bcm7120_l2_intc_probe() argument
228 return -ENOMEM; in bcm7120_l2_intc_probe()
232 ret = -ENODEV; in bcm7120_l2_intc_probe()
236 data->num_parent_irqs = platform_irq_count(pdev); in bcm7120_l2_intc_probe()
237 put_device(&pdev->dev); in bcm7120_l2_intc_probe()
238 if (data->num_parent_irqs <= 0) { in bcm7120_l2_intc_probe()
239 pr_err("invalid number of parent interrupts\n"); in bcm7120_l2_intc_probe()
240 ret = -ENOMEM; in bcm7120_l2_intc_probe()
244 data->l1_data = kcalloc(data->num_parent_irqs, sizeof(*data->l1_data), in bcm7120_l2_intc_probe()
246 if (!data->l1_data) { in bcm7120_l2_intc_probe()
247 ret = -ENOMEM; in bcm7120_l2_intc_probe()
255 data->can_wake = of_property_read_bool(dn, "brcm,irq-can-wake"); in bcm7120_l2_intc_probe()
257 for (irq = 0; irq < data->num_parent_irqs; irq++) { in bcm7120_l2_intc_probe()
263 data->domain = irq_domain_create_linear(of_fwnode_handle(dn), IRQS_PER_WORD * data->n_words, in bcm7120_l2_intc_probe()
265 if (!data->domain) { in bcm7120_l2_intc_probe()
266 ret = -ENOMEM; in bcm7120_l2_intc_probe()
271 * peripheral registers for CPU-native byte order. in bcm7120_l2_intc_probe()
277 ret = irq_alloc_domain_generic_chips(data->domain, IRQS_PER_WORD, 1, in bcm7120_l2_intc_probe()
278 dn->full_name, handle_level_irq, clr, in bcm7120_l2_intc_probe()
285 for (idx = 0; idx < data->n_words; idx++) { in bcm7120_l2_intc_probe()
287 gc = irq_get_domain_generic_chip(data->domain, irq); in bcm7120_l2_intc_probe()
289 gc->unused = 0xffffffff & ~valid_mask[idx]; in bcm7120_l2_intc_probe()
290 gc->private = data; in bcm7120_l2_intc_probe()
291 ct = gc->chip_types; in bcm7120_l2_intc_probe()
293 gc->reg_base = data->pair_base[idx]; in bcm7120_l2_intc_probe()
294 ct->regs.mask = data->en_offset[idx]; in bcm7120_l2_intc_probe()
296 /* gc->reg_base is defined and so is gc->writel */ in bcm7120_l2_intc_probe()
297 irq_reg_writel(gc, data->irq_fwd_mask[idx], in bcm7120_l2_intc_probe()
298 data->en_offset[idx]); in bcm7120_l2_intc_probe()
300 ct->chip.irq_mask = irq_gc_mask_clr_bit; in bcm7120_l2_intc_probe()
301 ct->chip.irq_unmask = irq_gc_mask_set_bit; in bcm7120_l2_intc_probe()
302 ct->chip.irq_ack = irq_gc_noop; in bcm7120_l2_intc_probe()
303 gc->suspend = bcm7120_l2_intc_suspend; in bcm7120_l2_intc_probe()
304 gc->resume = bcm7120_l2_intc_resume; in bcm7120_l2_intc_probe()
307 * Initialize mask-cache, in case we need it for in bcm7120_l2_intc_probe()
311 gc->mask_cache = irq_reg_readl(gc, ct->regs.mask); in bcm7120_l2_intc_probe()
313 if (data->can_wake) { in bcm7120_l2_intc_probe()
317 gc->wake_enabled = 0xffffffff; in bcm7120_l2_intc_probe()
318 gc->wake_enabled &= ~gc->unused; in bcm7120_l2_intc_probe()
319 ct->chip.irq_set_wake = irq_gc_set_wake; in bcm7120_l2_intc_probe()
323 pr_info("registered %s intc (%pOF, parent IRQ(s): %d)\n", in bcm7120_l2_intc_probe()
324 intc_name, dn, data->num_parent_irqs); in bcm7120_l2_intc_probe()
329 irq_domain_remove(data->domain); in bcm7120_l2_intc_probe()
331 kfree(data->l1_data); in bcm7120_l2_intc_probe()
334 if (data->map_base[idx]) in bcm7120_l2_intc_probe()
335 iounmap(data->map_base[idx]); in bcm7120_l2_intc_probe()
343 struct device_node *parent) in bcm7120_l2_intc_probe_7120() argument
345 return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_7120, in bcm7120_l2_intc_probe_7120()
350 struct device_node *parent) in bcm7120_l2_intc_probe_3380() argument
352 return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_3380, in bcm7120_l2_intc_probe_3380()
357 IRQCHIP_MATCH("brcm,bcm7120-l2-intc", bcm7120_l2_intc_probe_7120)
358 IRQCHIP_MATCH("brcm,bcm3380-l2-intc", bcm7120_l2_intc_probe_3380)
360 MODULE_DESCRIPTION("Broadcom STB 7120-style L2 interrupt controller driver");