]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/linux/gpio/driver.h
Merge branch 'gpio-irq-validmask' of /home/linus/linux-pinctrl into devel
[linux-beck.git] / include / linux / gpio / driver.h
index bee976f827889d1b7261d44dde499ccaadac5d71..1f0be7213e6dfd6a03da165da1e32d93eab1e7df 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <linux/device.h>
 #include <linux/types.h>
-#include <linux/module.h>
 #include <linux/irq.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqdomain.h>
@@ -16,9 +15,22 @@ struct of_phandle_args;
 struct device_node;
 struct seq_file;
 struct gpio_device;
+struct module;
 
 #ifdef CONFIG_GPIOLIB
 
+/**
+ * enum single_ended_mode - mode for single ended operation
+ * @LINE_MODE_PUSH_PULL: normal mode for a GPIO line, drive actively high/low
+ * @LINE_MODE_OPEN_DRAIN: set line to be open drain
+ * @LINE_MODE_OPEN_SOURCE: set line to be open source
+ */
+enum single_ended_mode {
+       LINE_MODE_PUSH_PULL,
+       LINE_MODE_OPEN_DRAIN,
+       LINE_MODE_OPEN_SOURCE,
+};
+
 /**
  * struct gpio_chip - abstract a GPIO controller
  * @label: a functional name for the GPIO device, such as a part
@@ -38,7 +50,15 @@ struct gpio_device;
  * @set: assigns output value for signal "offset"
  * @set_multiple: assigns output values for multiple signals defined by "mask"
  * @set_debounce: optional hook for setting debounce time for specified gpio in
- *      interrupt triggered gpio chips
+ *     interrupt triggered gpio chips
+ * @set_single_ended: optional hook for setting a line as open drain, open
+ *     source, or non-single ended (restore from open drain/source to normal
+ *     push-pull mode) this should be implemented if the hardware supports
+ *     open drain or open source settings. The GPIOlib will otherwise try
+ *     to emulate open drain/source by not actively driving lines high/low
+ *     if a consumer request this. The driver may return -ENOTSUPP if e.g.
+ *     it supports just open drain but not open source and is called
+ *     with LINE_MODE_OPEN_SOURCE as mode argument.
  * @to_irq: optional hook supporting non-static gpio_to_irq() mappings;
  *     implementation may not sleep
  * @dbg_show: optional routine to show contents in debugfs; default code
@@ -92,6 +112,10 @@ struct gpio_device;
  *     initialization, provided by GPIO driver
  * @irq_parent: GPIO IRQ chip parent/bank linux irq number,
  *     provided by GPIO driver
+ * @irq_need_valid_mask: If set core allocates @irq_valid_mask with all
+ *     bits set to one
+ * @irq_valid_mask: If not %NULL holds bitmask of GPIOs which are valid to
+ *     be included in IRQ domain of the chip
  * @lock_key: per GPIO IRQ chip lockdep class
  *
  * A gpio_chip can help platforms abstract various sources of GPIOs so
@@ -130,6 +154,9 @@ struct gpio_chip {
        int                     (*set_debounce)(struct gpio_chip *chip,
                                                unsigned offset,
                                                unsigned debounce);
+       int                     (*set_single_ended)(struct gpio_chip *chip,
+                                               unsigned offset,
+                                               enum single_ended_mode mode);
 
        int                     (*to_irq)(struct gpio_chip *chip,
                                                unsigned offset);
@@ -167,6 +194,8 @@ struct gpio_chip {
        irq_flow_handler_t      irq_handler;
        unsigned int            irq_default_type;
        int                     irq_parent;
+       bool                    irq_need_valid_mask;
+       unsigned long           *irq_valid_mask;
        struct lock_class_key   *lock_key;
 #endif