summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLudovic Desroches <ludovic.desroches@microchip.com>2018-09-13 08:42:13 -0400
committerLinus Walleij <linus.walleij@linaro.org>2018-09-14 04:58:54 -0400
commit0c3dfa176912b5f87732545598200fb55e9c1978 (patch)
treeaa6a7078c836d70c7c43d917c29fa872557473f4
parentb97760ae8e3dc8bb91881c13425a0bff55f2bd85 (diff)
pinctrl: at91: don't use the same irqchip with multiple gpiochips
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: Ludovic Desroches <ludovic.desroches@microchip.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/pinctrl-at91.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index cfd8239f2727..911ea0fe2a41 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1574,16 +1574,6 @@ void at91_pinctrl_gpio_resume(void)
1574#define gpio_irq_set_wake NULL 1574#define gpio_irq_set_wake NULL
1575#endif /* CONFIG_PM */ 1575#endif /* CONFIG_PM */
1576 1576
1577static struct irq_chip gpio_irqchip = {
1578 .name = "GPIO",
1579 .irq_ack = gpio_irq_ack,
1580 .irq_disable = gpio_irq_mask,
1581 .irq_mask = gpio_irq_mask,
1582 .irq_unmask = gpio_irq_unmask,
1583 /* .irq_set_type is set dynamically */
1584 .irq_set_wake = gpio_irq_set_wake,
1585};
1586
1587static void gpio_irq_handler(struct irq_desc *desc) 1577static void gpio_irq_handler(struct irq_desc *desc)
1588{ 1578{
1589 struct irq_chip *chip = irq_desc_get_chip(desc); 1579 struct irq_chip *chip = irq_desc_get_chip(desc);
@@ -1624,12 +1614,22 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
1624 struct gpio_chip *gpiochip_prev = NULL; 1614 struct gpio_chip *gpiochip_prev = NULL;
1625 struct at91_gpio_chip *prev = NULL; 1615 struct at91_gpio_chip *prev = NULL;
1626 struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq); 1616 struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq);
1617 struct irq_chip *gpio_irqchip;
1627 int ret, i; 1618 int ret, i;
1628 1619
1620 gpio_irqchip = devm_kzalloc(&pdev->dev, sizeof(*gpio_irqchip), GFP_KERNEL);
1621 if (!gpio_irqchip)
1622 return -ENOMEM;
1623
1629 at91_gpio->pioc_hwirq = irqd_to_hwirq(d); 1624 at91_gpio->pioc_hwirq = irqd_to_hwirq(d);
1630 1625
1631 /* Setup proper .irq_set_type function */ 1626 gpio_irqchip->name = "GPIO";
1632 gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type; 1627 gpio_irqchip->irq_ack = gpio_irq_ack;
1628 gpio_irqchip->irq_disable = gpio_irq_mask;
1629 gpio_irqchip->irq_mask = gpio_irq_mask;
1630 gpio_irqchip->irq_unmask = gpio_irq_unmask;
1631 gpio_irqchip->irq_set_wake = gpio_irq_set_wake,
1632 gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type;
1633 1633
1634 /* Disable irqs of this PIO controller */ 1634 /* Disable irqs of this PIO controller */
1635 writel_relaxed(~0, at91_gpio->regbase + PIO_IDR); 1635 writel_relaxed(~0, at91_gpio->regbase + PIO_IDR);
@@ -1640,7 +1640,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
1640 * interrupt. 1640 * interrupt.
1641 */ 1641 */
1642 ret = gpiochip_irqchip_add(&at91_gpio->chip, 1642 ret = gpiochip_irqchip_add(&at91_gpio->chip,
1643 &gpio_irqchip, 1643 gpio_irqchip,
1644 0, 1644 0,
1645 handle_edge_irq, 1645 handle_edge_irq,
1646 IRQ_TYPE_NONE); 1646 IRQ_TYPE_NONE);
@@ -1658,7 +1658,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
1658 if (!gpiochip_prev) { 1658 if (!gpiochip_prev) {
1659 /* Then register the chain on the parent IRQ */ 1659 /* Then register the chain on the parent IRQ */
1660 gpiochip_set_chained_irqchip(&at91_gpio->chip, 1660 gpiochip_set_chained_irqchip(&at91_gpio->chip,
1661 &gpio_irqchip, 1661 gpio_irqchip,
1662 at91_gpio->pioc_virq, 1662 at91_gpio->pioc_virq,
1663 gpio_irq_handler); 1663 gpio_irq_handler);
1664 return 0; 1664 return 0;