blob: a79b3b18fadd050932bb4cd05bb5fc96fa94ea47 [file] [log] [blame]
Alexandre Courbot79a9bec2013-10-17 10:21:36 -07001#ifndef __LINUX_GPIO_DRIVER_H
2#define __LINUX_GPIO_DRIVER_H
3
Linus Walleijff2b1352015-10-20 11:10:38 +02004#include <linux/device.h>
Alexandre Courbot79a9bec2013-10-17 10:21:36 -07005#include <linux/types.h>
Linus Walleij14250522014-03-25 10:40:18 +01006#include <linux/irq.h>
7#include <linux/irqchip/chained_irq.h>
8#include <linux/irqdomain.h>
Grygorii Strashkoa0a8bcf2015-08-17 15:35:23 +03009#include <linux/lockdep.h>
Linus Walleij964cb342015-03-18 01:56:17 +010010#include <linux/pinctrl/pinctrl.h>
Mika Westerberg2956b5d2017-01-23 15:34:34 +030011#include <linux/pinctrl/pinconf-generic.h>
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070012
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070013struct gpio_desc;
Alexandre Courbotc9a99722013-11-25 18:34:24 +090014struct of_phandle_args;
15struct device_node;
Stephen Rothwellf3ed0b62013-10-29 01:06:23 +110016struct seq_file;
Linus Walleijff2b1352015-10-20 11:10:38 +020017struct gpio_device;
Paul Gortmakerd47529b2016-09-12 18:16:31 -040018struct module;
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070019
Alexandre Courbotbb1e88c2014-02-09 17:43:54 +090020#ifdef CONFIG_GPIOLIB
21
Thierry Redingc44eafd2017-11-07 19:15:45 +010022#ifdef CONFIG_GPIOLIB_IRQCHIP
23/**
24 * struct gpio_irq_chip - GPIO interrupt controller
25 */
26struct gpio_irq_chip {
27 /**
Thierry Redingda80ff82017-11-07 19:15:46 +010028 * @chip:
29 *
30 * GPIO IRQ chip implementation, provided by GPIO driver.
31 */
32 struct irq_chip *chip;
33
34 /**
Thierry Redingc44eafd2017-11-07 19:15:45 +010035 * @domain_ops:
36 *
37 * Table of interrupt domain operations for this IRQ chip.
38 */
39 const struct irq_domain_ops *domain_ops;
40
41 /**
42 * @parent_handler:
43 *
44 * The interrupt handler for the GPIO chip's parent interrupts, may be
45 * NULL if the parent interrupts are nested rather than cascaded.
46 */
47 irq_flow_handler_t parent_handler;
48
49 /**
50 * @parent_handler_data:
51 *
52 * Data associated, and passed to, the handler for the parent
53 * interrupt.
54 */
55 void *parent_handler_data;
56};
Thierry Redingda80ff82017-11-07 19:15:46 +010057
58static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip)
59{
60 return container_of(chip, struct gpio_irq_chip, chip);
61}
Thierry Redingc44eafd2017-11-07 19:15:45 +010062#endif
63
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070064/**
65 * struct gpio_chip - abstract a GPIO controller
Linus Walleijdf4878e2016-02-12 14:48:23 +010066 * @label: a functional name for the GPIO device, such as a part
67 * number or the name of the SoC IP-block implementing it.
Linus Walleijff2b1352015-10-20 11:10:38 +020068 * @gpiodev: the internal state holder, opaque struct
Linus Walleij58383c782015-11-04 09:56:26 +010069 * @parent: optional parent device providing the GPIOs
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070070 * @owner: helps prevent removal of modules exporting active GPIOs
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070071 * @request: optional hook for chip-specific activation, such as
72 * enabling module power and clock; may sleep
73 * @free: optional hook for chip-specific deactivation, such as
74 * disabling module power and clock; may sleep
75 * @get_direction: returns direction for signal "offset", 0=out, 1=in,
76 * (same as GPIOF_DIR_XXX), or negative error
77 * @direction_input: configures signal "offset" as input, or returns error
78 * @direction_output: configures signal "offset" as output, or returns error
Vladimir Zapolskiy60befd22015-12-22 16:37:28 +020079 * @get: returns value for signal "offset", 0=low, 1=high, or negative error
Lukas Wunnereec1d562017-10-12 12:40:10 +020080 * @get_multiple: reads values for multiple signals defined by "mask" and
81 * stores them in "bits", returns 0 on success or negative error
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070082 * @set: assigns output value for signal "offset"
Rojhalat Ibrahim5f424242014-11-04 17:12:06 +010083 * @set_multiple: assigns output values for multiple signals defined by "mask"
Mika Westerberg2956b5d2017-01-23 15:34:34 +030084 * @set_config: optional hook for all kinds of settings. Uses the same
85 * packed config format as generic pinconf.
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070086 * @to_irq: optional hook supporting non-static gpio_to_irq() mappings;
87 * implementation may not sleep
88 * @dbg_show: optional routine to show contents in debugfs; default code
89 * will be used when this is omitted, but custom code can show extra
90 * state (such as pullup/pulldown configuration).
Linus Walleijaf6c2352015-05-13 13:03:21 +020091 * @base: identifies the first GPIO number handled by this chip;
92 * or, if negative during registration, requests dynamic ID allocation.
93 * DEPRECATION: providing anything non-negative and nailing the base
Geert Uytterhoeven30bb6fb2015-06-15 13:31:33 +020094 * offset of GPIO chips is deprecated. Please pass -1 as base to
Linus Walleijaf6c2352015-05-13 13:03:21 +020095 * let gpiolib select the chip base in all possible cases. We want to
96 * get rid of the static GPIO number space in the long run.
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070097 * @ngpio: the number of GPIOs handled by this controller; the last GPIO
98 * handled is (base + ngpio - 1).
Alexandre Courbot79a9bec2013-10-17 10:21:36 -070099 * @names: if set, must be an array of strings to use as alternative
100 * names for the GPIOs in this chip. Any entry in the array
101 * may be NULL if there is no alias for the GPIO, however the
102 * array must be @ngpio entries long. A name can include a single printk
103 * format specifier for an unsigned int. It is substituted by the actual
104 * number of the gpio.
Linus Walleij9fb1f392013-12-04 14:42:46 +0100105 * @can_sleep: flag must be set iff get()/set() methods sleep, as they
Linus Walleij1c8732b2014-04-09 13:34:39 +0200106 * must while accessing GPIO expander chips over I2C or SPI. This
107 * implies that if the chip supports IRQs, these IRQs need to be threaded
108 * as the chip access may sleep when e.g. reading out the IRQ status
109 * registers.
Linus Walleij0f4630f2015-12-04 14:02:58 +0100110 * @read_reg: reader function for generic GPIO
111 * @write_reg: writer function for generic GPIO
Linus Walleij24efd942017-10-20 16:31:27 +0200112 * @be_bits: if the generic GPIO has big endian bit order (bit 31 is representing
113 * line 0, bit 30 is line 1 ... bit 0 is line 31) this is set to true by the
114 * generic GPIO core. It is for internal housekeeping only.
Linus Walleij0f4630f2015-12-04 14:02:58 +0100115 * @reg_dat: data (in) register for generic GPIO
116 * @reg_set: output set register (out=high) for generic GPIO
Anthony Best08bcd3e2016-10-04 14:15:42 -0600117 * @reg_clr: output clear register (out=low) for generic GPIO
Linus Walleij0f4630f2015-12-04 14:02:58 +0100118 * @reg_dir: direction setting register for generic GPIO
119 * @bgpio_bits: number of register bits used for a generic GPIO i.e.
120 * <register width> * 8
121 * @bgpio_lock: used to lock chip->bgpio_data. Also, this is needed to keep
122 * shadowed and real data registers writes together.
123 * @bgpio_data: shadowed data register for generic GPIO to clear/set bits
124 * safely.
125 * @bgpio_dir: shadowed direction register for generic GPIO to clear/set
126 * direction safely.
Grygorii Strashko41d6bb42015-08-17 15:35:24 +0300127 * @irqdomain: Interrupt translation domain; responsible for mapping
128 * between GPIO hwirq number and linux irq number
Grygorii Strashko41d6bb42015-08-17 15:35:24 +0300129 * @irq_handler: the irq handler to use (often a predefined irq core function)
130 * for GPIO IRQs, provided by GPIO driver
131 * @irq_default_type: default IRQ triggering type applied during GPIO driver
132 * initialization, provided by GPIO driver
Linus Walleijd245b3f2016-11-24 10:57:25 +0100133 * @irq_chained_parent: GPIO IRQ chip parent/bank linux irq number,
134 * provided by GPIO driver for chained interrupt (not for nested
135 * interrupts).
136 * @irq_nested: True if set the interrupt handling is nested.
Mika Westerberg79b804c2016-09-20 15:15:21 +0300137 * @irq_need_valid_mask: If set core allocates @irq_valid_mask with all
138 * bits set to one
139 * @irq_valid_mask: If not %NULL holds bitmask of GPIOs which are valid to
140 * be included in IRQ domain of the chip
Grygorii Strashko41d6bb42015-08-17 15:35:24 +0300141 * @lock_key: per GPIO IRQ chip lockdep class
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700142 *
143 * A gpio_chip can help platforms abstract various sources of GPIOs so
144 * they can all be accessed through a common programing interface.
145 * Example sources would be SOC controllers, FPGAs, multifunction
146 * chips, dedicated GPIO expanders, and so on.
147 *
148 * Each chip controls a number of signals, identified in method calls
149 * by "offset" values in the range 0..(@ngpio - 1). When those signals
150 * are referenced through calls like gpio_get_value(gpio), the offset
151 * is calculated by subtracting @base from the gpio number.
152 */
153struct gpio_chip {
154 const char *label;
Linus Walleijff2b1352015-10-20 11:10:38 +0200155 struct gpio_device *gpiodev;
Linus Walleij58383c782015-11-04 09:56:26 +0100156 struct device *parent;
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700157 struct module *owner;
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700158
159 int (*request)(struct gpio_chip *chip,
160 unsigned offset);
161 void (*free)(struct gpio_chip *chip,
162 unsigned offset);
163 int (*get_direction)(struct gpio_chip *chip,
164 unsigned offset);
165 int (*direction_input)(struct gpio_chip *chip,
166 unsigned offset);
167 int (*direction_output)(struct gpio_chip *chip,
168 unsigned offset, int value);
169 int (*get)(struct gpio_chip *chip,
170 unsigned offset);
Lukas Wunnereec1d562017-10-12 12:40:10 +0200171 int (*get_multiple)(struct gpio_chip *chip,
172 unsigned long *mask,
173 unsigned long *bits);
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700174 void (*set)(struct gpio_chip *chip,
175 unsigned offset, int value);
Rojhalat Ibrahim5f424242014-11-04 17:12:06 +0100176 void (*set_multiple)(struct gpio_chip *chip,
177 unsigned long *mask,
178 unsigned long *bits);
Mika Westerberg2956b5d2017-01-23 15:34:34 +0300179 int (*set_config)(struct gpio_chip *chip,
180 unsigned offset,
181 unsigned long config);
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700182 int (*to_irq)(struct gpio_chip *chip,
183 unsigned offset);
184
185 void (*dbg_show)(struct seq_file *s,
186 struct gpio_chip *chip);
187 int base;
188 u16 ngpio;
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700189 const char *const *names;
Linus Walleij9fb1f392013-12-04 14:42:46 +0100190 bool can_sleep;
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700191
Linus Walleij0f4630f2015-12-04 14:02:58 +0100192#if IS_ENABLED(CONFIG_GPIO_GENERIC)
193 unsigned long (*read_reg)(void __iomem *reg);
194 void (*write_reg)(void __iomem *reg, unsigned long data);
Linus Walleij24efd942017-10-20 16:31:27 +0200195 bool be_bits;
Linus Walleij0f4630f2015-12-04 14:02:58 +0100196 void __iomem *reg_dat;
197 void __iomem *reg_set;
198 void __iomem *reg_clr;
199 void __iomem *reg_dir;
200 int bgpio_bits;
201 spinlock_t bgpio_lock;
202 unsigned long bgpio_data;
203 unsigned long bgpio_dir;
204#endif
205
Linus Walleij14250522014-03-25 10:40:18 +0100206#ifdef CONFIG_GPIOLIB_IRQCHIP
207 /*
Paul Bolle7d75a872014-09-05 13:09:25 +0200208 * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib
Linus Walleij14250522014-03-25 10:40:18 +0100209 * to handle IRQs for most practical cases.
210 */
Linus Walleij14250522014-03-25 10:40:18 +0100211 struct irq_domain *irqdomain;
212 irq_flow_handler_t irq_handler;
213 unsigned int irq_default_type;
Thierry Reding6f793092017-04-03 18:05:21 +0200214 unsigned int irq_chained_parent;
Linus Walleijd245b3f2016-11-24 10:57:25 +0100215 bool irq_nested;
Mika Westerberg79b804c2016-09-20 15:15:21 +0300216 bool irq_need_valid_mask;
217 unsigned long *irq_valid_mask;
Grygorii Strashkoa0a8bcf2015-08-17 15:35:23 +0300218 struct lock_class_key *lock_key;
Thierry Redingc44eafd2017-11-07 19:15:45 +0100219
220 /**
221 * @irq:
222 *
223 * Integrates interrupt chip functionality with the GPIO chip. Can be
224 * used to handle IRQs for most practical cases.
225 */
226 struct gpio_irq_chip irq;
Linus Walleij14250522014-03-25 10:40:18 +0100227#endif
228
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700229#if defined(CONFIG_OF_GPIO)
230 /*
231 * If CONFIG_OF is enabled, then all GPIO controllers described in the
232 * device tree automatically may have an OF translation
233 */
Thierry Reding67049c52017-07-24 16:57:23 +0200234
235 /**
236 * @of_node:
237 *
238 * Pointer to a device tree node representing this GPIO controller.
239 */
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700240 struct device_node *of_node;
Thierry Reding67049c52017-07-24 16:57:23 +0200241
242 /**
243 * @of_gpio_n_cells:
244 *
245 * Number of cells used to form the GPIO specifier.
246 */
Thierry Redinge3b445d2017-07-24 16:57:28 +0200247 unsigned int of_gpio_n_cells;
Thierry Reding67049c52017-07-24 16:57:23 +0200248
249 /**
250 * @of_xlate:
251 *
252 * Callback to translate a device tree GPIO specifier into a chip-
253 * relative GPIO number and flags.
254 */
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700255 int (*of_xlate)(struct gpio_chip *gc,
256 const struct of_phandle_args *gpiospec, u32 *flags);
257#endif
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700258};
259
260extern const char *gpiochip_is_requested(struct gpio_chip *chip,
261 unsigned offset);
262
263/* add/remove chips */
Linus Walleijb08ea352015-12-03 15:14:13 +0100264extern int gpiochip_add_data(struct gpio_chip *chip, void *data);
265static inline int gpiochip_add(struct gpio_chip *chip)
266{
267 return gpiochip_add_data(chip, NULL);
268}
abdoulaye berthee1db1702014-07-05 18:28:50 +0200269extern void gpiochip_remove(struct gpio_chip *chip);
Laxman Dewangan0cf32922016-02-15 16:32:09 +0530270extern int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
271 void *data);
272extern void devm_gpiochip_remove(struct device *dev, struct gpio_chip *chip);
273
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700274extern struct gpio_chip *gpiochip_find(void *data,
275 int (*match)(struct gpio_chip *chip, void *data));
276
277/* lock/unlock as IRQ */
Alexandre Courbote3a2e872014-10-23 17:27:07 +0900278int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
279void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
Linus Walleij6cee3822016-02-11 20:16:45 +0100280bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset);
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700281
Linus Walleij143b65d2016-02-16 15:41:42 +0100282/* Line status inquiry for drivers */
283bool gpiochip_line_is_open_drain(struct gpio_chip *chip, unsigned int offset);
284bool gpiochip_line_is_open_source(struct gpio_chip *chip, unsigned int offset);
285
Charles Keepax05f479b2017-05-23 15:47:29 +0100286/* Sleep persistence inquiry for drivers */
287bool gpiochip_line_is_persistent(struct gpio_chip *chip, unsigned int offset);
288
Linus Walleijb08ea352015-12-03 15:14:13 +0100289/* get driver data */
Linus Walleij43c54ec2016-02-11 11:37:48 +0100290void *gpiochip_get_data(struct gpio_chip *chip);
Linus Walleijb08ea352015-12-03 15:14:13 +0100291
Alexandre Courbotbb1e88c2014-02-09 17:43:54 +0900292struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
293
Linus Walleij0f4630f2015-12-04 14:02:58 +0100294struct bgpio_pdata {
295 const char *label;
296 int base;
297 int ngpio;
298};
299
Arnd Bergmannc474e342016-01-09 22:16:42 +0100300#if IS_ENABLED(CONFIG_GPIO_GENERIC)
301
Linus Walleij0f4630f2015-12-04 14:02:58 +0100302int bgpio_init(struct gpio_chip *gc, struct device *dev,
303 unsigned long sz, void __iomem *dat, void __iomem *set,
304 void __iomem *clr, void __iomem *dirout, void __iomem *dirin,
305 unsigned long flags);
306
307#define BGPIOF_BIG_ENDIAN BIT(0)
308#define BGPIOF_UNREADABLE_REG_SET BIT(1) /* reg_set is unreadable */
309#define BGPIOF_UNREADABLE_REG_DIR BIT(2) /* reg_dir is unreadable */
310#define BGPIOF_BIG_ENDIAN_BYTE_ORDER BIT(3)
311#define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */
312#define BGPIOF_NO_OUTPUT BIT(5) /* only input */
313
314#endif
315
Linus Walleij14250522014-03-25 10:40:18 +0100316#ifdef CONFIG_GPIOLIB_IRQCHIP
317
318void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
319 struct irq_chip *irqchip,
Thierry Reding6f793092017-04-03 18:05:21 +0200320 unsigned int parent_irq,
Linus Walleij14250522014-03-25 10:40:18 +0100321 irq_flow_handler_t parent_handler);
322
Linus Walleijd245b3f2016-11-24 10:57:25 +0100323void gpiochip_set_nested_irqchip(struct gpio_chip *gpiochip,
324 struct irq_chip *irqchip,
Thierry Reding6f793092017-04-03 18:05:21 +0200325 unsigned int parent_irq);
Linus Walleijd245b3f2016-11-24 10:57:25 +0100326
Linus Walleij739e6f52017-01-11 13:37:07 +0100327int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
328 struct irq_chip *irqchip,
329 unsigned int first_irq,
330 irq_flow_handler_t handler,
331 unsigned int type,
332 bool nested,
333 struct lock_class_key *lock_key);
Grygorii Strashkoa0a8bcf2015-08-17 15:35:23 +0300334
Linus Walleij739e6f52017-01-11 13:37:07 +0100335#ifdef CONFIG_LOCKDEP
336
337/*
338 * Lockdep requires that each irqchip instance be created with a
339 * unique key so as to avoid unnecessary warnings. This upfront
340 * boilerplate static inlines provides such a key for each
341 * unique instance.
342 */
343static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
344 struct irq_chip *irqchip,
345 unsigned int first_irq,
346 irq_flow_handler_t handler,
347 unsigned int type)
348{
349 static struct lock_class_key key;
350
351 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
352 handler, type, false, &key);
353}
354
Linus Walleijd245b3f2016-11-24 10:57:25 +0100355static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
356 struct irq_chip *irqchip,
357 unsigned int first_irq,
358 irq_flow_handler_t handler,
359 unsigned int type)
360{
Linus Walleij739e6f52017-01-11 13:37:07 +0100361
362 static struct lock_class_key key;
363
364 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
365 handler, type, true, &key);
366}
367#else
368static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
369 struct irq_chip *irqchip,
370 unsigned int first_irq,
371 irq_flow_handler_t handler,
372 unsigned int type)
373{
374 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
375 handler, type, false, NULL);
Linus Walleijd245b3f2016-11-24 10:57:25 +0100376}
377
Linus Walleij739e6f52017-01-11 13:37:07 +0100378static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
379 struct irq_chip *irqchip,
380 unsigned int first_irq,
381 irq_flow_handler_t handler,
382 unsigned int type)
383{
384 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
385 handler, type, true, NULL);
386}
387#endif /* CONFIG_LOCKDEP */
Linus Walleij14250522014-03-25 10:40:18 +0100388
Paul Bolle7d75a872014-09-05 13:09:25 +0200389#endif /* CONFIG_GPIOLIB_IRQCHIP */
Linus Walleij14250522014-03-25 10:40:18 +0100390
Jonas Gorskic771c2f2015-10-11 17:34:15 +0200391int gpiochip_generic_request(struct gpio_chip *chip, unsigned offset);
392void gpiochip_generic_free(struct gpio_chip *chip, unsigned offset);
Mika Westerberg2956b5d2017-01-23 15:34:34 +0300393int gpiochip_generic_config(struct gpio_chip *chip, unsigned offset,
394 unsigned long config);
Jonas Gorskic771c2f2015-10-11 17:34:15 +0200395
Linus Walleij964cb342015-03-18 01:56:17 +0100396#ifdef CONFIG_PINCTRL
397
398/**
399 * struct gpio_pin_range - pin range controlled by a gpio chip
Thierry Reding950d55f52017-07-24 16:57:22 +0200400 * @node: list for maintaining set of pin ranges, used internally
Linus Walleij964cb342015-03-18 01:56:17 +0100401 * @pctldev: pinctrl device which handles corresponding pins
402 * @range: actual range of pins controlled by a gpio controller
403 */
Linus Walleij964cb342015-03-18 01:56:17 +0100404struct gpio_pin_range {
405 struct list_head node;
406 struct pinctrl_dev *pctldev;
407 struct pinctrl_gpio_range range;
408};
409
410int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
411 unsigned int gpio_offset, unsigned int pin_offset,
412 unsigned int npins);
413int gpiochip_add_pingroup_range(struct gpio_chip *chip,
414 struct pinctrl_dev *pctldev,
415 unsigned int gpio_offset, const char *pin_group);
416void gpiochip_remove_pin_ranges(struct gpio_chip *chip);
417
418#else
419
420static inline int
421gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
422 unsigned int gpio_offset, unsigned int pin_offset,
423 unsigned int npins)
424{
425 return 0;
426}
427static inline int
428gpiochip_add_pingroup_range(struct gpio_chip *chip,
429 struct pinctrl_dev *pctldev,
430 unsigned int gpio_offset, const char *pin_group)
431{
432 return 0;
433}
434
435static inline void
436gpiochip_remove_pin_ranges(struct gpio_chip *chip)
437{
438}
439
440#endif /* CONFIG_PINCTRL */
441
Alexandre Courbotabdc08a2014-08-19 10:06:09 -0700442struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum,
443 const char *label);
Guenter Roeckf7d4ad92014-07-22 08:01:01 -0700444void gpiochip_free_own_desc(struct gpio_desc *desc);
445
Alexandre Courbotbb1e88c2014-02-09 17:43:54 +0900446#else /* CONFIG_GPIOLIB */
447
448static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
449{
450 /* GPIO can never have been requested */
451 WARN_ON(1);
452 return ERR_PTR(-ENODEV);
453}
454
455#endif /* CONFIG_GPIOLIB */
456
Alexandre Courbot79a9bec2013-10-17 10:21:36 -0700457#endif