Lines Matching +full:bcm3380 +full:- +full:l2 +full:- +full:intc
1 // SPDX-License-Identifier: GPL-2.0-only
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()
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()
117 return -EINVAL; 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()
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()
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()
232 return -ENOMEM; in bcm7120_l2_intc_probe()
236 ret = -ENODEV; in bcm7120_l2_intc_probe()
240 data->num_parent_irqs = platform_irq_count(pdev); in bcm7120_l2_intc_probe()
241 put_device(&pdev->dev); in bcm7120_l2_intc_probe()
242 if (data->num_parent_irqs <= 0) { in bcm7120_l2_intc_probe()
244 ret = -ENOMEM; in bcm7120_l2_intc_probe()
248 data->l1_data = kcalloc(data->num_parent_irqs, sizeof(*data->l1_data), in bcm7120_l2_intc_probe()
250 if (!data->l1_data) { in bcm7120_l2_intc_probe()
251 ret = -ENOMEM; in bcm7120_l2_intc_probe()
259 data->can_wake = of_property_read_bool(dn, "brcm,irq-can-wake"); in bcm7120_l2_intc_probe()
261 for (irq = 0; irq < data->num_parent_irqs; irq++) { in bcm7120_l2_intc_probe()
267 data->domain = irq_domain_add_linear(dn, IRQS_PER_WORD * data->n_words, in bcm7120_l2_intc_probe()
269 if (!data->domain) { in bcm7120_l2_intc_probe()
270 ret = -ENOMEM; in bcm7120_l2_intc_probe()
275 * peripheral registers for CPU-native byte order. in bcm7120_l2_intc_probe()
281 ret = irq_alloc_domain_generic_chips(data->domain, IRQS_PER_WORD, 1, in bcm7120_l2_intc_probe()
282 dn->full_name, handle_level_irq, clr, in bcm7120_l2_intc_probe()
289 for (idx = 0; idx < data->n_words; idx++) { in bcm7120_l2_intc_probe()
291 gc = irq_get_domain_generic_chip(data->domain, irq); in bcm7120_l2_intc_probe()
293 gc->unused = 0xffffffff & ~valid_mask[idx]; in bcm7120_l2_intc_probe()
294 gc->private = data; in bcm7120_l2_intc_probe()
295 ct = gc->chip_types; in bcm7120_l2_intc_probe()
297 gc->reg_base = data->pair_base[idx]; in bcm7120_l2_intc_probe()
298 ct->regs.mask = data->en_offset[idx]; in bcm7120_l2_intc_probe()
300 /* gc->reg_base is defined and so is gc->writel */ in bcm7120_l2_intc_probe()
301 irq_reg_writel(gc, data->irq_fwd_mask[idx], in bcm7120_l2_intc_probe()
302 data->en_offset[idx]); in bcm7120_l2_intc_probe()
304 ct->chip.irq_mask = irq_gc_mask_clr_bit; in bcm7120_l2_intc_probe()
305 ct->chip.irq_unmask = irq_gc_mask_set_bit; in bcm7120_l2_intc_probe()
306 ct->chip.irq_ack = irq_gc_noop; in bcm7120_l2_intc_probe()
307 gc->suspend = bcm7120_l2_intc_suspend; in bcm7120_l2_intc_probe()
308 gc->resume = bcm7120_l2_intc_resume; in bcm7120_l2_intc_probe()
311 * Initialize mask-cache, in case we need it for in bcm7120_l2_intc_probe()
315 gc->mask_cache = irq_reg_readl(gc, ct->regs.mask); in bcm7120_l2_intc_probe()
317 if (data->can_wake) { in bcm7120_l2_intc_probe()
321 gc->wake_enabled = 0xffffffff; in bcm7120_l2_intc_probe()
322 gc->wake_enabled &= ~gc->unused; in bcm7120_l2_intc_probe()
323 ct->chip.irq_set_wake = irq_gc_set_wake; in bcm7120_l2_intc_probe()
327 pr_info("registered %s intc (%pOF, parent IRQ(s): %d)\n", in bcm7120_l2_intc_probe()
328 intc_name, dn, data->num_parent_irqs); in bcm7120_l2_intc_probe()
333 irq_domain_remove(data->domain); in bcm7120_l2_intc_probe()
335 kfree(data->l1_data); in bcm7120_l2_intc_probe()
338 if (data->map_base[idx]) in bcm7120_l2_intc_probe()
339 iounmap(data->map_base[idx]); in bcm7120_l2_intc_probe()
350 "BCM7120 L2"); in bcm7120_l2_intc_probe_7120()
357 "BCM3380 L2"); in bcm7120_l2_intc_probe_3380()
361 IRQCHIP_MATCH("brcm,bcm7120-l2-intc", bcm7120_l2_intc_probe_7120)
362 IRQCHIP_MATCH("brcm,bcm3380-l2-intc", bcm7120_l2_intc_probe_3380)
364 MODULE_DESCRIPTION("Broadcom STB 7120-style L2 interrupt controller driver");