Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 2 | #ifndef __LINUX_GPIO_CONSUMER_H |
| 3 | #define __LINUX_GPIO_CONSUMER_H |
| 4 | |
Arnd Bergmann | cdf86cd2 | 2014-05-08 15:42:25 +0200 | [diff] [blame] | 5 | #include <linux/bug.h> |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 6 | #include <linux/err.h> |
| 7 | #include <linux/kernel.h> |
| 8 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 9 | struct device; |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
| 12 | * Opaque descriptor for a GPIO. These are obtained using gpiod_get() and are |
| 13 | * preferable to the old integer-based handles. |
| 14 | * |
| 15 | * Contrary to integers, a pointer to a gpio_desc is guaranteed to be valid |
| 16 | * until the GPIO is released. |
| 17 | */ |
| 18 | struct gpio_desc; |
| 19 | |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 20 | /** |
Janusz Krzysztofik | bf9346f | 2018-09-05 23:50:06 +0200 | [diff] [blame] | 21 | * Opaque descriptor for a structure of GPIO array attributes. This structure |
| 22 | * is attached to struct gpiod_descs obtained from gpiod_get_array() and can be |
| 23 | * passed back to get/set array functions in order to activate fast processing |
| 24 | * path if applicable. |
| 25 | */ |
| 26 | struct gpio_array; |
| 27 | |
| 28 | /** |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 29 | * Struct containing an array of descriptors that can be obtained using |
| 30 | * gpiod_get_array(). |
| 31 | */ |
| 32 | struct gpio_descs { |
Janusz Krzysztofik | bf9346f | 2018-09-05 23:50:06 +0200 | [diff] [blame] | 33 | struct gpio_array *info; |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 34 | unsigned int ndescs; |
| 35 | struct gpio_desc *desc[]; |
| 36 | }; |
| 37 | |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 38 | #define GPIOD_FLAGS_BIT_DIR_SET BIT(0) |
| 39 | #define GPIOD_FLAGS_BIT_DIR_OUT BIT(1) |
| 40 | #define GPIOD_FLAGS_BIT_DIR_VAL BIT(2) |
Linus Walleij | f926dfc | 2017-09-10 19:26:22 +0200 | [diff] [blame] | 41 | #define GPIOD_FLAGS_BIT_OPEN_DRAIN BIT(3) |
Linus Walleij | b0ce7b29 | 2018-10-12 14:54:12 +0200 | [diff] [blame] | 42 | #define GPIOD_FLAGS_BIT_NONEXCLUSIVE BIT(4) |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Optional flags that can be passed to one of gpiod_* to configure direction |
| 46 | * and output value. These values cannot be OR'd. |
| 47 | */ |
| 48 | enum gpiod_flags { |
| 49 | GPIOD_ASIS = 0, |
| 50 | GPIOD_IN = GPIOD_FLAGS_BIT_DIR_SET, |
| 51 | GPIOD_OUT_LOW = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT, |
| 52 | GPIOD_OUT_HIGH = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT | |
| 53 | GPIOD_FLAGS_BIT_DIR_VAL, |
Andy Shevchenko | 0969a20 | 2018-07-27 17:47:01 +0300 | [diff] [blame] | 54 | GPIOD_OUT_LOW_OPEN_DRAIN = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_OPEN_DRAIN, |
| 55 | GPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRAIN, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 56 | }; |
| 57 | |
Linus Walleij | 58b84f6 | 2014-08-19 12:00:53 -0500 | [diff] [blame] | 58 | #ifdef CONFIG_GPIOLIB |
| 59 | |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 60 | /* Return the number of GPIOs associated with a device / function */ |
| 61 | int gpiod_count(struct device *dev, const char *con_id); |
| 62 | |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 63 | /* Acquire and dispose GPIOs */ |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 64 | struct gpio_desc *__must_check gpiod_get(struct device *dev, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 65 | const char *con_id, |
| 66 | enum gpiod_flags flags); |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 67 | struct gpio_desc *__must_check gpiod_get_index(struct device *dev, |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 68 | const char *con_id, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 69 | unsigned int idx, |
| 70 | enum gpiod_flags flags); |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 71 | struct gpio_desc *__must_check gpiod_get_optional(struct device *dev, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 72 | const char *con_id, |
| 73 | enum gpiod_flags flags); |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 74 | struct gpio_desc *__must_check gpiod_get_index_optional(struct device *dev, |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 75 | const char *con_id, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 76 | unsigned int index, |
| 77 | enum gpiod_flags flags); |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 78 | struct gpio_descs *__must_check gpiod_get_array(struct device *dev, |
| 79 | const char *con_id, |
| 80 | enum gpiod_flags flags); |
| 81 | struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev, |
| 82 | const char *con_id, |
| 83 | enum gpiod_flags flags); |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 84 | void gpiod_put(struct gpio_desc *desc); |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 85 | void gpiod_put_array(struct gpio_descs *descs); |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 86 | |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 87 | struct gpio_desc *__must_check devm_gpiod_get(struct device *dev, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 88 | const char *con_id, |
| 89 | enum gpiod_flags flags); |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 90 | struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev, |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 91 | const char *con_id, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 92 | unsigned int idx, |
| 93 | enum gpiod_flags flags); |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 94 | struct gpio_desc *__must_check devm_gpiod_get_optional(struct device *dev, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 95 | const char *con_id, |
| 96 | enum gpiod_flags flags); |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 97 | struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 98 | devm_gpiod_get_index_optional(struct device *dev, const char *con_id, |
Alexandre Courbot | 39b2bbe | 2014-07-25 23:38:36 +0900 | [diff] [blame] | 99 | unsigned int index, enum gpiod_flags flags); |
Rojhalat Ibrahim | 331758e | 2015-02-11 17:28:02 +0100 | [diff] [blame] | 100 | struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev, |
| 101 | const char *con_id, |
| 102 | enum gpiod_flags flags); |
| 103 | struct gpio_descs *__must_check |
| 104 | devm_gpiod_get_array_optional(struct device *dev, const char *con_id, |
| 105 | enum gpiod_flags flags); |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 106 | void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); |
Linus Walleij | 891ddbc | 2018-12-06 13:43:46 +0100 | [diff] [blame] | 107 | void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc); |
Rojhalat Ibrahim | 331758e | 2015-02-11 17:28:02 +0100 | [diff] [blame] | 108 | void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs); |
Alexandre Courbot | bae48da | 2013-10-17 10:21:38 -0700 | [diff] [blame] | 109 | |
Alexandre Courbot | 8e53b0f | 2014-11-25 17:16:31 +0900 | [diff] [blame] | 110 | int gpiod_get_direction(struct gpio_desc *desc); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 111 | int gpiod_direction_input(struct gpio_desc *desc); |
| 112 | int gpiod_direction_output(struct gpio_desc *desc, int value); |
Philipp Zabel | ef70bbe | 2014-01-07 12:34:11 +0100 | [diff] [blame] | 113 | int gpiod_direction_output_raw(struct gpio_desc *desc, int value); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 114 | |
| 115 | /* Value get/set from non-sleeping context */ |
| 116 | int gpiod_get_value(const struct gpio_desc *desc); |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 117 | int gpiod_get_array_value(unsigned int array_size, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 118 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 119 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 120 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 121 | void gpiod_set_value(struct gpio_desc *desc, int value); |
Geert Uytterhoeven | cf9af0d | 2018-09-27 13:38:09 +0200 | [diff] [blame] | 122 | int gpiod_set_array_value(unsigned int array_size, |
| 123 | struct gpio_desc **desc_array, |
| 124 | struct gpio_array *array_info, |
| 125 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 126 | int gpiod_get_raw_value(const struct gpio_desc *desc); |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 127 | int gpiod_get_raw_array_value(unsigned int array_size, |
| 128 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 129 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 130 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 131 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); |
Laura Abbott | 3027743 | 2018-05-21 10:57:07 -0700 | [diff] [blame] | 132 | int gpiod_set_raw_array_value(unsigned int array_size, |
Geert Uytterhoeven | 3c94066 | 2018-09-27 13:38:10 +0200 | [diff] [blame] | 133 | struct gpio_desc **desc_array, |
| 134 | struct gpio_array *array_info, |
| 135 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 136 | |
| 137 | /* Value get/set from sleeping context */ |
| 138 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 139 | int gpiod_get_array_value_cansleep(unsigned int array_size, |
| 140 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 141 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 142 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 143 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); |
Geert Uytterhoeven | cf9af0d | 2018-09-27 13:38:09 +0200 | [diff] [blame] | 144 | int gpiod_set_array_value_cansleep(unsigned int array_size, |
| 145 | struct gpio_desc **desc_array, |
| 146 | struct gpio_array *array_info, |
| 147 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 148 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 149 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, |
| 150 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 151 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 152 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 153 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); |
Laura Abbott | 3027743 | 2018-05-21 10:57:07 -0700 | [diff] [blame] | 154 | int gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
Geert Uytterhoeven | 3c94066 | 2018-09-27 13:38:10 +0200 | [diff] [blame] | 155 | struct gpio_desc **desc_array, |
| 156 | struct gpio_array *array_info, |
| 157 | unsigned long *value_bitmap); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 158 | |
| 159 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); |
Andrew Jeffery | e10f72b | 2017-11-30 14:25:24 +1030 | [diff] [blame] | 160 | int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 161 | |
| 162 | int gpiod_is_active_low(const struct gpio_desc *desc); |
| 163 | int gpiod_cansleep(const struct gpio_desc *desc); |
| 164 | |
| 165 | int gpiod_to_irq(const struct gpio_desc *desc); |
Muchun Song | 18534df | 2018-11-01 21:12:50 +0800 | [diff] [blame] | 166 | int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 167 | |
| 168 | /* Convert between the old gpio_ and new gpiod_ interfaces */ |
| 169 | struct gpio_desc *gpio_to_desc(unsigned gpio); |
| 170 | int desc_to_gpio(const struct gpio_desc *desc); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 171 | |
Mika Westerberg | 40b7318 | 2014-10-21 13:33:59 +0200 | [diff] [blame] | 172 | /* Child properties interface */ |
Linus Walleij | 92542ed | 2017-12-29 22:52:02 +0100 | [diff] [blame] | 173 | struct device_node; |
Mika Westerberg | 40b7318 | 2014-10-21 13:33:59 +0200 | [diff] [blame] | 174 | struct fwnode_handle; |
| 175 | |
Linus Walleij | fe6c473 | 2018-12-06 13:43:42 +0100 | [diff] [blame] | 176 | struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, |
| 177 | const char *propname, int index, |
| 178 | enum gpiod_flags dflags, |
| 179 | const char *label); |
Linus Walleij | 92542ed | 2017-12-29 22:52:02 +0100 | [diff] [blame] | 180 | struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, |
| 181 | struct device_node *node, |
| 182 | const char *propname, int index, |
| 183 | enum gpiod_flags dflags, |
| 184 | const char *label); |
Mika Westerberg | 40b7318 | 2014-10-21 13:33:59 +0200 | [diff] [blame] | 185 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, |
Boris Brezillon | 537b94d | 2017-02-02 14:53:11 +0100 | [diff] [blame] | 186 | const char *propname, int index, |
Alexander Stein | b2987d7 | 2017-01-12 17:39:24 +0100 | [diff] [blame] | 187 | enum gpiod_flags dflags, |
| 188 | const char *label); |
Boris Brezillon | 537b94d | 2017-02-02 14:53:11 +0100 | [diff] [blame] | 189 | struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, |
| 190 | const char *con_id, int index, |
| 191 | struct fwnode_handle *child, |
| 192 | enum gpiod_flags flags, |
| 193 | const char *label); |
Linus Walleij | 3498d86 | 2017-02-21 14:19:45 +0100 | [diff] [blame] | 194 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 195 | #else /* CONFIG_GPIOLIB */ |
| 196 | |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 197 | static inline int gpiod_count(struct device *dev, const char *con_id) |
| 198 | { |
| 199 | return 0; |
| 200 | } |
| 201 | |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 202 | static inline struct gpio_desc *__must_check gpiod_get(struct device *dev, |
| 203 | const char *con_id, |
| 204 | enum gpiod_flags flags) |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 205 | { |
| 206 | return ERR_PTR(-ENOSYS); |
| 207 | } |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 208 | static inline struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 209 | gpiod_get_index(struct device *dev, |
| 210 | const char *con_id, |
| 211 | unsigned int idx, |
| 212 | enum gpiod_flags flags) |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 213 | { |
| 214 | return ERR_PTR(-ENOSYS); |
| 215 | } |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 216 | |
| 217 | static inline struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 218 | gpiod_get_optional(struct device *dev, const char *con_id, |
| 219 | enum gpiod_flags flags) |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 220 | { |
Dmitry Torokhov | 22c4036 | 2017-02-12 17:13:55 -0800 | [diff] [blame] | 221 | return NULL; |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | static inline struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 225 | gpiod_get_index_optional(struct device *dev, const char *con_id, |
| 226 | unsigned int index, enum gpiod_flags flags) |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 227 | { |
Dmitry Torokhov | 22c4036 | 2017-02-12 17:13:55 -0800 | [diff] [blame] | 228 | return NULL; |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 229 | } |
| 230 | |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 231 | static inline struct gpio_descs *__must_check |
| 232 | gpiod_get_array(struct device *dev, const char *con_id, |
| 233 | enum gpiod_flags flags) |
| 234 | { |
| 235 | return ERR_PTR(-ENOSYS); |
| 236 | } |
| 237 | |
| 238 | static inline struct gpio_descs *__must_check |
| 239 | gpiod_get_array_optional(struct device *dev, const char *con_id, |
| 240 | enum gpiod_flags flags) |
| 241 | { |
Dmitry Torokhov | 22c4036 | 2017-02-12 17:13:55 -0800 | [diff] [blame] | 242 | return NULL; |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 243 | } |
| 244 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 245 | static inline void gpiod_put(struct gpio_desc *desc) |
| 246 | { |
| 247 | might_sleep(); |
| 248 | |
| 249 | /* GPIO can never have been requested */ |
| 250 | WARN_ON(1); |
| 251 | } |
| 252 | |
Linus Walleij | 891ddbc | 2018-12-06 13:43:46 +0100 | [diff] [blame] | 253 | static inline void devm_gpiod_unhinge(struct device *dev, |
| 254 | struct gpio_desc *desc) |
| 255 | { |
| 256 | might_sleep(); |
| 257 | |
| 258 | /* GPIO can never have been requested */ |
| 259 | WARN_ON(1); |
| 260 | } |
| 261 | |
Rojhalat Ibrahim | 6685852 | 2015-02-11 17:27:58 +0100 | [diff] [blame] | 262 | static inline void gpiod_put_array(struct gpio_descs *descs) |
| 263 | { |
| 264 | might_sleep(); |
| 265 | |
| 266 | /* GPIO can never have been requested */ |
| 267 | WARN_ON(1); |
| 268 | } |
| 269 | |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 270 | static inline struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 271 | devm_gpiod_get(struct device *dev, |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 272 | const char *con_id, |
| 273 | enum gpiod_flags flags) |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 274 | { |
| 275 | return ERR_PTR(-ENOSYS); |
| 276 | } |
| 277 | static inline |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 278 | struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 279 | devm_gpiod_get_index(struct device *dev, |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 280 | const char *con_id, |
| 281 | unsigned int idx, |
| 282 | enum gpiod_flags flags) |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 283 | { |
| 284 | return ERR_PTR(-ENOSYS); |
| 285 | } |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 286 | |
| 287 | static inline struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 288 | devm_gpiod_get_optional(struct device *dev, const char *con_id, |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 289 | enum gpiod_flags flags) |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 290 | { |
Dmitry Torokhov | 22c4036 | 2017-02-12 17:13:55 -0800 | [diff] [blame] | 291 | return NULL; |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | static inline struct gpio_desc *__must_check |
Uwe Kleine-König | b17d1bf | 2015-02-11 11:52:37 +0100 | [diff] [blame] | 295 | devm_gpiod_get_index_optional(struct device *dev, const char *con_id, |
Linus Walleij | 0dbc8b7 | 2014-09-01 15:15:40 +0200 | [diff] [blame] | 296 | unsigned int index, enum gpiod_flags flags) |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 297 | { |
Dmitry Torokhov | 22c4036 | 2017-02-12 17:13:55 -0800 | [diff] [blame] | 298 | return NULL; |
Thierry Reding | 29a1f233 | 2014-04-25 17:10:06 +0200 | [diff] [blame] | 299 | } |
| 300 | |
Rojhalat Ibrahim | 331758e | 2015-02-11 17:28:02 +0100 | [diff] [blame] | 301 | static inline struct gpio_descs *__must_check |
| 302 | devm_gpiod_get_array(struct device *dev, const char *con_id, |
| 303 | enum gpiod_flags flags) |
| 304 | { |
| 305 | return ERR_PTR(-ENOSYS); |
| 306 | } |
| 307 | |
| 308 | static inline struct gpio_descs *__must_check |
| 309 | devm_gpiod_get_array_optional(struct device *dev, const char *con_id, |
| 310 | enum gpiod_flags flags) |
| 311 | { |
Dmitry Torokhov | 22c4036 | 2017-02-12 17:13:55 -0800 | [diff] [blame] | 312 | return NULL; |
Rojhalat Ibrahim | 331758e | 2015-02-11 17:28:02 +0100 | [diff] [blame] | 313 | } |
| 314 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 315 | static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) |
| 316 | { |
| 317 | might_sleep(); |
| 318 | |
| 319 | /* GPIO can never have been requested */ |
| 320 | WARN_ON(1); |
| 321 | } |
| 322 | |
Rojhalat Ibrahim | 331758e | 2015-02-11 17:28:02 +0100 | [diff] [blame] | 323 | static inline void devm_gpiod_put_array(struct device *dev, |
| 324 | struct gpio_descs *descs) |
| 325 | { |
| 326 | might_sleep(); |
| 327 | |
| 328 | /* GPIO can never have been requested */ |
| 329 | WARN_ON(1); |
| 330 | } |
| 331 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 332 | |
| 333 | static inline int gpiod_get_direction(const struct gpio_desc *desc) |
| 334 | { |
| 335 | /* GPIO can never have been requested */ |
| 336 | WARN_ON(1); |
| 337 | return -ENOSYS; |
| 338 | } |
| 339 | static inline int gpiod_direction_input(struct gpio_desc *desc) |
| 340 | { |
| 341 | /* GPIO can never have been requested */ |
| 342 | WARN_ON(1); |
| 343 | return -ENOSYS; |
| 344 | } |
| 345 | static inline int gpiod_direction_output(struct gpio_desc *desc, int value) |
| 346 | { |
| 347 | /* GPIO can never have been requested */ |
| 348 | WARN_ON(1); |
| 349 | return -ENOSYS; |
| 350 | } |
Philipp Zabel | ef70bbe | 2014-01-07 12:34:11 +0100 | [diff] [blame] | 351 | static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value) |
| 352 | { |
| 353 | /* GPIO can never have been requested */ |
| 354 | WARN_ON(1); |
| 355 | return -ENOSYS; |
| 356 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 357 | |
| 358 | |
| 359 | static inline int gpiod_get_value(const struct gpio_desc *desc) |
| 360 | { |
| 361 | /* GPIO can never have been requested */ |
| 362 | WARN_ON(1); |
| 363 | return 0; |
| 364 | } |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 365 | static inline int gpiod_get_array_value(unsigned int array_size, |
| 366 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 367 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 368 | unsigned long *value_bitmap) |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 369 | { |
| 370 | /* GPIO can never have been requested */ |
| 371 | WARN_ON(1); |
| 372 | return 0; |
| 373 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 374 | static inline void gpiod_set_value(struct gpio_desc *desc, int value) |
| 375 | { |
| 376 | /* GPIO can never have been requested */ |
| 377 | WARN_ON(1); |
| 378 | } |
Geert Uytterhoeven | cf9af0d | 2018-09-27 13:38:09 +0200 | [diff] [blame] | 379 | static inline int gpiod_set_array_value(unsigned int array_size, |
| 380 | struct gpio_desc **desc_array, |
| 381 | struct gpio_array *array_info, |
| 382 | unsigned long *value_bitmap) |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 383 | { |
| 384 | /* GPIO can never have been requested */ |
| 385 | WARN_ON(1); |
Geert Uytterhoeven | cf9af0d | 2018-09-27 13:38:09 +0200 | [diff] [blame] | 386 | return 0; |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 387 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 388 | static inline int gpiod_get_raw_value(const struct gpio_desc *desc) |
| 389 | { |
| 390 | /* GPIO can never have been requested */ |
| 391 | WARN_ON(1); |
| 392 | return 0; |
| 393 | } |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 394 | static inline int gpiod_get_raw_array_value(unsigned int array_size, |
| 395 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 396 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 397 | unsigned long *value_bitmap) |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 398 | { |
| 399 | /* GPIO can never have been requested */ |
| 400 | WARN_ON(1); |
| 401 | return 0; |
| 402 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 403 | static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) |
| 404 | { |
| 405 | /* GPIO can never have been requested */ |
| 406 | WARN_ON(1); |
| 407 | } |
Laura Abbott | 3027743 | 2018-05-21 10:57:07 -0700 | [diff] [blame] | 408 | static inline int gpiod_set_raw_array_value(unsigned int array_size, |
Geert Uytterhoeven | 3c94066 | 2018-09-27 13:38:10 +0200 | [diff] [blame] | 409 | struct gpio_desc **desc_array, |
| 410 | struct gpio_array *array_info, |
| 411 | unsigned long *value_bitmap) |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 412 | { |
| 413 | /* GPIO can never have been requested */ |
| 414 | WARN_ON(1); |
Laura Abbott | 3027743 | 2018-05-21 10:57:07 -0700 | [diff] [blame] | 415 | return 0; |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 416 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 417 | |
| 418 | static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) |
| 419 | { |
| 420 | /* GPIO can never have been requested */ |
| 421 | WARN_ON(1); |
| 422 | return 0; |
| 423 | } |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 424 | static inline int gpiod_get_array_value_cansleep(unsigned int array_size, |
| 425 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 426 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 427 | unsigned long *value_bitmap) |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 428 | { |
| 429 | /* GPIO can never have been requested */ |
| 430 | WARN_ON(1); |
| 431 | return 0; |
| 432 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 433 | static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) |
| 434 | { |
| 435 | /* GPIO can never have been requested */ |
| 436 | WARN_ON(1); |
| 437 | } |
Geert Uytterhoeven | cf9af0d | 2018-09-27 13:38:09 +0200 | [diff] [blame] | 438 | static inline int gpiod_set_array_value_cansleep(unsigned int array_size, |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 439 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 440 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 441 | unsigned long *value_bitmap) |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 442 | { |
| 443 | /* GPIO can never have been requested */ |
| 444 | WARN_ON(1); |
Geert Uytterhoeven | cf9af0d | 2018-09-27 13:38:09 +0200 | [diff] [blame] | 445 | return 0; |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 446 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 447 | static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) |
| 448 | { |
| 449 | /* GPIO can never have been requested */ |
| 450 | WARN_ON(1); |
| 451 | return 0; |
| 452 | } |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 453 | static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size, |
| 454 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 455 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 456 | unsigned long *value_bitmap) |
Lukas Wunner | eec1d56 | 2017-10-12 12:40:10 +0200 | [diff] [blame] | 457 | { |
| 458 | /* GPIO can never have been requested */ |
| 459 | WARN_ON(1); |
| 460 | return 0; |
| 461 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 462 | static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, |
| 463 | int value) |
| 464 | { |
| 465 | /* GPIO can never have been requested */ |
| 466 | WARN_ON(1); |
| 467 | } |
Laura Abbott | 3027743 | 2018-05-21 10:57:07 -0700 | [diff] [blame] | 468 | static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 469 | struct gpio_desc **desc_array, |
Janusz Krzysztofik | 77588c1 | 2018-09-05 23:50:07 +0200 | [diff] [blame] | 470 | struct gpio_array *array_info, |
Janusz Krzysztofik | b9762be | 2018-09-05 23:50:05 +0200 | [diff] [blame] | 471 | unsigned long *value_bitmap) |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 472 | { |
| 473 | /* GPIO can never have been requested */ |
| 474 | WARN_ON(1); |
Laura Abbott | 3027743 | 2018-05-21 10:57:07 -0700 | [diff] [blame] | 475 | return 0; |
Rojhalat Ibrahim | 5f42424 | 2014-11-04 17:12:06 +0100 | [diff] [blame] | 476 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 477 | |
| 478 | static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) |
| 479 | { |
| 480 | /* GPIO can never have been requested */ |
| 481 | WARN_ON(1); |
| 482 | return -ENOSYS; |
| 483 | } |
| 484 | |
Andrew Jeffery | e10f72b | 2017-11-30 14:25:24 +1030 | [diff] [blame] | 485 | static inline int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) |
| 486 | { |
| 487 | /* GPIO can never have been requested */ |
| 488 | WARN_ON(1); |
| 489 | return -ENOSYS; |
| 490 | } |
| 491 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 492 | static inline int gpiod_is_active_low(const struct gpio_desc *desc) |
| 493 | { |
| 494 | /* GPIO can never have been requested */ |
| 495 | WARN_ON(1); |
| 496 | return 0; |
| 497 | } |
| 498 | static inline int gpiod_cansleep(const struct gpio_desc *desc) |
| 499 | { |
| 500 | /* GPIO can never have been requested */ |
| 501 | WARN_ON(1); |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | static inline int gpiod_to_irq(const struct gpio_desc *desc) |
| 506 | { |
| 507 | /* GPIO can never have been requested */ |
| 508 | WARN_ON(1); |
| 509 | return -EINVAL; |
| 510 | } |
| 511 | |
Muchun Song | 18534df | 2018-11-01 21:12:50 +0800 | [diff] [blame] | 512 | static inline int gpiod_set_consumer_name(struct gpio_desc *desc, |
| 513 | const char *name) |
Linus Walleij | 90b39402e | 2018-06-01 13:21:27 +0200 | [diff] [blame] | 514 | { |
| 515 | /* GPIO can never have been requested */ |
| 516 | WARN_ON(1); |
Muchun Song | 18534df | 2018-11-01 21:12:50 +0800 | [diff] [blame] | 517 | return -EINVAL; |
Linus Walleij | 90b39402e | 2018-06-01 13:21:27 +0200 | [diff] [blame] | 518 | } |
| 519 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 520 | static inline struct gpio_desc *gpio_to_desc(unsigned gpio) |
| 521 | { |
Krzysztof Kozlowski | c5510b8 | 2018-12-06 10:45:49 +0100 | [diff] [blame] | 522 | return NULL; |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 523 | } |
Markus Pargmann | c0017ed | 2015-08-14 16:10:59 +0200 | [diff] [blame] | 524 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 525 | static inline int desc_to_gpio(const struct gpio_desc *desc) |
| 526 | { |
| 527 | /* GPIO can never have been requested */ |
| 528 | WARN_ON(1); |
| 529 | return -EINVAL; |
| 530 | } |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 531 | |
Geert Uytterhoeven | 496e7ce | 2015-05-07 01:08:08 -0700 | [diff] [blame] | 532 | /* Child properties interface */ |
Linus Walleij | 92542ed | 2017-12-29 22:52:02 +0100 | [diff] [blame] | 533 | struct device_node; |
Geert Uytterhoeven | 496e7ce | 2015-05-07 01:08:08 -0700 | [diff] [blame] | 534 | struct fwnode_handle; |
| 535 | |
Andy Shevchenko | a264d10 | 2017-01-09 16:02:28 +0200 | [diff] [blame] | 536 | static inline |
Linus Walleij | fe6c473 | 2018-12-06 13:43:42 +0100 | [diff] [blame] | 537 | struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, |
| 538 | const char *propname, int index, |
| 539 | enum gpiod_flags dflags, |
| 540 | const char *label) |
| 541 | { |
| 542 | return ERR_PTR(-ENOSYS); |
| 543 | } |
| 544 | |
| 545 | static inline |
Linus Walleij | 92542ed | 2017-12-29 22:52:02 +0100 | [diff] [blame] | 546 | struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, |
| 547 | struct device_node *node, |
| 548 | const char *propname, int index, |
| 549 | enum gpiod_flags dflags, |
| 550 | const char *label) |
| 551 | { |
| 552 | return ERR_PTR(-ENOSYS); |
| 553 | } |
| 554 | |
| 555 | static inline |
Andy Shevchenko | a264d10 | 2017-01-09 16:02:28 +0200 | [diff] [blame] | 556 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, |
Boris Brezillon | 537b94d | 2017-02-02 14:53:11 +0100 | [diff] [blame] | 557 | const char *propname, int index, |
Alexander Stein | b2987d7 | 2017-01-12 17:39:24 +0100 | [diff] [blame] | 558 | enum gpiod_flags dflags, |
| 559 | const char *label) |
Geert Uytterhoeven | 496e7ce | 2015-05-07 01:08:08 -0700 | [diff] [blame] | 560 | { |
| 561 | return ERR_PTR(-ENOSYS); |
| 562 | } |
| 563 | |
Andy Shevchenko | a264d10 | 2017-01-09 16:02:28 +0200 | [diff] [blame] | 564 | static inline |
Boris Brezillon | 537b94d | 2017-02-02 14:53:11 +0100 | [diff] [blame] | 565 | struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, |
| 566 | const char *con_id, int index, |
| 567 | struct fwnode_handle *child, |
| 568 | enum gpiod_flags flags, |
| 569 | const char *label) |
| 570 | { |
| 571 | return ERR_PTR(-ENOSYS); |
| 572 | } |
| 573 | |
| 574 | #endif /* CONFIG_GPIOLIB */ |
| 575 | |
| 576 | static inline |
Boris Brezillon | 4b09479 | 2017-02-02 14:53:10 +0100 | [diff] [blame] | 577 | struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev, |
| 578 | const char *con_id, |
| 579 | struct fwnode_handle *child, |
| 580 | enum gpiod_flags flags, |
| 581 | const char *label) |
Geert Uytterhoeven | 496e7ce | 2015-05-07 01:08:08 -0700 | [diff] [blame] | 582 | { |
Boris Brezillon | 537b94d | 2017-02-02 14:53:11 +0100 | [diff] [blame] | 583 | return devm_fwnode_get_index_gpiod_from_child(dev, con_id, 0, child, |
| 584 | flags, label); |
Geert Uytterhoeven | 496e7ce | 2015-05-07 01:08:08 -0700 | [diff] [blame] | 585 | } |
| 586 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 587 | #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) |
| 588 | |
| 589 | int gpiod_export(struct gpio_desc *desc, bool direction_may_change); |
| 590 | int gpiod_export_link(struct device *dev, const char *name, |
| 591 | struct gpio_desc *desc); |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 592 | void gpiod_unexport(struct gpio_desc *desc); |
| 593 | |
| 594 | #else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ |
| 595 | |
| 596 | static inline int gpiod_export(struct gpio_desc *desc, |
| 597 | bool direction_may_change) |
| 598 | { |
| 599 | return -ENOSYS; |
| 600 | } |
| 601 | |
| 602 | static inline int gpiod_export_link(struct device *dev, const char *name, |
| 603 | struct gpio_desc *desc) |
| 604 | { |
| 605 | return -ENOSYS; |
| 606 | } |
| 607 | |
Alexandre Courbot | 79a9bec | 2013-10-17 10:21:36 -0700 | [diff] [blame] | 608 | static inline void gpiod_unexport(struct gpio_desc *desc) |
| 609 | { |
| 610 | } |
| 611 | |
| 612 | #endif /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ |
| 613 | |
| 614 | #endif |