1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 279a9becdSAlexandre Courbot #ifndef __LINUX_GPIO_DRIVER_H 379a9becdSAlexandre Courbot #define __LINUX_GPIO_DRIVER_H 479a9becdSAlexandre Courbot 5ff2b1359SLinus Walleij #include <linux/device.h> 679a9becdSAlexandre Courbot #include <linux/types.h> 714250520SLinus Walleij #include <linux/irq.h> 814250520SLinus Walleij #include <linux/irqchip/chained_irq.h> 914250520SLinus Walleij #include <linux/irqdomain.h> 10a0a8bcf4SGrygorii Strashko #include <linux/lockdep.h> 11964cb341SLinus Walleij #include <linux/pinctrl/pinctrl.h> 122956b5d9SMika Westerberg #include <linux/pinctrl/pinconf-generic.h> 1379a9becdSAlexandre Courbot 1479a9becdSAlexandre Courbot struct gpio_desc; 15c9a9972bSAlexandre Courbot struct of_phandle_args; 16c9a9972bSAlexandre Courbot struct device_node; 17f3ed0b66SStephen Rothwell struct seq_file; 18ff2b1359SLinus Walleij struct gpio_device; 19d47529b2SPaul Gortmaker struct module; 2021abf103SLinus Walleij enum gpiod_flags; 215923ea6cSLinus Walleij enum gpio_lookup_flags; 2279a9becdSAlexandre Courbot 23bb1e88ccSAlexandre Courbot #ifdef CONFIG_GPIOLIB 24bb1e88ccSAlexandre Courbot 25c44eafd7SThierry Reding #ifdef CONFIG_GPIOLIB_IRQCHIP 26fdd61a01SLinus Walleij 27fdd61a01SLinus Walleij struct gpio_chip; 28fdd61a01SLinus Walleij 29c44eafd7SThierry Reding /** 30c44eafd7SThierry Reding * struct gpio_irq_chip - GPIO interrupt controller 31c44eafd7SThierry Reding */ 32c44eafd7SThierry Reding struct gpio_irq_chip { 33c44eafd7SThierry Reding /** 34da80ff81SThierry Reding * @chip: 35da80ff81SThierry Reding * 36da80ff81SThierry Reding * GPIO IRQ chip implementation, provided by GPIO driver. 37da80ff81SThierry Reding */ 38da80ff81SThierry Reding struct irq_chip *chip; 39da80ff81SThierry Reding 40da80ff81SThierry Reding /** 41f0fbe7bcSThierry Reding * @domain: 42f0fbe7bcSThierry Reding * 43f0fbe7bcSThierry Reding * Interrupt translation domain; responsible for mapping between GPIO 44f0fbe7bcSThierry Reding * hwirq number and Linux IRQ number. 45f0fbe7bcSThierry Reding */ 46f0fbe7bcSThierry Reding struct irq_domain *domain; 47f0fbe7bcSThierry Reding 48f0fbe7bcSThierry Reding /** 49c44eafd7SThierry Reding * @domain_ops: 50c44eafd7SThierry Reding * 51c44eafd7SThierry Reding * Table of interrupt domain operations for this IRQ chip. 52c44eafd7SThierry Reding */ 53c44eafd7SThierry Reding const struct irq_domain_ops *domain_ops; 54c44eafd7SThierry Reding 55fdd61a01SLinus Walleij #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY 56fdd61a01SLinus Walleij /** 57fdd61a01SLinus Walleij * @fwnode: 58fdd61a01SLinus Walleij * 59fdd61a01SLinus Walleij * Firmware node corresponding to this gpiochip/irqchip, necessary 60fdd61a01SLinus Walleij * for hierarchical irqdomain support. 61fdd61a01SLinus Walleij */ 62fdd61a01SLinus Walleij struct fwnode_handle *fwnode; 63fdd61a01SLinus Walleij 64fdd61a01SLinus Walleij /** 65fdd61a01SLinus Walleij * @parent_domain: 66fdd61a01SLinus Walleij * 67fdd61a01SLinus Walleij * If non-NULL, will be set as the parent of this GPIO interrupt 68fdd61a01SLinus Walleij * controller's IRQ domain to establish a hierarchical interrupt 69fdd61a01SLinus Walleij * domain. The presence of this will activate the hierarchical 70fdd61a01SLinus Walleij * interrupt support. 71fdd61a01SLinus Walleij */ 72fdd61a01SLinus Walleij struct irq_domain *parent_domain; 73fdd61a01SLinus Walleij 74fdd61a01SLinus Walleij /** 75fdd61a01SLinus Walleij * @child_to_parent_hwirq: 76fdd61a01SLinus Walleij * 77fdd61a01SLinus Walleij * This callback translates a child hardware IRQ offset to a parent 78fdd61a01SLinus Walleij * hardware IRQ offset on a hierarchical interrupt chip. The child 79fdd61a01SLinus Walleij * hardware IRQs correspond to the GPIO index 0..ngpio-1 (see the 80fdd61a01SLinus Walleij * ngpio field of struct gpio_chip) and the corresponding parent 81fdd61a01SLinus Walleij * hardware IRQ and type (such as IRQ_TYPE_*) shall be returned by 82fdd61a01SLinus Walleij * the driver. The driver can calculate this from an offset or using 83fdd61a01SLinus Walleij * a lookup table or whatever method is best for this chip. Return 84fdd61a01SLinus Walleij * 0 on successful translation in the driver. 85fdd61a01SLinus Walleij * 86fdd61a01SLinus Walleij * If some ranges of hardware IRQs do not have a corresponding parent 87fdd61a01SLinus Walleij * HWIRQ, return -EINVAL, but also make sure to fill in @valid_mask and 88fdd61a01SLinus Walleij * @need_valid_mask to make these GPIO lines unavailable for 89fdd61a01SLinus Walleij * translation. 90fdd61a01SLinus Walleij */ 91fdd61a01SLinus Walleij int (*child_to_parent_hwirq)(struct gpio_chip *chip, 92fdd61a01SLinus Walleij unsigned int child_hwirq, 93fdd61a01SLinus Walleij unsigned int child_type, 94fdd61a01SLinus Walleij unsigned int *parent_hwirq, 95fdd61a01SLinus Walleij unsigned int *parent_type); 96fdd61a01SLinus Walleij 97fdd61a01SLinus Walleij /** 98fdd61a01SLinus Walleij * @populate_parent_fwspec: 99fdd61a01SLinus Walleij * 100fdd61a01SLinus Walleij * This optional callback populates the &struct irq_fwspec for the 101fdd61a01SLinus Walleij * parent's IRQ domain. If this is not specified, then 102fdd61a01SLinus Walleij * &gpiochip_populate_parent_fwspec_twocell will be used. A four-cell 103fdd61a01SLinus Walleij * variant named &gpiochip_populate_parent_fwspec_fourcell is also 104fdd61a01SLinus Walleij * available. 105fdd61a01SLinus Walleij */ 106fdd61a01SLinus Walleij void (*populate_parent_fwspec)(struct gpio_chip *chip, 107fdd61a01SLinus Walleij struct irq_fwspec *fwspec, 108fdd61a01SLinus Walleij unsigned int parent_hwirq, 109fdd61a01SLinus Walleij unsigned int parent_type); 110fdd61a01SLinus Walleij 111fdd61a01SLinus Walleij /** 112fdd61a01SLinus Walleij * @child_offset_to_irq: 113fdd61a01SLinus Walleij * 114fdd61a01SLinus Walleij * This optional callback is used to translate the child's GPIO line 115fdd61a01SLinus Walleij * offset on the GPIO chip to an IRQ number for the GPIO to_irq() 116fdd61a01SLinus Walleij * callback. If this is not specified, then a default callback will be 117fdd61a01SLinus Walleij * provided that returns the line offset. 118fdd61a01SLinus Walleij */ 119fdd61a01SLinus Walleij unsigned int (*child_offset_to_irq)(struct gpio_chip *chip, 120fdd61a01SLinus Walleij unsigned int pin); 121fdd61a01SLinus Walleij 122fdd61a01SLinus Walleij /** 123fdd61a01SLinus Walleij * @child_irq_domain_ops: 124fdd61a01SLinus Walleij * 125fdd61a01SLinus Walleij * The IRQ domain operations that will be used for this GPIO IRQ 126fdd61a01SLinus Walleij * chip. If no operations are provided, then default callbacks will 127fdd61a01SLinus Walleij * be populated to setup the IRQ hierarchy. Some drivers need to 128fdd61a01SLinus Walleij * supply their own translate function. 129fdd61a01SLinus Walleij */ 130fdd61a01SLinus Walleij struct irq_domain_ops child_irq_domain_ops; 131fdd61a01SLinus Walleij #endif 132fdd61a01SLinus Walleij 133c44eafd7SThierry Reding /** 134c7a0aa59SThierry Reding * @handler: 135c7a0aa59SThierry Reding * 136c7a0aa59SThierry Reding * The IRQ handler to use (often a predefined IRQ core function) for 137c7a0aa59SThierry Reding * GPIO IRQs, provided by GPIO driver. 138c7a0aa59SThierry Reding */ 139c7a0aa59SThierry Reding irq_flow_handler_t handler; 140c7a0aa59SThierry Reding 141c7a0aa59SThierry Reding /** 1423634eeb0SThierry Reding * @default_type: 1433634eeb0SThierry Reding * 1443634eeb0SThierry Reding * Default IRQ triggering type applied during GPIO driver 1453634eeb0SThierry Reding * initialization, provided by GPIO driver. 1463634eeb0SThierry Reding */ 1473634eeb0SThierry Reding unsigned int default_type; 1483634eeb0SThierry Reding 1493634eeb0SThierry Reding /** 150ca9df053SThierry Reding * @lock_key: 151ca9df053SThierry Reding * 15202ad0437SRandy Dunlap * Per GPIO IRQ chip lockdep class for IRQ lock. 153ca9df053SThierry Reding */ 154ca9df053SThierry Reding struct lock_class_key *lock_key; 15502ad0437SRandy Dunlap 15602ad0437SRandy Dunlap /** 15702ad0437SRandy Dunlap * @request_key: 15802ad0437SRandy Dunlap * 15902ad0437SRandy Dunlap * Per GPIO IRQ chip lockdep class for IRQ request. 16002ad0437SRandy Dunlap */ 16139c3fd58SAndrew Lunn struct lock_class_key *request_key; 162ca9df053SThierry Reding 163ca9df053SThierry Reding /** 164c44eafd7SThierry Reding * @parent_handler: 165c44eafd7SThierry Reding * 166c44eafd7SThierry Reding * The interrupt handler for the GPIO chip's parent interrupts, may be 167c44eafd7SThierry Reding * NULL if the parent interrupts are nested rather than cascaded. 168c44eafd7SThierry Reding */ 169c44eafd7SThierry Reding irq_flow_handler_t parent_handler; 170c44eafd7SThierry Reding 171c44eafd7SThierry Reding /** 172c44eafd7SThierry Reding * @parent_handler_data: 173c44eafd7SThierry Reding * 174c44eafd7SThierry Reding * Data associated, and passed to, the handler for the parent 175c44eafd7SThierry Reding * interrupt. 176c44eafd7SThierry Reding */ 177c44eafd7SThierry Reding void *parent_handler_data; 17839e5f096SThierry Reding 17939e5f096SThierry Reding /** 18039e5f096SThierry Reding * @num_parents: 18139e5f096SThierry Reding * 18239e5f096SThierry Reding * The number of interrupt parents of a GPIO chip. 18339e5f096SThierry Reding */ 18439e5f096SThierry Reding unsigned int num_parents; 18539e5f096SThierry Reding 18639e5f096SThierry Reding /** 18739e5f096SThierry Reding * @parents: 18839e5f096SThierry Reding * 18939e5f096SThierry Reding * A list of interrupt parents of a GPIO chip. This is owned by the 19039e5f096SThierry Reding * driver, so the core will only reference this list, not modify it. 19139e5f096SThierry Reding */ 19239e5f096SThierry Reding unsigned int *parents; 193dc6bafeeSThierry Reding 194dc6bafeeSThierry Reding /** 195e0d89728SThierry Reding * @map: 196e0d89728SThierry Reding * 197e0d89728SThierry Reding * A list of interrupt parents for each line of a GPIO chip. 198e0d89728SThierry Reding */ 199e0d89728SThierry Reding unsigned int *map; 200e0d89728SThierry Reding 201e0d89728SThierry Reding /** 20260ed54caSThierry Reding * @threaded: 203dc6bafeeSThierry Reding * 20460ed54caSThierry Reding * True if set the interrupt handling uses nested threads. 205dc6bafeeSThierry Reding */ 20660ed54caSThierry Reding bool threaded; 207dc7b0387SThierry Reding 208dc7b0387SThierry Reding /** 209dc7b0387SThierry Reding * @need_valid_mask: 210dc7b0387SThierry Reding * 211dc7b0387SThierry Reding * If set core allocates @valid_mask with all bits set to one. 212dc7b0387SThierry Reding */ 213dc7b0387SThierry Reding bool need_valid_mask; 214dc7b0387SThierry Reding 215dc7b0387SThierry Reding /** 216dc7b0387SThierry Reding * @valid_mask: 217dc7b0387SThierry Reding * 218dc7b0387SThierry Reding * If not %NULL holds bitmask of GPIOs which are valid to be included 219dc7b0387SThierry Reding * in IRQ domain of the chip. 220dc7b0387SThierry Reding */ 221dc7b0387SThierry Reding unsigned long *valid_mask; 2228302cf58SThierry Reding 2238302cf58SThierry Reding /** 2248302cf58SThierry Reding * @first: 2258302cf58SThierry Reding * 2268302cf58SThierry Reding * Required for static IRQ allocation. If set, irq_domain_add_simple() 2278302cf58SThierry Reding * will allocate and map all IRQs during initialization. 2288302cf58SThierry Reding */ 2298302cf58SThierry Reding unsigned int first; 230461c1a7dSHans Verkuil 231461c1a7dSHans Verkuil /** 232461c1a7dSHans Verkuil * @irq_enable: 233461c1a7dSHans Verkuil * 234461c1a7dSHans Verkuil * Store old irq_chip irq_enable callback 235461c1a7dSHans Verkuil */ 236461c1a7dSHans Verkuil void (*irq_enable)(struct irq_data *data); 237461c1a7dSHans Verkuil 238461c1a7dSHans Verkuil /** 239461c1a7dSHans Verkuil * @irq_disable: 240461c1a7dSHans Verkuil * 241461c1a7dSHans Verkuil * Store old irq_chip irq_disable callback 242461c1a7dSHans Verkuil */ 243461c1a7dSHans Verkuil void (*irq_disable)(struct irq_data *data); 244c44eafd7SThierry Reding }; 245f310f2efSEnrico Weigelt #endif /* CONFIG_GPIOLIB_IRQCHIP */ 246c44eafd7SThierry Reding 24779a9becdSAlexandre Courbot /** 24879a9becdSAlexandre Courbot * struct gpio_chip - abstract a GPIO controller 249df4878e9SLinus Walleij * @label: a functional name for the GPIO device, such as a part 250df4878e9SLinus Walleij * number or the name of the SoC IP-block implementing it. 251ff2b1359SLinus Walleij * @gpiodev: the internal state holder, opaque struct 25258383c78SLinus Walleij * @parent: optional parent device providing the GPIOs 25379a9becdSAlexandre Courbot * @owner: helps prevent removal of modules exporting active GPIOs 25479a9becdSAlexandre Courbot * @request: optional hook for chip-specific activation, such as 25579a9becdSAlexandre Courbot * enabling module power and clock; may sleep 25679a9becdSAlexandre Courbot * @free: optional hook for chip-specific deactivation, such as 25779a9becdSAlexandre Courbot * disabling module power and clock; may sleep 25879a9becdSAlexandre Courbot * @get_direction: returns direction for signal "offset", 0=out, 1=in, 259e48d194dSLinus Walleij * (same as GPIOF_DIR_XXX), or negative error. 260e48d194dSLinus Walleij * It is recommended to always implement this function, even on 261e48d194dSLinus Walleij * input-only or output-only gpio chips. 26279a9becdSAlexandre Courbot * @direction_input: configures signal "offset" as input, or returns error 263e48d194dSLinus Walleij * This can be omitted on input-only or output-only gpio chips. 26479a9becdSAlexandre Courbot * @direction_output: configures signal "offset" as output, or returns error 265e48d194dSLinus Walleij * This can be omitted on input-only or output-only gpio chips. 26660befd2eSVladimir Zapolskiy * @get: returns value for signal "offset", 0=low, 1=high, or negative error 267eec1d566SLukas Wunner * @get_multiple: reads values for multiple signals defined by "mask" and 268eec1d566SLukas Wunner * stores them in "bits", returns 0 on success or negative error 26979a9becdSAlexandre Courbot * @set: assigns output value for signal "offset" 2705f424243SRojhalat Ibrahim * @set_multiple: assigns output values for multiple signals defined by "mask" 2712956b5d9SMika Westerberg * @set_config: optional hook for all kinds of settings. Uses the same 2722956b5d9SMika Westerberg * packed config format as generic pinconf. 27379a9becdSAlexandre Courbot * @to_irq: optional hook supporting non-static gpio_to_irq() mappings; 27479a9becdSAlexandre Courbot * implementation may not sleep 27579a9becdSAlexandre Courbot * @dbg_show: optional routine to show contents in debugfs; default code 27679a9becdSAlexandre Courbot * will be used when this is omitted, but custom code can show extra 27779a9becdSAlexandre Courbot * state (such as pullup/pulldown configuration). 278f99d479bSGeert Uytterhoeven * @init_valid_mask: optional routine to initialize @valid_mask, to be used if 279f99d479bSGeert Uytterhoeven * not all GPIOs are valid. 280af6c235dSLinus Walleij * @base: identifies the first GPIO number handled by this chip; 281af6c235dSLinus Walleij * or, if negative during registration, requests dynamic ID allocation. 282af6c235dSLinus Walleij * DEPRECATION: providing anything non-negative and nailing the base 28330bb6fb3SGeert Uytterhoeven * offset of GPIO chips is deprecated. Please pass -1 as base to 284af6c235dSLinus Walleij * let gpiolib select the chip base in all possible cases. We want to 285af6c235dSLinus Walleij * get rid of the static GPIO number space in the long run. 28679a9becdSAlexandre Courbot * @ngpio: the number of GPIOs handled by this controller; the last GPIO 28779a9becdSAlexandre Courbot * handled is (base + ngpio - 1). 28879a9becdSAlexandre Courbot * @names: if set, must be an array of strings to use as alternative 28979a9becdSAlexandre Courbot * names for the GPIOs in this chip. Any entry in the array 29079a9becdSAlexandre Courbot * may be NULL if there is no alias for the GPIO, however the 29179a9becdSAlexandre Courbot * array must be @ngpio entries long. A name can include a single printk 29279a9becdSAlexandre Courbot * format specifier for an unsigned int. It is substituted by the actual 29379a9becdSAlexandre Courbot * number of the gpio. 2949fb1f39eSLinus Walleij * @can_sleep: flag must be set iff get()/set() methods sleep, as they 2951c8732bbSLinus Walleij * must while accessing GPIO expander chips over I2C or SPI. This 2961c8732bbSLinus Walleij * implies that if the chip supports IRQs, these IRQs need to be threaded 2971c8732bbSLinus Walleij * as the chip access may sleep when e.g. reading out the IRQ status 2981c8732bbSLinus Walleij * registers. 2990f4630f3SLinus Walleij * @read_reg: reader function for generic GPIO 3000f4630f3SLinus Walleij * @write_reg: writer function for generic GPIO 30124efd94bSLinus Walleij * @be_bits: if the generic GPIO has big endian bit order (bit 31 is representing 30224efd94bSLinus Walleij * line 0, bit 30 is line 1 ... bit 0 is line 31) this is set to true by the 30324efd94bSLinus Walleij * generic GPIO core. It is for internal housekeeping only. 3040f4630f3SLinus Walleij * @reg_dat: data (in) register for generic GPIO 3050f4630f3SLinus Walleij * @reg_set: output set register (out=high) for generic GPIO 30608bcd3edSAnthony Best * @reg_clr: output clear register (out=low) for generic GPIO 307f69e00bdSLinus Walleij * @reg_dir_out: direction out setting register for generic GPIO 308f69e00bdSLinus Walleij * @reg_dir_in: direction in setting register for generic GPIO 309f69e00bdSLinus Walleij * @bgpio_dir_unreadable: indicates that the direction register(s) cannot 310f69e00bdSLinus Walleij * be read and we need to rely on out internal state tracking. 3110f4630f3SLinus Walleij * @bgpio_bits: number of register bits used for a generic GPIO i.e. 3120f4630f3SLinus Walleij * <register width> * 8 3130f4630f3SLinus Walleij * @bgpio_lock: used to lock chip->bgpio_data. Also, this is needed to keep 3140f4630f3SLinus Walleij * shadowed and real data registers writes together. 3150f4630f3SLinus Walleij * @bgpio_data: shadowed data register for generic GPIO to clear/set bits 3160f4630f3SLinus Walleij * safely. 3170f4630f3SLinus Walleij * @bgpio_dir: shadowed direction register for generic GPIO to clear/set 318f69e00bdSLinus Walleij * direction safely. A "1" in this word means the line is set as 319f69e00bdSLinus Walleij * output. 32079a9becdSAlexandre Courbot * 32179a9becdSAlexandre Courbot * A gpio_chip can help platforms abstract various sources of GPIOs so 32279a9becdSAlexandre Courbot * they can all be accessed through a common programing interface. 32379a9becdSAlexandre Courbot * Example sources would be SOC controllers, FPGAs, multifunction 32479a9becdSAlexandre Courbot * chips, dedicated GPIO expanders, and so on. 32579a9becdSAlexandre Courbot * 32679a9becdSAlexandre Courbot * Each chip controls a number of signals, identified in method calls 32779a9becdSAlexandre Courbot * by "offset" values in the range 0..(@ngpio - 1). When those signals 32879a9becdSAlexandre Courbot * are referenced through calls like gpio_get_value(gpio), the offset 32979a9becdSAlexandre Courbot * is calculated by subtracting @base from the gpio number. 33079a9becdSAlexandre Courbot */ 33179a9becdSAlexandre Courbot struct gpio_chip { 33279a9becdSAlexandre Courbot const char *label; 333ff2b1359SLinus Walleij struct gpio_device *gpiodev; 33458383c78SLinus Walleij struct device *parent; 33579a9becdSAlexandre Courbot struct module *owner; 33679a9becdSAlexandre Courbot 33779a9becdSAlexandre Courbot int (*request)(struct gpio_chip *chip, 33879a9becdSAlexandre Courbot unsigned offset); 33979a9becdSAlexandre Courbot void (*free)(struct gpio_chip *chip, 34079a9becdSAlexandre Courbot unsigned offset); 34179a9becdSAlexandre Courbot int (*get_direction)(struct gpio_chip *chip, 34279a9becdSAlexandre Courbot unsigned offset); 34379a9becdSAlexandre Courbot int (*direction_input)(struct gpio_chip *chip, 34479a9becdSAlexandre Courbot unsigned offset); 34579a9becdSAlexandre Courbot int (*direction_output)(struct gpio_chip *chip, 34679a9becdSAlexandre Courbot unsigned offset, int value); 34779a9becdSAlexandre Courbot int (*get)(struct gpio_chip *chip, 34879a9becdSAlexandre Courbot unsigned offset); 349eec1d566SLukas Wunner int (*get_multiple)(struct gpio_chip *chip, 350eec1d566SLukas Wunner unsigned long *mask, 351eec1d566SLukas Wunner unsigned long *bits); 35279a9becdSAlexandre Courbot void (*set)(struct gpio_chip *chip, 35379a9becdSAlexandre Courbot unsigned offset, int value); 3545f424243SRojhalat Ibrahim void (*set_multiple)(struct gpio_chip *chip, 3555f424243SRojhalat Ibrahim unsigned long *mask, 3565f424243SRojhalat Ibrahim unsigned long *bits); 3572956b5d9SMika Westerberg int (*set_config)(struct gpio_chip *chip, 35879a9becdSAlexandre Courbot unsigned offset, 3592956b5d9SMika Westerberg unsigned long config); 36079a9becdSAlexandre Courbot int (*to_irq)(struct gpio_chip *chip, 36179a9becdSAlexandre Courbot unsigned offset); 36279a9becdSAlexandre Courbot 36379a9becdSAlexandre Courbot void (*dbg_show)(struct seq_file *s, 36479a9becdSAlexandre Courbot struct gpio_chip *chip); 365f8ec92a9SRicardo Ribalda Delgado 366f8ec92a9SRicardo Ribalda Delgado int (*init_valid_mask)(struct gpio_chip *chip); 367f8ec92a9SRicardo Ribalda Delgado 36879a9becdSAlexandre Courbot int base; 36979a9becdSAlexandre Courbot u16 ngpio; 37079a9becdSAlexandre Courbot const char *const *names; 3719fb1f39eSLinus Walleij bool can_sleep; 37279a9becdSAlexandre Courbot 3730f4630f3SLinus Walleij #if IS_ENABLED(CONFIG_GPIO_GENERIC) 3740f4630f3SLinus Walleij unsigned long (*read_reg)(void __iomem *reg); 3750f4630f3SLinus Walleij void (*write_reg)(void __iomem *reg, unsigned long data); 37624efd94bSLinus Walleij bool be_bits; 3770f4630f3SLinus Walleij void __iomem *reg_dat; 3780f4630f3SLinus Walleij void __iomem *reg_set; 3790f4630f3SLinus Walleij void __iomem *reg_clr; 380f69e00bdSLinus Walleij void __iomem *reg_dir_out; 381f69e00bdSLinus Walleij void __iomem *reg_dir_in; 382f69e00bdSLinus Walleij bool bgpio_dir_unreadable; 3830f4630f3SLinus Walleij int bgpio_bits; 3840f4630f3SLinus Walleij spinlock_t bgpio_lock; 3850f4630f3SLinus Walleij unsigned long bgpio_data; 3860f4630f3SLinus Walleij unsigned long bgpio_dir; 387f310f2efSEnrico Weigelt #endif /* CONFIG_GPIO_GENERIC */ 3880f4630f3SLinus Walleij 38914250520SLinus Walleij #ifdef CONFIG_GPIOLIB_IRQCHIP 39014250520SLinus Walleij /* 3917d75a871SPaul Bolle * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib 39214250520SLinus Walleij * to handle IRQs for most practical cases. 39314250520SLinus Walleij */ 394c44eafd7SThierry Reding 395c44eafd7SThierry Reding /** 396c44eafd7SThierry Reding * @irq: 397c44eafd7SThierry Reding * 398c44eafd7SThierry Reding * Integrates interrupt chip functionality with the GPIO chip. Can be 399c44eafd7SThierry Reding * used to handle IRQs for most practical cases. 400c44eafd7SThierry Reding */ 401c44eafd7SThierry Reding struct gpio_irq_chip irq; 402f310f2efSEnrico Weigelt #endif /* CONFIG_GPIOLIB_IRQCHIP */ 40314250520SLinus Walleij 404726cb3baSStephen Boyd /** 405726cb3baSStephen Boyd * @need_valid_mask: 406726cb3baSStephen Boyd * 407f8ec92a9SRicardo Ribalda Delgado * If set core allocates @valid_mask with all its values initialized 408f8ec92a9SRicardo Ribalda Delgado * with init_valid_mask() or set to one if init_valid_mask() is not 409f8ec92a9SRicardo Ribalda Delgado * defined 410726cb3baSStephen Boyd */ 411726cb3baSStephen Boyd bool need_valid_mask; 412726cb3baSStephen Boyd 413726cb3baSStephen Boyd /** 414726cb3baSStephen Boyd * @valid_mask: 415726cb3baSStephen Boyd * 416726cb3baSStephen Boyd * If not %NULL holds bitmask of GPIOs which are valid to be used 417726cb3baSStephen Boyd * from the chip. 418726cb3baSStephen Boyd */ 419726cb3baSStephen Boyd unsigned long *valid_mask; 420726cb3baSStephen Boyd 42179a9becdSAlexandre Courbot #if defined(CONFIG_OF_GPIO) 42279a9becdSAlexandre Courbot /* 42379a9becdSAlexandre Courbot * If CONFIG_OF is enabled, then all GPIO controllers described in the 42479a9becdSAlexandre Courbot * device tree automatically may have an OF translation 42579a9becdSAlexandre Courbot */ 42667049c50SThierry Reding 42767049c50SThierry Reding /** 42867049c50SThierry Reding * @of_node: 42967049c50SThierry Reding * 43067049c50SThierry Reding * Pointer to a device tree node representing this GPIO controller. 43167049c50SThierry Reding */ 43279a9becdSAlexandre Courbot struct device_node *of_node; 43367049c50SThierry Reding 43467049c50SThierry Reding /** 43567049c50SThierry Reding * @of_gpio_n_cells: 43667049c50SThierry Reding * 43767049c50SThierry Reding * Number of cells used to form the GPIO specifier. 43867049c50SThierry Reding */ 439e3b445d7SThierry Reding unsigned int of_gpio_n_cells; 44067049c50SThierry Reding 44167049c50SThierry Reding /** 44267049c50SThierry Reding * @of_xlate: 44367049c50SThierry Reding * 44467049c50SThierry Reding * Callback to translate a device tree GPIO specifier into a chip- 44567049c50SThierry Reding * relative GPIO number and flags. 44667049c50SThierry Reding */ 44779a9becdSAlexandre Courbot int (*of_xlate)(struct gpio_chip *gc, 44879a9becdSAlexandre Courbot const struct of_phandle_args *gpiospec, u32 *flags); 449f310f2efSEnrico Weigelt #endif /* CONFIG_OF_GPIO */ 45079a9becdSAlexandre Courbot }; 45179a9becdSAlexandre Courbot 45279a9becdSAlexandre Courbot extern const char *gpiochip_is_requested(struct gpio_chip *chip, 45379a9becdSAlexandre Courbot unsigned offset); 45479a9becdSAlexandre Courbot 45579a9becdSAlexandre Courbot /* add/remove chips */ 456959bc7b2SThierry Reding extern int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, 45739c3fd58SAndrew Lunn struct lock_class_key *lock_key, 45839c3fd58SAndrew Lunn struct lock_class_key *request_key); 459959bc7b2SThierry Reding 460959bc7b2SThierry Reding /** 461959bc7b2SThierry Reding * gpiochip_add_data() - register a gpio_chip 462959bc7b2SThierry Reding * @chip: the chip to register, with chip->base initialized 463959bc7b2SThierry Reding * @data: driver-private data associated with this chip 464959bc7b2SThierry Reding * 465959bc7b2SThierry Reding * Context: potentially before irqs will work 466959bc7b2SThierry Reding * 467959bc7b2SThierry Reding * When gpiochip_add_data() is called very early during boot, so that GPIOs 468959bc7b2SThierry Reding * can be freely used, the chip->parent device must be registered before 469959bc7b2SThierry Reding * the gpio framework's arch_initcall(). Otherwise sysfs initialization 470959bc7b2SThierry Reding * for GPIOs will fail rudely. 471959bc7b2SThierry Reding * 472959bc7b2SThierry Reding * gpiochip_add_data() must only be called after gpiolib initialization, 473959bc7b2SThierry Reding * ie after core_initcall(). 474959bc7b2SThierry Reding * 475959bc7b2SThierry Reding * If chip->base is negative, this requests dynamic assignment of 476959bc7b2SThierry Reding * a range of valid GPIOs. 477959bc7b2SThierry Reding * 478959bc7b2SThierry Reding * Returns: 479959bc7b2SThierry Reding * A negative errno if the chip can't be registered, such as because the 480959bc7b2SThierry Reding * chip->base is invalid or already associated with a different chip. 481959bc7b2SThierry Reding * Otherwise it returns zero as a success code. 482959bc7b2SThierry Reding */ 483959bc7b2SThierry Reding #ifdef CONFIG_LOCKDEP 484959bc7b2SThierry Reding #define gpiochip_add_data(chip, data) ({ \ 48539c3fd58SAndrew Lunn static struct lock_class_key lock_key; \ 48639c3fd58SAndrew Lunn static struct lock_class_key request_key; \ 48739c3fd58SAndrew Lunn gpiochip_add_data_with_key(chip, data, &lock_key, \ 48839c3fd58SAndrew Lunn &request_key); \ 489959bc7b2SThierry Reding }) 490959bc7b2SThierry Reding #else 49139c3fd58SAndrew Lunn #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL, NULL) 492f310f2efSEnrico Weigelt #endif /* CONFIG_LOCKDEP */ 493959bc7b2SThierry Reding 494b08ea35aSLinus Walleij static inline int gpiochip_add(struct gpio_chip *chip) 495b08ea35aSLinus Walleij { 496b08ea35aSLinus Walleij return gpiochip_add_data(chip, NULL); 497b08ea35aSLinus Walleij } 498e1db1706Sabdoulaye berthe extern void gpiochip_remove(struct gpio_chip *chip); 4990cf3292cSLaxman Dewangan extern int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip, 5000cf3292cSLaxman Dewangan void *data); 5010cf3292cSLaxman Dewangan 50279a9becdSAlexandre Courbot extern struct gpio_chip *gpiochip_find(void *data, 50379a9becdSAlexandre Courbot int (*match)(struct gpio_chip *chip, void *data)); 50479a9becdSAlexandre Courbot 50579a9becdSAlexandre Courbot /* lock/unlock as IRQ */ 506e3a2e878SAlexandre Courbot int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset); 507e3a2e878SAlexandre Courbot void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); 5086cee3821SLinus Walleij bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset); 5094e6b8238SHans Verkuil int gpiochip_reqres_irq(struct gpio_chip *chip, unsigned int offset); 5104e6b8238SHans Verkuil void gpiochip_relres_irq(struct gpio_chip *chip, unsigned int offset); 5114e9439ddSHans Verkuil void gpiochip_disable_irq(struct gpio_chip *chip, unsigned int offset); 5124e9439ddSHans Verkuil void gpiochip_enable_irq(struct gpio_chip *chip, unsigned int offset); 51379a9becdSAlexandre Courbot 514143b65d6SLinus Walleij /* Line status inquiry for drivers */ 515143b65d6SLinus Walleij bool gpiochip_line_is_open_drain(struct gpio_chip *chip, unsigned int offset); 516143b65d6SLinus Walleij bool gpiochip_line_is_open_source(struct gpio_chip *chip, unsigned int offset); 517143b65d6SLinus Walleij 51805f479bfSCharles Keepax /* Sleep persistence inquiry for drivers */ 51905f479bfSCharles Keepax bool gpiochip_line_is_persistent(struct gpio_chip *chip, unsigned int offset); 520726cb3baSStephen Boyd bool gpiochip_line_is_valid(const struct gpio_chip *chip, unsigned int offset); 52105f479bfSCharles Keepax 522b08ea35aSLinus Walleij /* get driver data */ 52343c54ecaSLinus Walleij void *gpiochip_get_data(struct gpio_chip *chip); 524b08ea35aSLinus Walleij 525bb1e88ccSAlexandre Courbot struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); 526bb1e88ccSAlexandre Courbot 5270f4630f3SLinus Walleij struct bgpio_pdata { 5280f4630f3SLinus Walleij const char *label; 5290f4630f3SLinus Walleij int base; 5300f4630f3SLinus Walleij int ngpio; 5310f4630f3SLinus Walleij }; 5320f4630f3SLinus Walleij 533fdd61a01SLinus Walleij #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY 534fdd61a01SLinus Walleij 535fdd61a01SLinus Walleij void gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 536fdd61a01SLinus Walleij struct irq_fwspec *fwspec, 537fdd61a01SLinus Walleij unsigned int parent_hwirq, 538fdd61a01SLinus Walleij unsigned int parent_type); 539fdd61a01SLinus Walleij void gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 540fdd61a01SLinus Walleij struct irq_fwspec *fwspec, 541fdd61a01SLinus Walleij unsigned int parent_hwirq, 542fdd61a01SLinus Walleij unsigned int parent_type); 543fdd61a01SLinus Walleij 544fdd61a01SLinus Walleij #else 545fdd61a01SLinus Walleij 546fdd61a01SLinus Walleij static void gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 547fdd61a01SLinus Walleij struct irq_fwspec *fwspec, 548fdd61a01SLinus Walleij unsigned int parent_hwirq, 549fdd61a01SLinus Walleij unsigned int parent_type) 550fdd61a01SLinus Walleij { 551fdd61a01SLinus Walleij } 552fdd61a01SLinus Walleij 553fdd61a01SLinus Walleij static void gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 554fdd61a01SLinus Walleij struct irq_fwspec *fwspec, 555fdd61a01SLinus Walleij unsigned int parent_hwirq, 556fdd61a01SLinus Walleij unsigned int parent_type) 557fdd61a01SLinus Walleij { 558fdd61a01SLinus Walleij } 559fdd61a01SLinus Walleij 560fdd61a01SLinus Walleij #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ 561fdd61a01SLinus Walleij 562fdd61a01SLinus Walleij 563c474e348SArnd Bergmann #if IS_ENABLED(CONFIG_GPIO_GENERIC) 564c474e348SArnd Bergmann 5650f4630f3SLinus Walleij int bgpio_init(struct gpio_chip *gc, struct device *dev, 5660f4630f3SLinus Walleij unsigned long sz, void __iomem *dat, void __iomem *set, 5670f4630f3SLinus Walleij void __iomem *clr, void __iomem *dirout, void __iomem *dirin, 5680f4630f3SLinus Walleij unsigned long flags); 5690f4630f3SLinus Walleij 5700f4630f3SLinus Walleij #define BGPIOF_BIG_ENDIAN BIT(0) 5710f4630f3SLinus Walleij #define BGPIOF_UNREADABLE_REG_SET BIT(1) /* reg_set is unreadable */ 5720f4630f3SLinus Walleij #define BGPIOF_UNREADABLE_REG_DIR BIT(2) /* reg_dir is unreadable */ 5730f4630f3SLinus Walleij #define BGPIOF_BIG_ENDIAN_BYTE_ORDER BIT(3) 5740f4630f3SLinus Walleij #define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ 5750f4630f3SLinus Walleij #define BGPIOF_NO_OUTPUT BIT(5) /* only input */ 5760f4630f3SLinus Walleij 577f310f2efSEnrico Weigelt #endif /* CONFIG_GPIO_GENERIC */ 5780f4630f3SLinus Walleij 57914250520SLinus Walleij #ifdef CONFIG_GPIOLIB_IRQCHIP 58014250520SLinus Walleij 5811b95b4ebSThierry Reding int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, 5821b95b4ebSThierry Reding irq_hw_number_t hwirq); 5831b95b4ebSThierry Reding void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq); 5841b95b4ebSThierry Reding 585ef74f70eSBrian Masney int gpiochip_irq_domain_activate(struct irq_domain *domain, 586ef74f70eSBrian Masney struct irq_data *data, bool reserve); 587ef74f70eSBrian Masney void gpiochip_irq_domain_deactivate(struct irq_domain *domain, 588ef74f70eSBrian Masney struct irq_data *data); 589ef74f70eSBrian Masney 59014250520SLinus Walleij void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, 59114250520SLinus Walleij struct irq_chip *irqchip, 5926f79309aSThierry Reding unsigned int parent_irq, 59314250520SLinus Walleij irq_flow_handler_t parent_handler); 59414250520SLinus Walleij 595d245b3f9SLinus Walleij void gpiochip_set_nested_irqchip(struct gpio_chip *gpiochip, 596d245b3f9SLinus Walleij struct irq_chip *irqchip, 5976f79309aSThierry Reding unsigned int parent_irq); 598d245b3f9SLinus Walleij 599739e6f59SLinus Walleij int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip, 60014250520SLinus Walleij struct irq_chip *irqchip, 60114250520SLinus Walleij unsigned int first_irq, 60214250520SLinus Walleij irq_flow_handler_t handler, 603a0a8bcf4SGrygorii Strashko unsigned int type, 60460ed54caSThierry Reding bool threaded, 60539c3fd58SAndrew Lunn struct lock_class_key *lock_key, 60639c3fd58SAndrew Lunn struct lock_class_key *request_key); 607a0a8bcf4SGrygorii Strashko 60864ff2c8eSStephen Boyd bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gpiochip, 60964ff2c8eSStephen Boyd unsigned int offset); 61064ff2c8eSStephen Boyd 611739e6f59SLinus Walleij #ifdef CONFIG_LOCKDEP 612739e6f59SLinus Walleij 613739e6f59SLinus Walleij /* 614739e6f59SLinus Walleij * Lockdep requires that each irqchip instance be created with a 615739e6f59SLinus Walleij * unique key so as to avoid unnecessary warnings. This upfront 616739e6f59SLinus Walleij * boilerplate static inlines provides such a key for each 617739e6f59SLinus Walleij * unique instance. 618739e6f59SLinus Walleij */ 619739e6f59SLinus Walleij static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, 620739e6f59SLinus Walleij struct irq_chip *irqchip, 621739e6f59SLinus Walleij unsigned int first_irq, 622739e6f59SLinus Walleij irq_flow_handler_t handler, 623739e6f59SLinus Walleij unsigned int type) 624739e6f59SLinus Walleij { 62539c3fd58SAndrew Lunn static struct lock_class_key lock_key; 62639c3fd58SAndrew Lunn static struct lock_class_key request_key; 627739e6f59SLinus Walleij 628739e6f59SLinus Walleij return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 62939c3fd58SAndrew Lunn handler, type, false, 63039c3fd58SAndrew Lunn &lock_key, &request_key); 631739e6f59SLinus Walleij } 632739e6f59SLinus Walleij 633d245b3f9SLinus Walleij static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, 634d245b3f9SLinus Walleij struct irq_chip *irqchip, 635d245b3f9SLinus Walleij unsigned int first_irq, 636d245b3f9SLinus Walleij irq_flow_handler_t handler, 637d245b3f9SLinus Walleij unsigned int type) 638d245b3f9SLinus Walleij { 639739e6f59SLinus Walleij 64039c3fd58SAndrew Lunn static struct lock_class_key lock_key; 64139c3fd58SAndrew Lunn static struct lock_class_key request_key; 642739e6f59SLinus Walleij 643739e6f59SLinus Walleij return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 64439c3fd58SAndrew Lunn handler, type, true, 64539c3fd58SAndrew Lunn &lock_key, &request_key); 646739e6f59SLinus Walleij } 647f310f2efSEnrico Weigelt #else /* ! CONFIG_LOCKDEP */ 648739e6f59SLinus Walleij static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, 649739e6f59SLinus Walleij struct irq_chip *irqchip, 650739e6f59SLinus Walleij unsigned int first_irq, 651739e6f59SLinus Walleij irq_flow_handler_t handler, 652739e6f59SLinus Walleij unsigned int type) 653739e6f59SLinus Walleij { 654739e6f59SLinus Walleij return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 65539c3fd58SAndrew Lunn handler, type, false, NULL, NULL); 656d245b3f9SLinus Walleij } 657d245b3f9SLinus Walleij 658739e6f59SLinus Walleij static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, 659739e6f59SLinus Walleij struct irq_chip *irqchip, 660739e6f59SLinus Walleij unsigned int first_irq, 661739e6f59SLinus Walleij irq_flow_handler_t handler, 662739e6f59SLinus Walleij unsigned int type) 663739e6f59SLinus Walleij { 664739e6f59SLinus Walleij return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 66539c3fd58SAndrew Lunn handler, type, true, NULL, NULL); 666739e6f59SLinus Walleij } 667739e6f59SLinus Walleij #endif /* CONFIG_LOCKDEP */ 66814250520SLinus Walleij 6697d75a871SPaul Bolle #endif /* CONFIG_GPIOLIB_IRQCHIP */ 67014250520SLinus Walleij 671c771c2f4SJonas Gorski int gpiochip_generic_request(struct gpio_chip *chip, unsigned offset); 672c771c2f4SJonas Gorski void gpiochip_generic_free(struct gpio_chip *chip, unsigned offset); 6732956b5d9SMika Westerberg int gpiochip_generic_config(struct gpio_chip *chip, unsigned offset, 6742956b5d9SMika Westerberg unsigned long config); 675c771c2f4SJonas Gorski 676964cb341SLinus Walleij #ifdef CONFIG_PINCTRL 677964cb341SLinus Walleij 678964cb341SLinus Walleij /** 679964cb341SLinus Walleij * struct gpio_pin_range - pin range controlled by a gpio chip 680950d55f5SThierry Reding * @node: list for maintaining set of pin ranges, used internally 681964cb341SLinus Walleij * @pctldev: pinctrl device which handles corresponding pins 682964cb341SLinus Walleij * @range: actual range of pins controlled by a gpio controller 683964cb341SLinus Walleij */ 684964cb341SLinus Walleij struct gpio_pin_range { 685964cb341SLinus Walleij struct list_head node; 686964cb341SLinus Walleij struct pinctrl_dev *pctldev; 687964cb341SLinus Walleij struct pinctrl_gpio_range range; 688964cb341SLinus Walleij }; 689964cb341SLinus Walleij 690964cb341SLinus Walleij int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, 691964cb341SLinus Walleij unsigned int gpio_offset, unsigned int pin_offset, 692964cb341SLinus Walleij unsigned int npins); 693964cb341SLinus Walleij int gpiochip_add_pingroup_range(struct gpio_chip *chip, 694964cb341SLinus Walleij struct pinctrl_dev *pctldev, 695964cb341SLinus Walleij unsigned int gpio_offset, const char *pin_group); 696964cb341SLinus Walleij void gpiochip_remove_pin_ranges(struct gpio_chip *chip); 697964cb341SLinus Walleij 698f310f2efSEnrico Weigelt #else /* ! CONFIG_PINCTRL */ 699964cb341SLinus Walleij 700d664c439SEnrico Weigelt struct pinctrl_dev; 701d664c439SEnrico Weigelt 702964cb341SLinus Walleij static inline int 703964cb341SLinus Walleij gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, 704964cb341SLinus Walleij unsigned int gpio_offset, unsigned int pin_offset, 705964cb341SLinus Walleij unsigned int npins) 706964cb341SLinus Walleij { 707964cb341SLinus Walleij return 0; 708964cb341SLinus Walleij } 709964cb341SLinus Walleij static inline int 710964cb341SLinus Walleij gpiochip_add_pingroup_range(struct gpio_chip *chip, 711964cb341SLinus Walleij struct pinctrl_dev *pctldev, 712964cb341SLinus Walleij unsigned int gpio_offset, const char *pin_group) 713964cb341SLinus Walleij { 714964cb341SLinus Walleij return 0; 715964cb341SLinus Walleij } 716964cb341SLinus Walleij 717964cb341SLinus Walleij static inline void 718964cb341SLinus Walleij gpiochip_remove_pin_ranges(struct gpio_chip *chip) 719964cb341SLinus Walleij { 720964cb341SLinus Walleij } 721964cb341SLinus Walleij 722964cb341SLinus Walleij #endif /* CONFIG_PINCTRL */ 723964cb341SLinus Walleij 724abdc08a3SAlexandre Courbot struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, 72521abf103SLinus Walleij const char *label, 7265923ea6cSLinus Walleij enum gpio_lookup_flags lflags, 7275923ea6cSLinus Walleij enum gpiod_flags dflags); 728f7d4ad98SGuenter Roeck void gpiochip_free_own_desc(struct gpio_desc *desc); 729f7d4ad98SGuenter Roeck 73064ebde5bSJan Kundrát void devprop_gpiochip_set_names(struct gpio_chip *chip, 73164ebde5bSJan Kundrát const struct fwnode_handle *fwnode); 73264ebde5bSJan Kundrát 733bb1e88ccSAlexandre Courbot #else /* CONFIG_GPIOLIB */ 734bb1e88ccSAlexandre Courbot 735bb1e88ccSAlexandre Courbot static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) 736bb1e88ccSAlexandre Courbot { 737bb1e88ccSAlexandre Courbot /* GPIO can never have been requested */ 738bb1e88ccSAlexandre Courbot WARN_ON(1); 739bb1e88ccSAlexandre Courbot return ERR_PTR(-ENODEV); 740bb1e88ccSAlexandre Courbot } 741bb1e88ccSAlexandre Courbot 742bb1e88ccSAlexandre Courbot #endif /* CONFIG_GPIOLIB */ 743bb1e88ccSAlexandre Courbot 74479a9becdSAlexandre Courbot #endif 745