Lines Matching +full:chip +full:- +full:relative
1 // SPDX-License-Identifier: GPL-2.0
3 * Library implementing the most common irq chip callback functions
22 * irq_gc_noop - NOOP function
31 * irq_gc_mask_disable_reg - Mask chip via disable register
34 * Chip has separate enable/disable registers instead of a single mask
41 u32 mask = d->mask; in irq_gc_mask_disable_reg()
44 irq_reg_writel(gc, mask, ct->regs.disable); in irq_gc_mask_disable_reg()
45 *ct->mask_cache &= ~mask; in irq_gc_mask_disable_reg()
51 * irq_gc_mask_set_bit - Mask chip via setting bit in mask register
54 * Chip has a single mask register. Values of this register are cached
55 * and protected by gc->lock
61 u32 mask = d->mask; in irq_gc_mask_set_bit()
64 *ct->mask_cache |= mask; in irq_gc_mask_set_bit()
65 irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask); in irq_gc_mask_set_bit()
71 * irq_gc_mask_clr_bit - Mask chip via clearing bit in mask register
74 * Chip has a single mask register. Values of this register are cached
75 * and protected by gc->lock
81 u32 mask = d->mask; in irq_gc_mask_clr_bit()
84 *ct->mask_cache &= ~mask; in irq_gc_mask_clr_bit()
85 irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask); in irq_gc_mask_clr_bit()
91 * irq_gc_unmask_enable_reg - Unmask chip via enable register
94 * Chip has separate enable/disable registers instead of a single mask
101 u32 mask = d->mask; in irq_gc_unmask_enable_reg()
104 irq_reg_writel(gc, mask, ct->regs.enable); in irq_gc_unmask_enable_reg()
105 *ct->mask_cache |= mask; in irq_gc_unmask_enable_reg()
111 * irq_gc_ack_set_bit - Ack pending interrupt via setting bit
118 u32 mask = d->mask; in irq_gc_ack_set_bit()
121 irq_reg_writel(gc, mask, ct->regs.ack); in irq_gc_ack_set_bit()
127 * irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit
134 u32 mask = ~d->mask; in irq_gc_ack_clr_bit()
137 irq_reg_writel(gc, mask, ct->regs.ack); in irq_gc_ack_clr_bit()
142 * irq_gc_mask_disable_and_ack_set - Mask and ack pending interrupt
157 u32 mask = d->mask; in irq_gc_mask_disable_and_ack_set()
160 irq_reg_writel(gc, mask, ct->regs.disable); in irq_gc_mask_disable_and_ack_set()
161 *ct->mask_cache &= ~mask; in irq_gc_mask_disable_and_ack_set()
162 irq_reg_writel(gc, mask, ct->regs.ack); in irq_gc_mask_disable_and_ack_set()
167 * irq_gc_eoi - EOI interrupt
174 u32 mask = d->mask; in irq_gc_eoi()
177 irq_reg_writel(gc, mask, ct->regs.eoi); in irq_gc_eoi()
182 * irq_gc_set_wake - Set/clr wake bit for an interrupt
193 u32 mask = d->mask; in irq_gc_set_wake()
195 if (!(mask & gc->wake_enabled)) in irq_gc_set_wake()
196 return -EINVAL; in irq_gc_set_wake()
200 gc->wake_active |= mask; in irq_gc_set_wake()
202 gc->wake_active &= ~mask; in irq_gc_set_wake()
222 raw_spin_lock_init(&gc->lock); in irq_init_generic_chip()
223 gc->num_ct = num_ct; in irq_init_generic_chip()
224 gc->irq_base = irq_base; in irq_init_generic_chip()
225 gc->reg_base = reg_base; in irq_init_generic_chip()
226 gc->chip_types->chip.name = name; in irq_init_generic_chip()
227 gc->chip_types->handler = handler; in irq_init_generic_chip()
231 * irq_alloc_generic_chip - Allocate a generic chip and initialize it
232 * @name: Name of the irq chip
234 * @irq_base: Interrupt base nr for this chip
236 * @handler: Default flow handler associated with this chip
238 * Returns an initialized irq_chip_generic structure. The chip defaults
259 struct irq_chip_type *ct = gc->chip_types; in irq_gc_init_mask_cache()
260 u32 *mskptr = &gc->mask_cache, mskreg = ct->regs.mask; in irq_gc_init_mask_cache()
263 for (i = 0; i < gc->num_ct; i++) { in irq_gc_init_mask_cache()
275 * __irq_alloc_domain_generic_chips - Allocate generic chips for an irq domain
277 * @irqs_per_chip: Number of interrupts each chip handles (max 32)
279 * @name: Name of the irq chip
283 * @gcflags: Generic chip specific setup flags
300 if (d->gc) in __irq_alloc_domain_generic_chips()
301 return -EBUSY; in __irq_alloc_domain_generic_chips()
303 numchips = DIV_ROUND_UP(d->revmap_size, irqs_per_chip); in __irq_alloc_domain_generic_chips()
305 return -EINVAL; in __irq_alloc_domain_generic_chips()
307 /* Allocate a pointer, generic chip and chiptypes for each chip */ in __irq_alloc_domain_generic_chips()
314 return -ENOMEM; in __irq_alloc_domain_generic_chips()
315 dgc->irqs_per_chip = irqs_per_chip; in __irq_alloc_domain_generic_chips()
316 dgc->num_chips = numchips; in __irq_alloc_domain_generic_chips()
317 dgc->irq_flags_to_set = set; in __irq_alloc_domain_generic_chips()
318 dgc->irq_flags_to_clear = clr; in __irq_alloc_domain_generic_chips()
319 dgc->gc_flags = gcflags; in __irq_alloc_domain_generic_chips()
320 d->gc = dgc; in __irq_alloc_domain_generic_chips()
322 /* Calc pointer to the first generic chip */ in __irq_alloc_domain_generic_chips()
325 /* Store the pointer to the generic chip */ in __irq_alloc_domain_generic_chips()
326 dgc->gc[i] = gc = tmp; in __irq_alloc_domain_generic_chips()
330 gc->domain = d; in __irq_alloc_domain_generic_chips()
332 gc->reg_readl = &irq_readl_be; in __irq_alloc_domain_generic_chips()
333 gc->reg_writel = &irq_writel_be; in __irq_alloc_domain_generic_chips()
337 list_add_tail(&gc->list, &gc_list); in __irq_alloc_domain_generic_chips()
339 /* Calc pointer to the next generic chip */ in __irq_alloc_domain_generic_chips()
349 struct irq_domain_chip_generic *dgc = d->gc; in __irq_get_domain_generic_chip()
353 return ERR_PTR(-ENODEV); in __irq_get_domain_generic_chip()
354 idx = hw_irq / dgc->irqs_per_chip; in __irq_get_domain_generic_chip()
355 if (idx >= dgc->num_chips) in __irq_get_domain_generic_chip()
356 return ERR_PTR(-EINVAL); in __irq_get_domain_generic_chip()
357 return dgc->gc[idx]; in __irq_get_domain_generic_chip()
361 * irq_get_domain_generic_chip - Get a pointer to the generic chip of a hw_irq
375 * Separate lockdep classes for interrupt chip which can nest irq_desc
382 * irq_map_generic_chip - Map a generic chip for an irq domain
388 struct irq_domain_chip_generic *dgc = d->gc; in irq_map_generic_chip()
391 struct irq_chip *chip; in irq_map_generic_chip() local
399 idx = hw_irq % dgc->irqs_per_chip; in irq_map_generic_chip()
401 if (test_bit(idx, &gc->unused)) in irq_map_generic_chip()
402 return -ENOTSUPP; in irq_map_generic_chip()
404 if (test_bit(idx, &gc->installed)) in irq_map_generic_chip()
405 return -EBUSY; in irq_map_generic_chip()
407 ct = gc->chip_types; in irq_map_generic_chip()
408 chip = &ct->chip; in irq_map_generic_chip()
410 /* We only init the cache for the first mapping of a generic chip */ in irq_map_generic_chip()
411 if (!gc->installed) { in irq_map_generic_chip()
412 raw_spin_lock_irqsave(&gc->lock, flags); in irq_map_generic_chip()
413 irq_gc_init_mask_cache(gc, dgc->gc_flags); in irq_map_generic_chip()
414 raw_spin_unlock_irqrestore(&gc->lock, flags); in irq_map_generic_chip()
418 set_bit(idx, &gc->installed); in irq_map_generic_chip()
420 if (dgc->gc_flags & IRQ_GC_INIT_NESTED_LOCK) in irq_map_generic_chip()
424 if (chip->irq_calc_mask) in irq_map_generic_chip()
425 chip->irq_calc_mask(data); in irq_map_generic_chip()
427 data->mask = 1 << idx; in irq_map_generic_chip()
429 irq_domain_set_info(d, virq, hw_irq, chip, gc, ct->handler, NULL, NULL); in irq_map_generic_chip()
430 irq_modify_status(virq, dgc->irq_flags_to_clear, dgc->irq_flags_to_set); in irq_map_generic_chip()
437 struct irq_domain_chip_generic *dgc = d->gc; in irq_unmap_generic_chip()
438 unsigned int hw_irq = data->hwirq; in irq_unmap_generic_chip()
446 irq_idx = hw_irq % dgc->irqs_per_chip; in irq_unmap_generic_chip()
448 clear_bit(irq_idx, &gc->installed); in irq_unmap_generic_chip()
462 * irq_setup_generic_chip - Setup a range of interrupts with a generic chip
463 * @gc: Generic irq chip holding all data
464 * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base
469 * Set up max. 32 interrupts starting from gc->irq_base. Note, this
477 struct irq_chip_type *ct = gc->chip_types; in irq_setup_generic_chip()
478 struct irq_chip *chip = &ct->chip; in irq_setup_generic_chip() local
482 list_add_tail(&gc->list, &gc_list); in irq_setup_generic_chip()
487 for (i = gc->irq_base; msk; msk >>= 1, i++) { in irq_setup_generic_chip()
498 if (chip->irq_calc_mask) in irq_setup_generic_chip()
499 chip->irq_calc_mask(d); in irq_setup_generic_chip()
501 d->mask = 1 << (i - gc->irq_base); in irq_setup_generic_chip()
503 irq_set_chip_and_handler(i, chip, ct->handler); in irq_setup_generic_chip()
507 gc->irq_cnt = i - gc->irq_base; in irq_setup_generic_chip()
512 * irq_setup_alt_chip - Switch to alternative chip
516 * Only to be called from chip->irq_set_type() callbacks.
521 struct irq_chip_type *ct = gc->chip_types; in irq_setup_alt_chip()
524 for (i = 0; i < gc->num_ct; i++, ct++) { in irq_setup_alt_chip()
525 if (ct->type & type) { in irq_setup_alt_chip()
526 d->chip = &ct->chip; in irq_setup_alt_chip()
527 irq_data_to_desc(d)->handle_irq = ct->handler; in irq_setup_alt_chip()
531 return -EINVAL; in irq_setup_alt_chip()
536 * irq_remove_generic_chip - Remove a chip
537 * @gc: Generic irq chip holding all data
538 * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base
542 * Remove up to 32 interrupts starting from gc->irq_base.
550 list_del(&gc->list); in irq_remove_generic_chip()
562 if (gc->domain) { in irq_remove_generic_chip()
563 virq = irq_find_mapping(gc->domain, gc->irq_base + i); in irq_remove_generic_chip()
567 virq = gc->irq_base + i; in irq_remove_generic_chip()
583 if (!gc->domain) in irq_gc_get_irq_data()
584 return irq_get_irq_data(gc->irq_base); in irq_gc_get_irq_data()
590 if (!gc->installed) in irq_gc_get_irq_data()
593 virq = irq_find_mapping(gc->domain, gc->irq_base + __ffs(gc->installed)); in irq_gc_get_irq_data()
603 struct irq_chip_type *ct = gc->chip_types; in irq_gc_suspend()
605 if (ct->chip.irq_suspend) { in irq_gc_suspend()
609 ct->chip.irq_suspend(data); in irq_gc_suspend()
612 if (gc->suspend) in irq_gc_suspend()
613 gc->suspend(gc); in irq_gc_suspend()
623 struct irq_chip_type *ct = gc->chip_types; in irq_gc_resume()
625 if (gc->resume) in irq_gc_resume()
626 gc->resume(gc); in irq_gc_resume()
628 if (ct->chip.irq_resume) { in irq_gc_resume()
632 ct->chip.irq_resume(data); in irq_gc_resume()
646 struct irq_chip_type *ct = gc->chip_types; in irq_gc_shutdown()
648 if (ct->chip.irq_pm_shutdown) { in irq_gc_shutdown()
652 ct->chip.irq_pm_shutdown(data); in irq_gc_shutdown()