Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0989aa65 authored by Ludovic Desroches's avatar Ludovic Desroches Committed by Greg Kroah-Hartman
Browse files

pinctrl: at91: don't use the same irqchip with multiple gpiochips



[ Upstream commit 0c3dfa176912b5f87732545598200fb55e9c1978 ]

Sharing the same irqchip with multiple gpiochips is not a good
practice. For instance, when installing hooks, we change the state
of the irqchip. The initial state of the irqchip for the second
gpiochip to register is then disrupted.

Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent d1b9d321
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -1574,16 +1574,6 @@ void at91_pinctrl_gpio_resume(void)
#define gpio_irq_set_wake	NULL
#endif /* CONFIG_PM */

static struct irq_chip gpio_irqchip = {
	.name		= "GPIO",
	.irq_ack	= gpio_irq_ack,
	.irq_disable	= gpio_irq_mask,
	.irq_mask	= gpio_irq_mask,
	.irq_unmask	= gpio_irq_unmask,
	/* .irq_set_type is set dynamically */
	.irq_set_wake	= gpio_irq_set_wake,
};

static void gpio_irq_handler(struct irq_desc *desc)
{
	struct irq_chip *chip = irq_desc_get_chip(desc);
@@ -1624,12 +1614,22 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
	struct gpio_chip	*gpiochip_prev = NULL;
	struct at91_gpio_chip   *prev = NULL;
	struct irq_data		*d = irq_get_irq_data(at91_gpio->pioc_virq);
	struct irq_chip		*gpio_irqchip;
	int ret, i;

	gpio_irqchip = devm_kzalloc(&pdev->dev, sizeof(*gpio_irqchip), GFP_KERNEL);
	if (!gpio_irqchip)
		return -ENOMEM;

	at91_gpio->pioc_hwirq = irqd_to_hwirq(d);

	/* Setup proper .irq_set_type function */
	gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
	gpio_irqchip->name = "GPIO";
	gpio_irqchip->irq_ack = gpio_irq_ack;
	gpio_irqchip->irq_disable = gpio_irq_mask;
	gpio_irqchip->irq_mask = gpio_irq_mask;
	gpio_irqchip->irq_unmask = gpio_irq_unmask;
	gpio_irqchip->irq_set_wake = gpio_irq_set_wake,
	gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type;

	/* Disable irqs of this PIO controller */
	writel_relaxed(~0, at91_gpio->regbase + PIO_IDR);
@@ -1640,7 +1640,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
	 * interrupt.
	 */
	ret = gpiochip_irqchip_add(&at91_gpio->chip,
				   &gpio_irqchip,
				   gpio_irqchip,
				   0,
				   handle_edge_irq,
				   IRQ_TYPE_NONE);
@@ -1658,7 +1658,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
	if (!gpiochip_prev) {
		/* Then register the chain on the parent IRQ */
		gpiochip_set_chained_irqchip(&at91_gpio->chip,
					     &gpio_irqchip,
					     gpio_irqchip,
					     at91_gpio->pioc_virq,
					     gpio_irq_handler);
		return 0;