Commit 2851ef52 authored by Linus Walleij's avatar Linus Walleij

pinctrl: armada-37xx: Pass irqchip when adding gpiochip

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 <miquel.raynal@bootlin.com>
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: Marek Behún <marek.behun@nic.cz>
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20191002121550.16104-1-linus.walleij@linaro.org
parent d874beca
...@@ -722,6 +722,8 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, ...@@ -722,6 +722,8 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
struct device_node *np = info->dev->of_node; struct device_node *np = info->dev->of_node;
struct gpio_chip *gc = &info->gpio_chip; struct gpio_chip *gc = &info->gpio_chip;
struct irq_chip *irqchip = &info->irq_chip; struct irq_chip *irqchip = &info->irq_chip;
struct gpio_irq_chip *girq = &gc->irq;
struct device *dev = &pdev->dev;
struct resource res; struct resource res;
int ret = -ENODEV, i, nr_irq_parent; int ret = -ENODEV, i, nr_irq_parent;
...@@ -732,19 +734,21 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, ...@@ -732,19 +734,21 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
break; break;
} }
}; };
if (ret) if (ret) {
dev_err(dev, "no gpio-controller child node\n");
return ret; return ret;
}
nr_irq_parent = of_irq_count(np); nr_irq_parent = of_irq_count(np);
spin_lock_init(&info->irq_lock); spin_lock_init(&info->irq_lock);
if (!nr_irq_parent) { if (!nr_irq_parent) {
dev_err(&pdev->dev, "Invalid or no IRQ\n"); dev_err(dev, "invalid or no IRQ\n");
return 0; return 0;
} }
if (of_address_to_resource(info->dev->of_node, 1, &res)) { 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; return -ENOENT;
} }
...@@ -759,27 +763,27 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, ...@@ -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_set_type = armada_37xx_irq_set_type;
irqchip->irq_startup = armada_37xx_irq_startup; irqchip->irq_startup = armada_37xx_irq_startup;
irqchip->name = info->data->name; irqchip->name = info->data->name;
ret = gpiochip_irqchip_add(gc, irqchip, 0, girq->chip = irqchip;
handle_edge_irq, IRQ_TYPE_NONE); girq->parent_handler = armada_37xx_irq_handler;
if (ret) {
dev_info(&pdev->dev, "could not add irqchip\n");
return ret;
}
/* /*
* Many interrupts are connected to the parent interrupt * Many interrupts are connected to the parent interrupt
* controller. But we do not take advantage of this and use * controller. But we do not take advantage of this and use
* the chained irq with all of them. * 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++) { for (i = 0; i < nr_irq_parent; i++) {
int irq = irq_of_parse_and_map(np, i); int irq = irq_of_parse_and_map(np, i);
if (irq < 0) if (irq < 0)
continue; continue;
girq->parents[i] = irq;
gpiochip_set_chained_irqchip(gc, irqchip, irq,
armada_37xx_irq_handler);
} }
girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_edge_irq;
return 0; return 0;
} }
...@@ -809,10 +813,10 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev, ...@@ -809,10 +813,10 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev,
gc->of_node = np; gc->of_node = np;
gc->label = info->data->name; gc->label = info->data->name;
ret = devm_gpiochip_add_data(&pdev->dev, gc, info); ret = armada_37xx_irqchip_register(pdev, info);
if (ret) if (ret)
return ret; return ret;
ret = armada_37xx_irqchip_register(pdev, info); ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment