/** * irq_gc_mask_set_bit - Mask chip via setting bit in mask register * @d: irq_data * * Chip has a single mask register. Values of this register are cached * and protected by gc->lock
*/ void irq_gc_mask_set_bit(struct irq_data *d)
{ struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
/** * irq_gc_mask_clr_bit - Mask chip via clearing bit in mask register * @d: irq_data * * Chip has a single mask register. Values of this register are cached * and protected by gc->lock
*/ void irq_gc_mask_clr_bit(struct irq_data *d)
{ struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
/** * irq_gc_mask_disable_and_ack_set - Mask and ack pending interrupt * @d: irq_data * * This generic implementation of the irq_mask_ack method is for chips * with separate enable/disable registers instead of a single mask * register and where a pending interrupt is acknowledged by setting a * bit. * * Note: This is the only permutation currently used. Similar generic * functions should be added here if other permutations are required.
*/ void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
{ struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
/** * irq_gc_set_wake - Set/clr wake bit for an interrupt * @d: irq_data * @on: Indicates whether the wake bit should be set or cleared * * For chips where the wake from suspend functionality is not * configured in a separate register and the wakeup active state is * just stored in a bitmask.
*/ int irq_gc_set_wake(struct irq_data *d, unsignedint on)
{ struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
u32 mask = d->mask;
raw_spin_lock_init(&gc->lock);
gc->num_ct = num_ct;
gc->irq_base = irq_base;
gc->reg_base = reg_base; for (i = 0; i < num_ct; i++)
ct[i].chip.name = name;
gc->chip_types->handler = handler;
}
/** * irq_alloc_generic_chip - Allocate a generic chip and initialize it * @name: Name of the irq chip * @num_ct: Number of irq_chip_type instances associated with this * @irq_base: Interrupt base nr for this chip * @reg_base: Register base address (virtual) * @handler: Default flow handler associated with this chip * * Returns an initialized irq_chip_generic structure. The chip defaults * to the primary (index 0) irq_chip_type and @handler
*/ struct irq_chip_generic *
irq_alloc_generic_chip(constchar *name, int num_ct, unsignedint irq_base, void __iomem *reg_base, irq_flow_handler_t handler)
{ struct irq_chip_generic *gc;
/* Calc pointer to the first generic chip */
tmp += dgc_sz; for (i = 0; i < numchips; i++) { /* Store the pointer to the generic chip */
dgc->gc[i] = gc = tmp;
irq_init_generic_chip(gc, info->name, info->num_ct,
i * dgc->irqs_per_chip, NULL,
info->handler);
if (info->init) {
ret = info->init(gc); if (ret) goto err;
}
scoped_guard (raw_spinlock_irqsave, &gc_lock)
list_add_tail(&gc->list, &gc_list); /* Calc pointer to the next generic chip */
tmp += gc_sz;
} return 0;
err: while (i--) { if (dgc->exit)
dgc->exit(dgc->gc[i]);
irq_remove_generic_chip(dgc->gc[i], ~0U, 0, 0);
}
d->gc = NULL;
kfree(dgc); return ret;
}
EXPORT_SYMBOL_GPL(irq_domain_alloc_generic_chips);
/** * irq_domain_remove_generic_chips - Remove generic chips from an irq domain * @d: irq domain for which generic chips are to be removed
*/ void irq_domain_remove_generic_chips(struct irq_domain *d)
{ struct irq_domain_chip_generic *dgc = d->gc; unsignedint i;
if (!dgc) return;
for (i = 0; i < dgc->num_chips; i++) { if (dgc->exit)
dgc->exit(dgc->gc[i]);
irq_remove_generic_chip(dgc->gc[i], ~0U, 0, 0);
}
d->gc = NULL;
kfree(dgc);
}
EXPORT_SYMBOL_GPL(irq_domain_remove_generic_chips);
/** * __irq_alloc_domain_generic_chips - Allocate generic chips for an irq domain * @d: irq domain for which to allocate chips * @irqs_per_chip: Number of interrupts each chip handles (max 32) * @num_ct: Number of irq_chip_type instances associated with this * @name: Name of the irq chip * @handler: Default flow handler associated with these chips * @clr: IRQ_* bits to clear in the mapping function * @set: IRQ_* bits to set in the mapping function * @gcflags: Generic chip specific setup flags
*/ int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, int num_ct, constchar *name,
irq_flow_handler_t handler, unsignedint clr, unsignedint set, enum irq_gc_flags gcflags)
{ struct irq_domain_chip_generic_info info = {
.irqs_per_chip = irqs_per_chip,
.num_ct = num_ct,
.name = name,
.handler = handler,
.irq_flags_to_clear = clr,
.irq_flags_to_set = set,
.gc_flags = gcflags,
};
/* * Separate lockdep classes for interrupt chip which can nest irq_desc * lock and request mutex.
*/ staticstruct lock_class_key irq_nested_lock_class; staticstruct lock_class_key irq_nested_request_class;
/* * irq_map_generic_chip - Map a generic chip for an irq domain
*/ int irq_map_generic_chip(struct irq_domain *d, unsignedint virq,
irq_hw_number_t hw_irq)
{ struct irq_data *data = irq_domain_get_irq_data(d, virq); struct irq_domain_chip_generic *dgc = d->gc; struct irq_chip_generic *gc; struct irq_chip_type *ct; struct irq_chip *chip; int idx;
gc = __irq_get_domain_generic_chip(d, hw_irq); if (IS_ERR(gc)) return PTR_ERR(gc);
idx = hw_irq % dgc->irqs_per_chip;
if (test_bit(idx, &gc->unused)) return -ENOTSUPP;
if (test_bit(idx, &gc->installed)) return -EBUSY;
ct = gc->chip_types;
chip = &ct->chip;
/* We only init the cache for the first mapping of a generic chip */ if (!gc->installed) {
guard(raw_spinlock_irqsave)(&gc->lock);
irq_gc_init_mask_cache(gc, dgc->gc_flags);
}
/* Mark the interrupt as installed */
set_bit(idx, &gc->installed);
if (dgc->gc_flags & IRQ_GC_INIT_NESTED_LOCK)
irq_set_lockdep_class(virq, &irq_nested_lock_class,
&irq_nested_request_class);
if (chip->irq_calc_mask)
chip->irq_calc_mask(data); else
data->mask = 1 << idx;
/** * irq_setup_generic_chip - Setup a range of interrupts with a generic chip * @gc: Generic irq chip holding all data * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base * @flags: Flags for initialization * @clr: IRQ_* bits to clear * @set: IRQ_* bits to set * * Set up max. 32 interrupts starting from gc->irq_base. Note, this * initializes all interrupts to the primary irq_chip_type and its * associated handler.
*/ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk, enum irq_gc_flags flags, unsignedint clr, unsignedint set)
{ struct irq_chip_type *ct = gc->chip_types; struct irq_chip *chip = &ct->chip; unsignedint i;
for (i = gc->irq_base; msk; msk >>= 1, i++) { if (!(msk & 0x01)) continue;
if (flags & IRQ_GC_INIT_NESTED_LOCK)
irq_set_lockdep_class(i, &irq_nested_lock_class,
&irq_nested_request_class);
if (!(flags & IRQ_GC_NO_MASK)) { struct irq_data *d = irq_get_irq_data(i);
if (chip->irq_calc_mask)
chip->irq_calc_mask(d); else
d->mask = 1 << (i - gc->irq_base);
}
irq_set_chip_and_handler(i, chip, ct->handler);
irq_set_chip_data(i, gc);
irq_modify_status(i, clr, set);
}
gc->irq_cnt = i - gc->irq_base;
}
EXPORT_SYMBOL_GPL(irq_setup_generic_chip);
/** * irq_setup_alt_chip - Switch to alternative chip * @d: irq_data for this interrupt * @type: Flow type to be initialized * * Only to be called from chip->irq_set_type() callbacks.
*/ int irq_setup_alt_chip(struct irq_data *d, unsignedint type)
{ struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); struct irq_chip_type *ct = gc->chip_types; unsignedint i;
for (i = 0; i < gc->num_ct; i++, ct++) { if (ct->type & type) {
d->chip = &ct->chip;
irq_data_to_desc(d)->handle_irq = ct->handler; return 0;
}
} return -EINVAL;
}
EXPORT_SYMBOL_GPL(irq_setup_alt_chip);
/** * irq_remove_generic_chip - Remove a chip * @gc: Generic irq chip holding all data * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base * @clr: IRQ_* bits to clear * @set: IRQ_* bits to set * * Remove up to 32 interrupts starting from gc->irq_base.
*/ void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk, unsignedint clr, unsignedint set)
{ unsignedint i, virq;
for (i = 0; msk; msk >>= 1, i++) { if (!(msk & 0x01)) continue;
/* * Interrupt domain based chips store the base hardware * interrupt number in gc::irq_base. Otherwise gc::irq_base * contains the base Linux interrupt number.
*/ if (gc->domain) {
virq = irq_find_mapping(gc->domain, gc->irq_base + i); if (!virq) continue;
} else {
virq = gc->irq_base + i;
}
/* Remove handler first. That will mask the irq line */
irq_set_handler(virq, NULL);
irq_set_chip(virq, &no_irq_chip);
irq_set_chip_data(virq, NULL);
irq_modify_status(virq, clr, set);
}
}
EXPORT_SYMBOL_GPL(irq_remove_generic_chip);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.