Lines Matching +full:single +full:- +full:chip

1 // SPDX-License-Identifier: GPL-2.0
3 * Library implementing the most common irq chip callback functions
22 * irq_gc_noop - NOOP function
30 * irq_gc_mask_disable_reg - Mask chip via disable register
33 * Chip has separate enable/disable registers instead of a single mask
40 u32 mask = d->mask; in irq_gc_mask_disable_reg()
43 irq_reg_writel(gc, mask, ct->regs.disable); in irq_gc_mask_disable_reg()
44 *ct->mask_cache &= ~mask; in irq_gc_mask_disable_reg()
49 * irq_gc_mask_set_bit - Mask chip via setting bit in mask register
52 * Chip has a single mask register. Values of this register are cached
53 * and protected by gc->lock
59 u32 mask = d->mask; in irq_gc_mask_set_bit()
62 *ct->mask_cache |= mask; in irq_gc_mask_set_bit()
63 irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask); in irq_gc_mask_set_bit()
69 * irq_gc_mask_clr_bit - Mask chip via clearing bit in mask register
72 * Chip has a single mask register. Values of this register are cached
73 * and protected by gc->lock
79 u32 mask = d->mask; in irq_gc_mask_clr_bit()
82 *ct->mask_cache &= ~mask; in irq_gc_mask_clr_bit()
83 irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask); in irq_gc_mask_clr_bit()
89 * irq_gc_unmask_enable_reg - Unmask chip via enable register
92 * Chip has separate enable/disable registers instead of a single mask
99 u32 mask = d->mask; in irq_gc_unmask_enable_reg()
102 irq_reg_writel(gc, mask, ct->regs.enable); in irq_gc_unmask_enable_reg()
103 *ct->mask_cache |= mask; in irq_gc_unmask_enable_reg()
108 * irq_gc_ack_set_bit - Ack pending interrupt via setting bit
115 u32 mask = d->mask; in irq_gc_ack_set_bit()
118 irq_reg_writel(gc, mask, ct->regs.ack); in irq_gc_ack_set_bit()
124 * irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit
131 u32 mask = ~d->mask; in irq_gc_ack_clr_bit()
134 irq_reg_writel(gc, mask, ct->regs.ack); in irq_gc_ack_clr_bit()
139 * irq_gc_mask_disable_and_ack_set - Mask and ack pending interrupt
143 * with separate enable/disable registers instead of a single mask
154 u32 mask = d->mask; in irq_gc_mask_disable_and_ack_set()
157 irq_reg_writel(gc, mask, ct->regs.disable); in irq_gc_mask_disable_and_ack_set()
158 *ct->mask_cache &= ~mask; in irq_gc_mask_disable_and_ack_set()
159 irq_reg_writel(gc, mask, ct->regs.ack); in irq_gc_mask_disable_and_ack_set()
164 * irq_gc_eoi - EOI interrupt
171 u32 mask = d->mask; in irq_gc_eoi()
174 irq_reg_writel(gc, mask, ct->regs.eoi); in irq_gc_eoi()
179 * irq_gc_set_wake - Set/clr wake bit for an interrupt
190 u32 mask = d->mask; in irq_gc_set_wake()
192 if (!(mask & gc->wake_enabled)) in irq_gc_set_wake()
193 return -EINVAL; in irq_gc_set_wake()
197 gc->wake_active |= mask; in irq_gc_set_wake()
199 gc->wake_active &= ~mask; in irq_gc_set_wake()
218 raw_spin_lock_init(&gc->lock); in irq_init_generic_chip()
219 gc->num_ct = num_ct; in irq_init_generic_chip()
220 gc->irq_base = irq_base; in irq_init_generic_chip()
221 gc->reg_base = reg_base; in irq_init_generic_chip()
222 gc->chip_types->chip.name = name; in irq_init_generic_chip()
223 gc->chip_types->handler = handler; in irq_init_generic_chip()
227 * irq_alloc_generic_chip - Allocate a generic chip and initialize it
228 * @name: Name of the irq chip
230 * @irq_base: Interrupt base nr for this chip
232 * @handler: Default flow handler associated with this chip
234 * Returns an initialized irq_chip_generic structure. The chip defaults
256 struct irq_chip_type *ct = gc->chip_types; in irq_gc_init_mask_cache()
257 u32 *mskptr = &gc->mask_cache, mskreg = ct->regs.mask; in irq_gc_init_mask_cache()
260 for (i = 0; i < gc->num_ct; i++) { in irq_gc_init_mask_cache()
272 * __irq_alloc_domain_generic_chip - Allocate generic chips for an irq domain
274 * @irqs_per_chip: Number of interrupts each chip handles (max 32)
276 * @name: Name of the irq chip
280 * @gcflags: Generic chip specific setup flags
294 if (d->gc) in __irq_alloc_domain_generic_chips()
295 return -EBUSY; in __irq_alloc_domain_generic_chips()
297 numchips = DIV_ROUND_UP(d->revmap_size, irqs_per_chip); in __irq_alloc_domain_generic_chips()
299 return -EINVAL; in __irq_alloc_domain_generic_chips()
301 /* Allocate a pointer, generic chip and chiptypes for each chip */ in __irq_alloc_domain_generic_chips()
307 return -ENOMEM; in __irq_alloc_domain_generic_chips()
308 dgc->irqs_per_chip = irqs_per_chip; in __irq_alloc_domain_generic_chips()
309 dgc->num_chips = numchips; in __irq_alloc_domain_generic_chips()
310 dgc->irq_flags_to_set = set; in __irq_alloc_domain_generic_chips()
311 dgc->irq_flags_to_clear = clr; in __irq_alloc_domain_generic_chips()
312 dgc->gc_flags = gcflags; in __irq_alloc_domain_generic_chips()
313 d->gc = dgc; in __irq_alloc_domain_generic_chips()
315 /* Calc pointer to the first generic chip */ in __irq_alloc_domain_generic_chips()
318 /* Store the pointer to the generic chip */ in __irq_alloc_domain_generic_chips()
319 dgc->gc[i] = gc = tmp; in __irq_alloc_domain_generic_chips()
323 gc->domain = d; in __irq_alloc_domain_generic_chips()
325 gc->reg_readl = &irq_readl_be; in __irq_alloc_domain_generic_chips()
326 gc->reg_writel = &irq_writel_be; in __irq_alloc_domain_generic_chips()
330 list_add_tail(&gc->list, &gc_list); in __irq_alloc_domain_generic_chips()
332 /* Calc pointer to the next generic chip */ in __irq_alloc_domain_generic_chips()
342 struct irq_domain_chip_generic *dgc = d->gc; in __irq_get_domain_generic_chip()
346 return ERR_PTR(-ENODEV); in __irq_get_domain_generic_chip()
347 idx = hw_irq / dgc->irqs_per_chip; in __irq_get_domain_generic_chip()
348 if (idx >= dgc->num_chips) in __irq_get_domain_generic_chip()
349 return ERR_PTR(-EINVAL); in __irq_get_domain_generic_chip()
350 return dgc->gc[idx]; in __irq_get_domain_generic_chip()
354 * irq_get_domain_generic_chip - Get a pointer to the generic chip of a hw_irq
368 * Separate lockdep classes for interrupt chip which can nest irq_desc
375 * irq_map_generic_chip - Map a generic chip for an irq domain
381 struct irq_domain_chip_generic *dgc = d->gc; in irq_map_generic_chip()
384 struct irq_chip *chip; in irq_map_generic_chip() local
392 idx = hw_irq % dgc->irqs_per_chip; in irq_map_generic_chip()
394 if (test_bit(idx, &gc->unused)) in irq_map_generic_chip()
395 return -ENOTSUPP; in irq_map_generic_chip()
397 if (test_bit(idx, &gc->installed)) in irq_map_generic_chip()
398 return -EBUSY; in irq_map_generic_chip()
400 ct = gc->chip_types; in irq_map_generic_chip()
401 chip = &ct->chip; in irq_map_generic_chip()
403 /* We only init the cache for the first mapping of a generic chip */ in irq_map_generic_chip()
404 if (!gc->installed) { in irq_map_generic_chip()
405 raw_spin_lock_irqsave(&gc->lock, flags); in irq_map_generic_chip()
406 irq_gc_init_mask_cache(gc, dgc->gc_flags); in irq_map_generic_chip()
407 raw_spin_unlock_irqrestore(&gc->lock, flags); in irq_map_generic_chip()
411 set_bit(idx, &gc->installed); in irq_map_generic_chip()
413 if (dgc->gc_flags & IRQ_GC_INIT_NESTED_LOCK) in irq_map_generic_chip()
417 if (chip->irq_calc_mask) in irq_map_generic_chip()
418 chip->irq_calc_mask(data); in irq_map_generic_chip()
420 data->mask = 1 << idx; in irq_map_generic_chip()
422 irq_domain_set_info(d, virq, hw_irq, chip, gc, ct->handler, NULL, NULL); in irq_map_generic_chip()
423 irq_modify_status(virq, dgc->irq_flags_to_clear, dgc->irq_flags_to_set); in irq_map_generic_chip()
430 struct irq_domain_chip_generic *dgc = d->gc; in irq_unmap_generic_chip()
431 unsigned int hw_irq = data->hwirq; in irq_unmap_generic_chip()
439 irq_idx = hw_irq % dgc->irqs_per_chip; in irq_unmap_generic_chip()
441 clear_bit(irq_idx, &gc->installed); in irq_unmap_generic_chip()
455 * irq_setup_generic_chip - Setup a range of interrupts with a generic chip
456 * @gc: Generic irq chip holding all data
457 * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base
462 * Set up max. 32 interrupts starting from gc->irq_base. Note, this
470 struct irq_chip_type *ct = gc->chip_types; in irq_setup_generic_chip()
471 struct irq_chip *chip = &ct->chip; in irq_setup_generic_chip() local
475 list_add_tail(&gc->list, &gc_list); in irq_setup_generic_chip()
480 for (i = gc->irq_base; msk; msk >>= 1, i++) { in irq_setup_generic_chip()
491 if (chip->irq_calc_mask) in irq_setup_generic_chip()
492 chip->irq_calc_mask(d); in irq_setup_generic_chip()
494 d->mask = 1 << (i - gc->irq_base); in irq_setup_generic_chip()
496 irq_set_chip_and_handler(i, chip, ct->handler); in irq_setup_generic_chip()
500 gc->irq_cnt = i - gc->irq_base; in irq_setup_generic_chip()
505 * irq_setup_alt_chip - Switch to alternative chip
509 * Only to be called from chip->irq_set_type() callbacks.
514 struct irq_chip_type *ct = gc->chip_types; in irq_setup_alt_chip()
517 for (i = 0; i < gc->num_ct; i++, ct++) { in irq_setup_alt_chip()
518 if (ct->type & type) { in irq_setup_alt_chip()
519 d->chip = &ct->chip; in irq_setup_alt_chip()
520 irq_data_to_desc(d)->handle_irq = ct->handler; in irq_setup_alt_chip()
524 return -EINVAL; in irq_setup_alt_chip()
529 * irq_remove_generic_chip - Remove a chip
530 * @gc: Generic irq chip holding all data
531 * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base
535 * Remove up to 32 interrupts starting from gc->irq_base.
540 unsigned int i = gc->irq_base; in irq_remove_generic_chip()
543 list_del(&gc->list); in irq_remove_generic_chip()
563 if (!gc->domain) in irq_gc_get_irq_data()
564 return irq_get_irq_data(gc->irq_base); in irq_gc_get_irq_data()
570 if (!gc->installed) in irq_gc_get_irq_data()
573 virq = irq_find_mapping(gc->domain, gc->irq_base + __ffs(gc->installed)); in irq_gc_get_irq_data()
583 struct irq_chip_type *ct = gc->chip_types; in irq_gc_suspend()
585 if (ct->chip.irq_suspend) { in irq_gc_suspend()
589 ct->chip.irq_suspend(data); in irq_gc_suspend()
592 if (gc->suspend) in irq_gc_suspend()
593 gc->suspend(gc); in irq_gc_suspend()
603 struct irq_chip_type *ct = gc->chip_types; in irq_gc_resume()
605 if (gc->resume) in irq_gc_resume()
606 gc->resume(gc); in irq_gc_resume()
608 if (ct->chip.irq_resume) { in irq_gc_resume()
612 ct->chip.irq_resume(data); in irq_gc_resume()
626 struct irq_chip_type *ct = gc->chip_types; in irq_gc_shutdown()
628 if (ct->chip.irq_pm_shutdown) { in irq_gc_shutdown()
632 ct->chip.irq_pm_shutdown(data); in irq_gc_shutdown()