aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/gpio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-03-25 05:40:18 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-03-26 05:31:21 -0400
commit1425052097b53de841e064dc190a9009480c208c (patch)
tree828f6a7bf6e5903149ea1d34ae9c7ba14a9a6fd8 /include/linux/gpio
parent8f18bcfcd2bc30cb9a5924a6b4af49c8388bc785 (diff)
gpio: add IRQ chip helpers in gpiolib
This provides a function gpiochip_irqchip_add() to set up an irqchip for a GPIO controller, and a function gpiochip_set_chained_irqchip() to chain it to a parent irqchip. Most GPIOs are of the type where a number of lines form a cascaded interrupt controller chained onto the primary system interrupt controller (or further down the chain) so let's add this helper and factor the code to request the lines to be used as IRQs, the .to_irq() function and the irqdomain into the core as well. Acked-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio')
-rw-r--r--include/linux/gpio/driver.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 9fe283642253..c1c5c2368fc8 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -3,6 +3,9 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/irq.h>
7#include <linux/irqchip/chained_irq.h>
8#include <linux/irqdomain.h>
6 9
7struct device; 10struct device;
8struct gpio_desc; 11struct gpio_desc;
@@ -97,6 +100,17 @@ struct gpio_chip {
97 bool can_sleep; 100 bool can_sleep;
98 bool exported; 101 bool exported;
99 102
103#ifdef CONFIG_GPIOLIB_IRQCHIP
104 /*
105 * With CONFIG_GPIO_IRQCHIP we get an irqchip inside the gpiolib
106 * to handle IRQs for most practical cases.
107 */
108 struct irq_chip *irqchip;
109 struct irq_domain *irqdomain;
110 irq_flow_handler_t irq_handler;
111 unsigned int irq_default_type;
112#endif
113
100#if defined(CONFIG_OF_GPIO) 114#if defined(CONFIG_OF_GPIO)
101 /* 115 /*
102 * If CONFIG_OF is enabled, then all GPIO controllers described in the 116 * If CONFIG_OF is enabled, then all GPIO controllers described in the
@@ -190,6 +204,21 @@ struct gpiod_lookup_table {
190 204
191void gpiod_add_lookup_table(struct gpiod_lookup_table *table); 205void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
192 206
207#ifdef CONFIG_GPIOLIB_IRQCHIP
208
209void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
210 struct irq_chip *irqchip,
211 int parent_irq,
212 irq_flow_handler_t parent_handler);
213
214int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
215 struct irq_chip *irqchip,
216 unsigned int first_irq,
217 irq_flow_handler_t handler,
218 unsigned int type);
219
220#endif /* CONFIG_GPIO_IRQCHIP */
221
193#else /* CONFIG_GPIOLIB */ 222#else /* CONFIG_GPIOLIB */
194 223
195static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) 224static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)