Merge tag 'gpio-v4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[sfrench/cifs-2.6.git] / include / linux / gpio / driver.h
index a4d5eb37744ad0ca3e6000814c8a713801e267b9..2db62b550b95a5045b9d386757b173addeb2f3cb 100644 (file)
@@ -66,9 +66,15 @@ struct gpio_irq_chip {
        /**
         * @lock_key:
         *
-        * Per GPIO IRQ chip lockdep classes.
+        * Per GPIO IRQ chip lockdep class for IRQ lock.
         */
        struct lock_class_key *lock_key;
+
+       /**
+        * @request_key:
+        *
+        * Per GPIO IRQ chip lockdep class for IRQ request.
+        */
        struct lock_class_key *request_key;
 
        /**
@@ -145,6 +151,20 @@ struct gpio_irq_chip {
         * will allocate and map all IRQs during initialization.
         */
        unsigned int first;
+
+       /**
+        * @irq_enable:
+        *
+        * Store old irq_chip irq_enable callback
+        */
+       void            (*irq_enable)(struct irq_data *data);
+
+       /**
+        * @irq_disable:
+        *
+        * Store old irq_chip irq_disable callback
+        */
+       void            (*irq_disable)(struct irq_data *data);
 };
 
 static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip)
@@ -165,9 +185,13 @@ static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip)
  * @free: optional hook for chip-specific deactivation, such as
  *     disabling module power and clock; may sleep
  * @get_direction: returns direction for signal "offset", 0=out, 1=in,
- *     (same as GPIOF_DIR_XXX), or negative error
+ *     (same as GPIOF_DIR_XXX), or negative error.
+ *     It is recommended to always implement this function, even on
+ *     input-only or output-only gpio chips.
  * @direction_input: configures signal "offset" as input, or returns error
+ *     This can be omitted on input-only or output-only gpio chips.
  * @direction_output: configures signal "offset" as output, or returns error
+ *     This can be omitted on input-only or output-only gpio chips.
  * @get: returns value for signal "offset", 0=low, 1=high, or negative error
  * @get_multiple: reads values for multiple signals defined by "mask" and
  *     stores them in "bits", returns 0 on success or negative error
@@ -263,6 +287,9 @@ struct gpio_chip {
 
        void                    (*dbg_show)(struct seq_file *s,
                                                struct gpio_chip *chip);
+
+       int                     (*init_valid_mask)(struct gpio_chip *chip);
+
        int                     base;
        u16                     ngpio;
        const char              *const *names;
@@ -301,7 +328,9 @@ struct gpio_chip {
        /**
         * @need_valid_mask:
         *
-        * If set core allocates @valid_mask with all bits set to one.
+        * If set core allocates @valid_mask with all its values initialized
+        * with init_valid_mask() or set to one if init_valid_mask() is not
+        * defined
         */
        bool need_valid_mask;
 
@@ -402,6 +431,10 @@ extern struct gpio_chip *gpiochip_find(void *data,
 int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
 void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
 bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset);
+int gpiochip_reqres_irq(struct gpio_chip *chip, unsigned int offset);
+void gpiochip_relres_irq(struct gpio_chip *chip, unsigned int offset);
+void gpiochip_disable_irq(struct gpio_chip *chip, unsigned int offset);
+void gpiochip_enable_irq(struct gpio_chip *chip, unsigned int offset);
 
 /* Line status inquiry for drivers */
 bool gpiochip_line_is_open_drain(struct gpio_chip *chip, unsigned int offset);