gpio: Introduce struct gpio_irq_chip.first
authorThierry Reding <treding@nvidia.com>
Tue, 7 Nov 2017 18:15:58 +0000 (19:15 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 8 Nov 2017 13:17:12 +0000 (14:17 +0100)
Some GPIO chips cannot support sparse IRQ numbering and therefore need
to manually allocate their interrupt descriptors statically. For these
cases, a driver can pass the first allocated IRQ via the struct
gpio_irq_chip's "first" field and thereby cause the IRQ domain to map
all IRQs during initialization.

Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c
include/linux/gpio/driver.h

index 389257f97e457286889429e5d1d8aeacfe0631f4..6d5c366a1378a4bf7798beb9df071fc5c4bc0c1f 100644 (file)
@@ -1778,7 +1778,8 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip)
                ops = &gpiochip_domain_ops;
 
        gpiochip->irq.domain = irq_domain_add_simple(np, gpiochip->ngpio,
-                                                    0, ops, gpiochip);
+                                                    gpiochip->irq.first,
+                                                    ops, gpiochip);
        if (!gpiochip->irq.domain)
                return -EINVAL;
 
index 0a3fdd4d9d8d993e9e39f5bcfae64109a5fb2302..a77d4ada060c8d93a339e87fc823c479ee1f3630 100644 (file)
@@ -128,6 +128,14 @@ struct gpio_irq_chip {
         * in IRQ domain of the chip.
         */
        unsigned long *valid_mask;
+
+       /**
+        * @first:
+        *
+        * Required for static IRQ allocation. If set, irq_domain_add_simple()
+        * will allocate and map all IRQs during initialization.
+        */
+       unsigned int first;
 };
 
 static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip)