Re: [PATCH v2 4/6] irqchip/irq-pruss-intc: Add helper functions to configure internal mapping

From: David Lechner
Date: Thu Aug 08 2019 - 14:31:19 EST


On 8/8/19 12:09 PM, David Lechner wrote:

Then we can provide a vendor resource hook in the remoteproc driver to handle
these resources:

static int ti_pru_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int offset, int avail)
{
ÂÂÂÂstruct ti_pru_data *pru = rproc->priv;
ÂÂÂÂstruct irq_fwspec fwspec;
ÂÂÂÂunsigned int virq;

ÂÂÂÂswitch (rsc_type) {
ÂÂÂÂcase TI_PRU_VENDOR_RESOURCE_IRQ:
ÂÂÂÂ{
ÂÂÂÂÂÂÂ struct ti_pru_vendor_resource_irq *rsc_irq = rsc;

ÂÂÂÂÂÂÂ fwspec.fwnode = pru->intc_fwnode;
ÂÂÂÂÂÂÂ fwspec.param[0] = le32_to_cpu(rsc_irq->event);
ÂÂÂÂÂÂÂ fwspec.param[1] = le32_to_cpu(rsc_irq->channel);
ÂÂÂÂÂÂÂ fwspec.param[2] = le32_to_cpu(rsc_irq->host);
ÂÂÂÂÂÂÂ fwspec.param[3] = le32_to_cpu(rsc_irq->domain);
ÂÂÂÂÂÂÂ fwspec.param_count = 4;
ÂÂÂÂ}
ÂÂÂÂÂÂÂ break;
ÂÂÂÂcase TI_PRU_VENDOR_RESOURCE_IRQ2:
ÂÂÂÂ{
ÂÂÂÂÂÂÂ struct ti_pru_vendor_resource_irq2 *rsc_irq2 = rsc;

ÂÂÂÂÂÂÂ fwspec.fwnode = pru->intc_fwnode;
ÂÂÂÂÂÂÂ fwspec.param[0] = le32_to_cpu(rsc_irq2->event);
ÂÂÂÂÂÂÂ fwspec.param[1] = le32_to_cpu(rsc_irq2->evt_sel);
ÂÂÂÂÂÂÂ fwspec.param[2] = le32_to_cpu(rsc_irq2->channel);
ÂÂÂÂÂÂÂ fwspec.param[3] = le32_to_cpu(rsc_irq2->host);
ÂÂÂÂÂÂÂ fwspec.param[4] = le32_to_cpu(rsc_irq2->domain);
ÂÂÂÂÂÂÂ fwspec.param_count = 5;
ÂÂÂÂÂÂÂ break;
ÂÂÂÂ}
ÂÂÂÂdefault:
ÂÂÂÂÂÂÂ return RSC_IGNORED;
ÂÂÂÂ}

ÂÂÂÂvirq = irq_create_fwspec_mapping(&fwspec);
ÂÂÂÂif (!virq)
ÂÂÂÂÂÂÂ return -EINVAL;

ÂÂÂÂ/* TODO: save virq (and other metadata) for later use */

ÂÂÂÂreturn RSC_HANDLED;
}

static const struct rproc_ops ti_pru_rproc_ops = {
ÂÂÂÂ.start = ti_pru_rproc_start,
ÂÂÂÂ.stop = ti_pru_rproc_stop,
ÂÂÂÂ.kick = ti_pru_rproc_kick,
ÂÂÂÂ.da_to_va = ti_pru_rproc_da_to_va,
ÂÂÂÂ.handle_rsc = ti_pru_rproc_handle_rsc,
};


After re-reading some of the previous discussions, it sounds like
we wouldn't want to always map every IRQ in the firmware resource
table.

In that case, we could implement the rproc_ops parse_fw callback
instead. All firmware nodes could be collected (from both the
firmware resource table and device tree) and the remoteproc driver
could decide which ones need to be mapped and which ones don't.
Then it could call irq_create_fwspec_mapping() only the nodes
that need to be mapped based on the current application.