diff options
Diffstat (limited to 'include/linux/gpio')
| -rw-r--r-- | include/linux/gpio/consumer.h | 80 | ||||
| -rw-r--r-- | include/linux/gpio/driver.h | 46 | 
2 files changed, 98 insertions, 28 deletions
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 21ddbe440030..f2f887795d43 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -18,10 +18,19 @@ struct device;  struct gpio_desc;  /** + * Opaque descriptor for a structure of GPIO array attributes.  This structure + * is attached to struct gpiod_descs obtained from gpiod_get_array() and can be + * passed back to get/set array functions in order to activate fast processing + * path if applicable. + */ +struct gpio_array; + +/**   * Struct containing an array of descriptors that can be obtained using   * gpiod_get_array().   */  struct gpio_descs { +	struct gpio_array *info;  	unsigned int ndescs;  	struct gpio_desc *desc[];  }; @@ -30,6 +39,7 @@ struct gpio_descs {  #define GPIOD_FLAGS_BIT_DIR_OUT		BIT(1)  #define GPIOD_FLAGS_BIT_DIR_VAL		BIT(2)  #define GPIOD_FLAGS_BIT_OPEN_DRAIN	BIT(3) +#define GPIOD_FLAGS_BIT_NONEXCLUSIVE	BIT(4)  /**   * Optional flags that can be passed to one of gpiod_* to configure direction @@ -104,36 +114,46 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value);  /* Value get/set from non-sleeping context */  int gpiod_get_value(const struct gpio_desc *desc);  int gpiod_get_array_value(unsigned int array_size, -			  struct gpio_desc **desc_array, int *value_array); +			  struct gpio_desc **desc_array, +			  struct gpio_array *array_info, +			  unsigned long *value_bitmap);  void gpiod_set_value(struct gpio_desc *desc, int value); -void gpiod_set_array_value(unsigned int array_size, -			   struct gpio_desc **desc_array, int *value_array); +int gpiod_set_array_value(unsigned int array_size, +			  struct gpio_desc **desc_array, +			  struct gpio_array *array_info, +			  unsigned long *value_bitmap);  int gpiod_get_raw_value(const struct gpio_desc *desc);  int gpiod_get_raw_array_value(unsigned int array_size,  			      struct gpio_desc **desc_array, -			      int *value_array); +			      struct gpio_array *array_info, +			      unsigned long *value_bitmap);  void gpiod_set_raw_value(struct gpio_desc *desc, int value);  int gpiod_set_raw_array_value(unsigned int array_size, -			       struct gpio_desc **desc_array, -			       int *value_array); +			      struct gpio_desc **desc_array, +			      struct gpio_array *array_info, +			      unsigned long *value_bitmap);  /* Value get/set from sleeping context */  int gpiod_get_value_cansleep(const struct gpio_desc *desc);  int gpiod_get_array_value_cansleep(unsigned int array_size,  				   struct gpio_desc **desc_array, -				   int *value_array); +				   struct gpio_array *array_info, +				   unsigned long *value_bitmap);  void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); -void gpiod_set_array_value_cansleep(unsigned int array_size, -				    struct gpio_desc **desc_array, -				    int *value_array); +int gpiod_set_array_value_cansleep(unsigned int array_size, +				   struct gpio_desc **desc_array, +				   struct gpio_array *array_info, +				   unsigned long *value_bitmap);  int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc);  int gpiod_get_raw_array_value_cansleep(unsigned int array_size,  				       struct gpio_desc **desc_array, -				       int *value_array); +				       struct gpio_array *array_info, +				       unsigned long *value_bitmap);  void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value);  int gpiod_set_raw_array_value_cansleep(unsigned int array_size, -					struct gpio_desc **desc_array, -					int *value_array); +				       struct gpio_desc **desc_array, +				       struct gpio_array *array_info, +				       unsigned long *value_bitmap);  int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce);  int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); @@ -330,7 +350,8 @@ static inline int gpiod_get_value(const struct gpio_desc *desc)  }  static inline int gpiod_get_array_value(unsigned int array_size,  					struct gpio_desc **desc_array, -					int *value_array) +					struct gpio_array *array_info, +					unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); @@ -341,12 +362,14 @@ static inline void gpiod_set_value(struct gpio_desc *desc, int value)  	/* GPIO can never have been requested */  	WARN_ON(1);  } -static inline void gpiod_set_array_value(unsigned int array_size, -					 struct gpio_desc **desc_array, -					 int *value_array) +static inline int gpiod_set_array_value(unsigned int array_size, +					struct gpio_desc **desc_array, +					struct gpio_array *array_info, +					unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); +	return 0;  }  static inline int gpiod_get_raw_value(const struct gpio_desc *desc)  { @@ -356,7 +379,8 @@ static inline int gpiod_get_raw_value(const struct gpio_desc *desc)  }  static inline int gpiod_get_raw_array_value(unsigned int array_size,  					    struct gpio_desc **desc_array, -					    int *value_array) +					    struct gpio_array *array_info, +					    unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); @@ -368,8 +392,9 @@ static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value)  	WARN_ON(1);  }  static inline int gpiod_set_raw_array_value(unsigned int array_size, -					     struct gpio_desc **desc_array, -					     int *value_array) +					    struct gpio_desc **desc_array, +					    struct gpio_array *array_info, +					    unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); @@ -384,7 +409,8 @@ static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc)  }  static inline int gpiod_get_array_value_cansleep(unsigned int array_size,  				     struct gpio_desc **desc_array, -				     int *value_array) +				     struct gpio_array *array_info, +				     unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); @@ -395,12 +421,14 @@ static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)  	/* GPIO can never have been requested */  	WARN_ON(1);  } -static inline void gpiod_set_array_value_cansleep(unsigned int array_size, +static inline int gpiod_set_array_value_cansleep(unsigned int array_size,  					    struct gpio_desc **desc_array, -					    int *value_array) +					    struct gpio_array *array_info, +					    unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); +	return 0;  }  static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc)  { @@ -410,7 +438,8 @@ static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc)  }  static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size,  					       struct gpio_desc **desc_array, -					       int *value_array) +					       struct gpio_array *array_info, +					       unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); @@ -424,7 +453,8 @@ static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc,  }  static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size,  						struct gpio_desc **desc_array, -						int *value_array) +						struct gpio_array *array_info, +						unsigned long *value_bitmap)  {  	/* GPIO can never have been requested */  	WARN_ON(1); diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 0ea328e71ec9..2db62b550b95 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -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;  	/** @@ -95,6 +101,13 @@ struct gpio_irq_chip {  	unsigned int num_parents;  	/** +	 * @parent_irq: +	 * +	 * For use by gpiochip_set_cascaded_irqchip() +	 */ +	unsigned int parent_irq; + +	/**  	 * @parents:  	 *  	 * A list of interrupt parents of a GPIO chip. This is owned by the @@ -138,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) @@ -158,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 @@ -256,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; @@ -294,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; @@ -395,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);  | 
