// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2021 Western Digital Corporation or its affiliates. * Copyright (C) 2022 Ventana Micro Systems Inc.
*/
switch (irqd_get_trigger_type(d)) { case IRQ_TYPE_LEVEL_LOW: case IRQ_TYPE_LEVEL_HIGH: /* * The section "4.9.2 Special consideration for level-sensitive interrupt * sources" of the RISC-V AIA specification says: * * A second option is for the interrupt service routine to write the * APLIC’s source identity number for the interrupt to the domain’s * setipnum register just before exiting. This will cause the interrupt’s * pending bit to be set to one again if the source is still asserting * an interrupt, but not if the source is not asserting an interrupt.
*/
writel(d->hwirq, priv->regs + APLIC_SETIPNUM_LE); break;
}
}
staticvoid aplic_msi_irq_eoi(struct irq_data *d)
{ /* * EOI handling is required only for level-triggered interrupts * when APLIC is in MSI mode.
*/
aplic_msi_irq_retrigger_level(d);
}
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM;
rc = aplic_setup_priv(priv, dev, regs); if (rc) {
dev_err(dev, "failed to create APLIC context\n"); return rc;
}
mc = &priv->msicfg;
/* * The APLIC outgoing MSI config registers assume target MSI * controller to be RISC-V AIA IMSIC controller.
*/
imsic_global = imsic_get_global_config(); if (!imsic_global) {
dev_err(dev, "IMSIC global config not found\n"); return -ENODEV;
}
/* Find number of guest index bits (LHXS) */
mc->lhxs = imsic_global->guest_index_bits; if (APLIC_xMSICFGADDRH_LHXS_MASK < mc->lhxs) {
dev_err(dev, "IMSIC guest index bits big for APLIC LHXS\n"); return -EINVAL;
}
/* Find number of HART index bits (LHXW) */
mc->lhxw = imsic_global->hart_index_bits; if (APLIC_xMSICFGADDRH_LHXW_MASK < mc->lhxw) {
dev_err(dev, "IMSIC hart index bits big for APLIC LHXW\n"); return -EINVAL;
}
/* Find number of group index bits (HHXW) */
mc->hhxw = imsic_global->group_index_bits; if (APLIC_xMSICFGADDRH_HHXW_MASK < mc->hhxw) {
dev_err(dev, "IMSIC group index bits big for APLIC HHXW\n"); return -EINVAL;
}
/* Find first bit position of group index (HHXS) */
mc->hhxs = imsic_global->group_index_shift; if (mc->hhxs < (2 * APLIC_xMSICFGADDR_PPN_SHIFT)) {
dev_err(dev, "IMSIC group index shift should be >= %d\n",
(2 * APLIC_xMSICFGADDR_PPN_SHIFT)); return -EINVAL;
}
mc->hhxs -= (2 * APLIC_xMSICFGADDR_PPN_SHIFT); if (APLIC_xMSICFGADDRH_HHXS_MASK < mc->hhxs) {
dev_err(dev, "IMSIC group index shift big for APLIC HHXS\n"); return -EINVAL;
}
/* Setup global config and interrupt delivery */
aplic_init_hw_global(priv, true);
/* Set the APLIC device MSI domain if not available */ if (!dev_get_msi_domain(dev)) { /* * The device MSI domain for OF devices is only set at the * time of populating/creating OF device. If the device MSI * domain is discovered later after the OF device is created * then we need to set it explicitly before using any platform * MSI functions. * * In case of APLIC device, the parent MSI domain is always * IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here.
*/ if (is_of_node(dev->fwnode)) {
of_msi_configure(dev, to_of_node(dev->fwnode));
} else {
msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev),
DOMAIN_BUS_PLATFORM_MSI); if (msi_domain)
dev_set_msi_domain(dev, msi_domain);
}
if (!dev_get_msi_domain(dev)) return -EPROBE_DEFER;
}
if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_template,
priv->nr_irqs + 1, priv, priv)) {
dev_err(dev, "failed to create MSI irq domain\n"); return -ENOMEM;
}
/* Advertise the interrupt controller */
pa = priv->msicfg.base_ppn << APLIC_xMSICFGADDR_PPN_SHIFT;
dev_info(dev, "%d interrupts forwarded to MSI base %pa\n", priv->nr_irqs, &pa);
return 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
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.