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
67 irq_get_domain_generic_chip(b->domain, base); in bcm7120_l2_intc_irq_handle()
72 pending = irq_reg_readl(gc, b->stat_offset[idx]) & in bcm7120_l2_intc_irq_handle()
73 gc->mask_cache & in bcm7120_l2_intc_irq_handle()
74 data->irq_map_mask[idx]; in bcm7120_l2_intc_irq_handle()
78 generic_handle_domain_irq(b->domain, base + hwirq); in bcm7120_l2_intc_irq_handle()
86 struct bcm7120_l2_intc_data *b = gc->private; in bcm7120_l2_intc_suspend()
87 struct irq_chip_type *ct = gc->chip_types; in bcm7120_l2_intc_suspend()
90 if (b->can_wake) in bcm7120_l2_intc_suspend()
91 irq_reg_writel(gc, gc->mask_cache | gc->wake_active, in bcm7120_l2_intc_suspend()
92 ct->regs.mask); in bcm7120_l2_intc_suspend()
98 struct irq_chip_type *ct = gc->chip_types; in bcm7120_l2_intc_resume()
102 irq_reg_writel(gc, gc->mask_cache, ct->regs.mask); in bcm7120_l2_intc_resume()
110 struct bcm7120_l1_intc_data *l1_data = &data->l1_data[irq]; in bcm7120_l2_intc_init_one()
116 pr_err("failed to map interrupt %d\n", irq); in bcm7120_l2_intc_init_one()
117 return -EINVAL; in bcm7120_l2_intc_init_one()
120 /* For multiple parent IRQs with multiple words, this looks like: in bcm7120_l2_intc_init_one()
123 * We need to associate a given parent interrupt with its corresponding in bcm7120_l2_intc_init_one()
125 * have the same handler being called for multiple parent interrupts. in bcm7120_l2_intc_init_one()
129 for (idx = 0; idx < data->n_words; idx++) { in bcm7120_l2_intc_init_one()
130 if (data->map_mask_prop) { in bcm7120_l2_intc_init_one()
131 l1_data->irq_map_mask[idx] |= in bcm7120_l2_intc_init_one()
132 be32_to_cpup(data->map_mask_prop + in bcm7120_l2_intc_init_one()
133 irq * data->n_words + idx); in bcm7120_l2_intc_init_one()
135 l1_data->irq_map_mask[idx] = 0xffffffff; in bcm7120_l2_intc_init_one()
137 valid_mask[idx] |= l1_data->irq_map_mask[idx]; in bcm7120_l2_intc_init_one()
140 l1_data->b = data; in bcm7120_l2_intc_init_one()
144 if (data->can_wake) in bcm7120_l2_intc_init_one()
155 data->map_base[0] = of_iomap(dn, 0); in bcm7120_l2_intc_iomap_7120()
156 if (!data->map_base[0]) { in bcm7120_l2_intc_iomap_7120()
158 return -ENOMEM; in bcm7120_l2_intc_iomap_7120()
161 data->pair_base[0] = data->map_base[0]; in bcm7120_l2_intc_iomap_7120()
162 data->en_offset[0] = IRQEN; in bcm7120_l2_intc_iomap_7120()
163 data->stat_offset[0] = IRQSTAT; in bcm7120_l2_intc_iomap_7120()
164 data->n_words = 1; in bcm7120_l2_intc_iomap_7120()
166 ret = of_property_read_u32_array(dn, "brcm,int-fwd-mask", in bcm7120_l2_intc_iomap_7120()
167 data->irq_fwd_mask, data->n_words); in bcm7120_l2_intc_iomap_7120()
168 if (ret != 0 && ret != -EINVAL) { in bcm7120_l2_intc_iomap_7120()
170 pr_err("invalid brcm,int-fwd-mask property\n"); in bcm7120_l2_intc_iomap_7120()
171 return -EINVAL; in bcm7120_l2_intc_iomap_7120()
174 data->map_mask_prop = of_get_property(dn, "brcm,int-map-mask", &ret); in bcm7120_l2_intc_iomap_7120()
175 if (!data->map_mask_prop || in bcm7120_l2_intc_iomap_7120()
176 (ret != (sizeof(__be32) * data->num_parent_irqs * data->n_words))) { in bcm7120_l2_intc_iomap_7120()
177 pr_err("invalid brcm,int-map-mask property\n"); in bcm7120_l2_intc_iomap_7120()
178 return -EINVAL; in bcm7120_l2_intc_iomap_7120()
193 void __iomem *base = min(en, stat); in bcm7120_l2_intc_iomap_3380() local
195 data->map_base[map_idx + 0] = en; in bcm7120_l2_intc_iomap_3380()
196 data->map_base[map_idx + 1] = stat; in bcm7120_l2_intc_iomap_3380()
198 if (!base) in bcm7120_l2_intc_iomap_3380()
201 data->pair_base[gc_idx] = base; in bcm7120_l2_intc_iomap_3380()
202 data->en_offset[gc_idx] = en - base; in bcm7120_l2_intc_iomap_3380()
203 data->stat_offset[gc_idx] = stat - base; in bcm7120_l2_intc_iomap_3380()
208 return -EINVAL; in bcm7120_l2_intc_iomap_3380()
211 data->n_words = gc_idx; in bcm7120_l2_intc_iomap_3380()
216 struct device_node *parent, in bcm7120_l2_intc_probe() argument
231 return -ENOMEM; in bcm7120_l2_intc_probe()
233 data->num_parent_irqs = of_irq_count(dn); in bcm7120_l2_intc_probe()
234 if (data->num_parent_irqs <= 0) { in bcm7120_l2_intc_probe()
235 pr_err("invalid number of parent interrupts\n"); in bcm7120_l2_intc_probe()
236 ret = -ENOMEM; in bcm7120_l2_intc_probe()
240 data->l1_data = kcalloc(data->num_parent_irqs, sizeof(*data->l1_data), in bcm7120_l2_intc_probe()
242 if (!data->l1_data) { in bcm7120_l2_intc_probe()
243 ret = -ENOMEM; in bcm7120_l2_intc_probe()
251 data->can_wake = of_property_read_bool(dn, "brcm,irq-can-wake"); in bcm7120_l2_intc_probe()
253 for (irq = 0; irq < data->num_parent_irqs; irq++) { in bcm7120_l2_intc_probe()
259 data->domain = irq_domain_add_linear(dn, IRQS_PER_WORD * data->n_words, in bcm7120_l2_intc_probe()
261 if (!data->domain) { in bcm7120_l2_intc_probe()
262 ret = -ENOMEM; in bcm7120_l2_intc_probe()
267 * peripheral registers for CPU-native byte order. in bcm7120_l2_intc_probe()
273 ret = irq_alloc_domain_generic_chips(data->domain, IRQS_PER_WORD, 1, in bcm7120_l2_intc_probe()
274 dn->full_name, handle_level_irq, clr, 0, flags); in bcm7120_l2_intc_probe()
280 for (idx = 0; idx < data->n_words; idx++) { in bcm7120_l2_intc_probe()
282 gc = irq_get_domain_generic_chip(data->domain, irq); in bcm7120_l2_intc_probe()
284 gc->unused = 0xffffffff & ~valid_mask[idx]; in bcm7120_l2_intc_probe()
285 gc->private = data; in bcm7120_l2_intc_probe()
286 ct = gc->chip_types; in bcm7120_l2_intc_probe()
288 gc->reg_base = data->pair_base[idx]; in bcm7120_l2_intc_probe()
289 ct->regs.mask = data->en_offset[idx]; in bcm7120_l2_intc_probe()
291 /* gc->reg_base is defined and so is gc->writel */ in bcm7120_l2_intc_probe()
292 irq_reg_writel(gc, data->irq_fwd_mask[idx], in bcm7120_l2_intc_probe()
293 data->en_offset[idx]); in bcm7120_l2_intc_probe()
295 ct->chip.irq_mask = irq_gc_mask_clr_bit; in bcm7120_l2_intc_probe()
296 ct->chip.irq_unmask = irq_gc_mask_set_bit; in bcm7120_l2_intc_probe()
297 ct->chip.irq_ack = irq_gc_noop; in bcm7120_l2_intc_probe()
298 gc->suspend = bcm7120_l2_intc_suspend; in bcm7120_l2_intc_probe()
299 gc->resume = bcm7120_l2_intc_resume; in bcm7120_l2_intc_probe()
302 * Initialize mask-cache, in case we need it for in bcm7120_l2_intc_probe()
306 gc->mask_cache = irq_reg_readl(gc, ct->regs.mask); in bcm7120_l2_intc_probe()
308 if (data->can_wake) { in bcm7120_l2_intc_probe()
312 gc->wake_enabled = 0xffffffff; in bcm7120_l2_intc_probe()
313 gc->wake_enabled &= ~gc->unused; in bcm7120_l2_intc_probe()
314 ct->chip.irq_set_wake = irq_gc_set_wake; in bcm7120_l2_intc_probe()
318 pr_info("registered %s intc (%pOF, parent IRQ(s): %d)\n", in bcm7120_l2_intc_probe()
319 intc_name, dn, data->num_parent_irqs); in bcm7120_l2_intc_probe()
324 irq_domain_remove(data->domain); in bcm7120_l2_intc_probe()
326 kfree(data->l1_data); in bcm7120_l2_intc_probe()
329 if (data->map_base[idx]) in bcm7120_l2_intc_probe()
330 iounmap(data->map_base[idx]); in bcm7120_l2_intc_probe()
337 struct device_node *parent) in bcm7120_l2_intc_probe_7120() argument
339 return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_7120, in bcm7120_l2_intc_probe_7120()
344 struct device_node *parent) in bcm7120_l2_intc_probe_3380() argument
346 return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_3380, in bcm7120_l2_intc_probe_3380()
350 IRQCHIP_DECLARE(bcm7120_l2_intc, "brcm,bcm7120-l2-intc",
353 IRQCHIP_DECLARE(bcm3380_l2_intc, "brcm,bcm3380-l2-intc",