Re: [PATCH 4/4] irq: imx: irqsteer: add multi output interrupts support
From: Lucas Stach
Date: Fri Jan 25 2019 - 05:54:40 EST
Am Freitag, den 18.01.2019, 07:53 +0000 schrieb Aisheng Dong:
> One irqsteer channel can support up to 8 output interrupts.
>
> > Cc: Marc Zyngier <marc.zyngier@xxxxxxx>
> > Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
> > Cc: Shawn Guo <shawnguo@xxxxxxxxxx>
> > Signed-off-by: Dong Aisheng <aisheng.dong@xxxxxxx>
> ---
> Âdrivers/irqchip/irq-imx-irqsteer.c | 39 +++++++++++++++++++++++++++-----------
> Â1 file changed, 28 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/irqchip/irq-imx-irqsteer.c b/drivers/irqchip/irq-imx-irqsteer.c
> index 1bebf0a..54802fa 100644
> --- a/drivers/irqchip/irq-imx-irqsteer.c
> +++ b/drivers/irqchip/irq-imx-irqsteer.c
> @@ -10,6 +10,7 @@
> Â#include <linux/irqchip/chained_irq.h>
> Â#include <linux/irqdomain.h>
> Â#include <linux/kernel.h>
> +#include <linux/of_irq.h>
> Â#include <linux/of_platform.h>
> Â#include <linux/spinlock.h>
> Â
> @@ -21,10 +22,13 @@
> > Â#define CHAN_MINTDIS(t) (CTRL_STRIDE_OFF(t, 3) + 0x4)
> > Â#define CHAN_MASTRSTAT(t) (CTRL_STRIDE_OFF(t, 3) + 0x8)
> Â
> > +#define CHAN_MAX_OUTPUT_INT 0x8
> +
> Âstruct irqsteer_data {
> > > Â void __iomem *regs;
> > > Â struct clk *ipg_clk;
> > > - int irq;
> > > + int irq[CHAN_MAX_OUTPUT_INT];
> > > + int irq_count;
> > > Â raw_spinlock_t lock;
> > > Â int reg_num;
> > > Â int channel;
> @@ -117,7 +121,7 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
> > Â struct device_node *np = pdev->dev.of_node;
> > Â struct irqsteer_data *data;
> > Â struct resource *res;
> > - int ret;
> > + int i, ret;
> Â
> > Â data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> > Â if (!data)
> @@ -130,12 +134,6 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
> > Â return PTR_ERR(data->regs);
> > Â }
> Â
> > - data->irq = platform_get_irq(pdev, 0);
> > - if (data->irq <= 0) {
> > - dev_err(&pdev->dev, "failed to get irq\n");
> > - return -ENODEV;
> > - }
> -
> > Â data->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
> > Â if (IS_ERR(data->ipg_clk)) {
> > Â ret = PTR_ERR(data->ipg_clk);
> @@ -177,8 +175,23 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
> > Â return -ENOMEM;
> > Â }
> Â
> > - irq_set_chained_handler_and_data(data->irq, imx_irqsteer_irq_handler,
> > - Âdata);
> + data->irq_count = of_irq_count(np);
We normally don't validate stuff that comes from the DT, but I guess it
might be helpful to validate that the number of output irqs specified
matches what the number of input irqs, i.e. there is one output irqs
specified for each group of 64 inputs.
> + if (!data->irq_count || data->irq_count > CHAN_MAX_OUTPUT_INT) {
> > + clk_disable_unprepare(data->ipg_clk);
> > + return -EINVAL;
> > + }
> +
> > + for (i = 0; i < data->irq_count; i++) {
> > + data->irq[i] = irq_of_parse_and_map(np, i);
> > + if (!data->irq[i]) {
> > + clk_disable_unprepare(data->ipg_clk);
> > + return -EINVAL;
> > + }
> +
> > + irq_set_chained_handler_and_data(data->irq[i],
> > + Âimx_irqsteer_irq_handler,
> + Âdata);
We really want some data about the output irq being passed here, so we
can cut down the number of register reads in the irq handler to the
maximum of 2 status registers per group.
Regards,
Lucas