Skip to content

Commit

Permalink
pinctrl: armada-37xx: Pass irqchip when adding gpiochip
Browse files Browse the repository at this point in the history
We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip. For more info see
drivers/gpio/TODO.

For chained irqchips this is a pretty straight-forward
conversion.

Cc: Miquel Raynal <[email protected]>
Cc: Gregory CLEMENT <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Thierry Reding <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
linusw committed Oct 16, 2019
1 parent d874bec commit 2851ef5
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
struct device_node *np = info->dev->of_node;
struct gpio_chip *gc = &info->gpio_chip;
struct irq_chip *irqchip = &info->irq_chip;
struct gpio_irq_chip *girq = &gc->irq;
struct device *dev = &pdev->dev;
struct resource res;
int ret = -ENODEV, i, nr_irq_parent;

Expand All @@ -732,19 +734,21 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
break;
}
};
if (ret)
if (ret) {
dev_err(dev, "no gpio-controller child node\n");
return ret;
}

nr_irq_parent = of_irq_count(np);
spin_lock_init(&info->irq_lock);

if (!nr_irq_parent) {
dev_err(&pdev->dev, "Invalid or no IRQ\n");
dev_err(dev, "invalid or no IRQ\n");
return 0;
}

if (of_address_to_resource(info->dev->of_node, 1, &res)) {
dev_err(info->dev, "cannot find IO resource\n");
dev_err(dev, "cannot find IO resource\n");
return -ENOENT;
}

Expand All @@ -759,27 +763,27 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
irqchip->irq_set_type = armada_37xx_irq_set_type;
irqchip->irq_startup = armada_37xx_irq_startup;
irqchip->name = info->data->name;
ret = gpiochip_irqchip_add(gc, irqchip, 0,
handle_edge_irq, IRQ_TYPE_NONE);
if (ret) {
dev_info(&pdev->dev, "could not add irqchip\n");
return ret;
}

girq->chip = irqchip;
girq->parent_handler = armada_37xx_irq_handler;
/*
* Many interrupts are connected to the parent interrupt
* controller. But we do not take advantage of this and use
* the chained irq with all of them.
*/
girq->num_parents = nr_irq_parent;
girq->parents = devm_kcalloc(&pdev->dev, nr_irq_parent,
sizeof(*girq->parents), GFP_KERNEL);
if (!girq->parents)
return -ENOMEM;
for (i = 0; i < nr_irq_parent; i++) {
int irq = irq_of_parse_and_map(np, i);

if (irq < 0)
continue;

gpiochip_set_chained_irqchip(gc, irqchip, irq,
armada_37xx_irq_handler);
girq->parents[i] = irq;
}
girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_edge_irq;

return 0;
}
Expand Down Expand Up @@ -809,10 +813,10 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev,
gc->of_node = np;
gc->label = info->data->name;

ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
ret = armada_37xx_irqchip_register(pdev, info);
if (ret)
return ret;
ret = armada_37xx_irqchip_register(pdev, info);
ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
if (ret)
return ret;

Expand Down

0 comments on commit 2851ef5

Please sign in to comment.