root/include/linux/gpio/consumer.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. gpiod_count
  2. gpiod_get
  3. gpiod_get_index
  4. gpiod_get_optional
  5. gpiod_get_index_optional
  6. gpiod_get_array
  7. gpiod_get_array_optional
  8. gpiod_put
  9. devm_gpiod_unhinge
  10. gpiod_put_array
  11. devm_gpiod_get
  12. devm_gpiod_get_index
  13. devm_gpiod_get_optional
  14. devm_gpiod_get_index_optional
  15. devm_gpiod_get_array
  16. devm_gpiod_get_array_optional
  17. devm_gpiod_put
  18. devm_gpiod_put_array
  19. gpiod_get_direction
  20. gpiod_direction_input
  21. gpiod_direction_output
  22. gpiod_direction_output_raw
  23. gpiod_get_value
  24. gpiod_get_array_value
  25. gpiod_set_value
  26. gpiod_set_array_value
  27. gpiod_get_raw_value
  28. gpiod_get_raw_array_value
  29. gpiod_set_raw_value
  30. gpiod_set_raw_array_value
  31. gpiod_get_value_cansleep
  32. gpiod_get_array_value_cansleep
  33. gpiod_set_value_cansleep
  34. gpiod_set_array_value_cansleep
  35. gpiod_get_raw_value_cansleep
  36. gpiod_get_raw_array_value_cansleep
  37. gpiod_set_raw_value_cansleep
  38. gpiod_set_raw_array_value_cansleep
  39. gpiod_set_debounce
  40. gpiod_set_transitory
  41. gpiod_toggle_active_low
  42. gpiod_is_active_low
  43. gpiod_cansleep
  44. gpiod_to_irq
  45. gpiod_set_consumer_name
  46. gpio_to_desc
  47. desc_to_gpio
  48. fwnode_get_named_gpiod
  49. devm_fwnode_get_index_gpiod_from_child
  50. devm_fwnode_get_gpiod_from_child
  51. gpiod_get_from_of_node
  52. devm_gpiod_get_from_of_node
  53. acpi_dev_add_driver_gpios
  54. acpi_dev_remove_driver_gpios
  55. devm_acpi_dev_add_driver_gpios
  56. devm_acpi_dev_remove_driver_gpios
  57. gpiod_export
  58. gpiod_export_link
  59. gpiod_unexport

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 #ifndef __LINUX_GPIO_CONSUMER_H
   3 #define __LINUX_GPIO_CONSUMER_H
   4 
   5 #include <linux/bug.h>
   6 #include <linux/err.h>
   7 #include <linux/kernel.h>
   8 
   9 struct device;
  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 
  20 /**
  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 /**
  29  * Struct containing an array of descriptors that can be obtained using
  30  * gpiod_get_array().
  31  */
  32 struct gpio_descs {
  33         struct gpio_array *info;
  34         unsigned int ndescs;
  35         struct gpio_desc *desc[];
  36 };
  37 
  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)
  41 #define GPIOD_FLAGS_BIT_OPEN_DRAIN      BIT(3)
  42 #define GPIOD_FLAGS_BIT_NONEXCLUSIVE    BIT(4)
  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,
  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,
  56 };
  57 
  58 #ifdef CONFIG_GPIOLIB
  59 
  60 /* Return the number of GPIOs associated with a device / function */
  61 int gpiod_count(struct device *dev, const char *con_id);
  62 
  63 /* Acquire and dispose GPIOs */
  64 struct gpio_desc *__must_check gpiod_get(struct device *dev,
  65                                          const char *con_id,
  66                                          enum gpiod_flags flags);
  67 struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
  68                                                const char *con_id,
  69                                                unsigned int idx,
  70                                                enum gpiod_flags flags);
  71 struct gpio_desc *__must_check gpiod_get_optional(struct device *dev,
  72                                                   const char *con_id,
  73                                                   enum gpiod_flags flags);
  74 struct gpio_desc *__must_check gpiod_get_index_optional(struct device *dev,
  75                                                         const char *con_id,
  76                                                         unsigned int index,
  77                                                         enum gpiod_flags flags);
  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);
  84 void gpiod_put(struct gpio_desc *desc);
  85 void gpiod_put_array(struct gpio_descs *descs);
  86 
  87 struct gpio_desc *__must_check devm_gpiod_get(struct device *dev,
  88                                               const char *con_id,
  89                                               enum gpiod_flags flags);
  90 struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
  91                                                     const char *con_id,
  92                                                     unsigned int idx,
  93                                                     enum gpiod_flags flags);
  94 struct gpio_desc *__must_check devm_gpiod_get_optional(struct device *dev,
  95                                                        const char *con_id,
  96                                                        enum gpiod_flags flags);
  97 struct gpio_desc *__must_check
  98 devm_gpiod_get_index_optional(struct device *dev, const char *con_id,
  99                               unsigned int index, enum gpiod_flags flags);
 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);
 106 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc);
 107 void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc);
 108 void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs);
 109 
 110 int gpiod_get_direction(struct gpio_desc *desc);
 111 int gpiod_direction_input(struct gpio_desc *desc);
 112 int gpiod_direction_output(struct gpio_desc *desc, int value);
 113 int gpiod_direction_output_raw(struct gpio_desc *desc, int value);
 114 
 115 /* Value get/set from non-sleeping context */
 116 int gpiod_get_value(const struct gpio_desc *desc);
 117 int gpiod_get_array_value(unsigned int array_size,
 118                           struct gpio_desc **desc_array,
 119                           struct gpio_array *array_info,
 120                           unsigned long *value_bitmap);
 121 void gpiod_set_value(struct gpio_desc *desc, int value);
 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);
 126 int gpiod_get_raw_value(const struct gpio_desc *desc);
 127 int gpiod_get_raw_array_value(unsigned int array_size,
 128                               struct gpio_desc **desc_array,
 129                               struct gpio_array *array_info,
 130                               unsigned long *value_bitmap);
 131 void gpiod_set_raw_value(struct gpio_desc *desc, int value);
 132 int gpiod_set_raw_array_value(unsigned int array_size,
 133                               struct gpio_desc **desc_array,
 134                               struct gpio_array *array_info,
 135                               unsigned long *value_bitmap);
 136 
 137 /* Value get/set from sleeping context */
 138 int gpiod_get_value_cansleep(const struct gpio_desc *desc);
 139 int gpiod_get_array_value_cansleep(unsigned int array_size,
 140                                    struct gpio_desc **desc_array,
 141                                    struct gpio_array *array_info,
 142                                    unsigned long *value_bitmap);
 143 void gpiod_set_value_cansleep(struct gpio_desc *desc, int value);
 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);
 148 int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc);
 149 int gpiod_get_raw_array_value_cansleep(unsigned int array_size,
 150                                        struct gpio_desc **desc_array,
 151                                        struct gpio_array *array_info,
 152                                        unsigned long *value_bitmap);
 153 void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value);
 154 int gpiod_set_raw_array_value_cansleep(unsigned int array_size,
 155                                        struct gpio_desc **desc_array,
 156                                        struct gpio_array *array_info,
 157                                        unsigned long *value_bitmap);
 158 
 159 int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce);
 160 int gpiod_set_transitory(struct gpio_desc *desc, bool transitory);
 161 void gpiod_toggle_active_low(struct gpio_desc *desc);
 162 
 163 int gpiod_is_active_low(const struct gpio_desc *desc);
 164 int gpiod_cansleep(const struct gpio_desc *desc);
 165 
 166 int gpiod_to_irq(const struct gpio_desc *desc);
 167 int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
 168 
 169 /* Convert between the old gpio_ and new gpiod_ interfaces */
 170 struct gpio_desc *gpio_to_desc(unsigned gpio);
 171 int desc_to_gpio(const struct gpio_desc *desc);
 172 
 173 /* Child properties interface */
 174 struct fwnode_handle;
 175 
 176 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 177                                          const char *propname, int index,
 178                                          enum gpiod_flags dflags,
 179                                          const char *label);
 180 struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 181                                                 const char *con_id, int index,
 182                                                 struct fwnode_handle *child,
 183                                                 enum gpiod_flags flags,
 184                                                 const char *label);
 185 
 186 #else /* CONFIG_GPIOLIB */
 187 
 188 static inline int gpiod_count(struct device *dev, const char *con_id)
 189 {
 190         return 0;
 191 }
 192 
 193 static inline struct gpio_desc *__must_check gpiod_get(struct device *dev,
 194                                                        const char *con_id,
 195                                                        enum gpiod_flags flags)
 196 {
 197         return ERR_PTR(-ENOSYS);
 198 }
 199 static inline struct gpio_desc *__must_check
 200 gpiod_get_index(struct device *dev,
 201                 const char *con_id,
 202                 unsigned int idx,
 203                 enum gpiod_flags flags)
 204 {
 205         return ERR_PTR(-ENOSYS);
 206 }
 207 
 208 static inline struct gpio_desc *__must_check
 209 gpiod_get_optional(struct device *dev, const char *con_id,
 210                    enum gpiod_flags flags)
 211 {
 212         return NULL;
 213 }
 214 
 215 static inline struct gpio_desc *__must_check
 216 gpiod_get_index_optional(struct device *dev, const char *con_id,
 217                          unsigned int index, enum gpiod_flags flags)
 218 {
 219         return NULL;
 220 }
 221 
 222 static inline struct gpio_descs *__must_check
 223 gpiod_get_array(struct device *dev, const char *con_id,
 224                 enum gpiod_flags flags)
 225 {
 226         return ERR_PTR(-ENOSYS);
 227 }
 228 
 229 static inline struct gpio_descs *__must_check
 230 gpiod_get_array_optional(struct device *dev, const char *con_id,
 231                          enum gpiod_flags flags)
 232 {
 233         return NULL;
 234 }
 235 
 236 static inline void gpiod_put(struct gpio_desc *desc)
 237 {
 238         might_sleep();
 239 
 240         /* GPIO can never have been requested */
 241         WARN_ON(desc);
 242 }
 243 
 244 static inline void devm_gpiod_unhinge(struct device *dev,
 245                                       struct gpio_desc *desc)
 246 {
 247         might_sleep();
 248 
 249         /* GPIO can never have been requested */
 250         WARN_ON(desc);
 251 }
 252 
 253 static inline void gpiod_put_array(struct gpio_descs *descs)
 254 {
 255         might_sleep();
 256 
 257         /* GPIO can never have been requested */
 258         WARN_ON(descs);
 259 }
 260 
 261 static inline struct gpio_desc *__must_check
 262 devm_gpiod_get(struct device *dev,
 263                  const char *con_id,
 264                  enum gpiod_flags flags)
 265 {
 266         return ERR_PTR(-ENOSYS);
 267 }
 268 static inline
 269 struct gpio_desc *__must_check
 270 devm_gpiod_get_index(struct device *dev,
 271                        const char *con_id,
 272                        unsigned int idx,
 273                        enum gpiod_flags flags)
 274 {
 275         return ERR_PTR(-ENOSYS);
 276 }
 277 
 278 static inline struct gpio_desc *__must_check
 279 devm_gpiod_get_optional(struct device *dev, const char *con_id,
 280                           enum gpiod_flags flags)
 281 {
 282         return NULL;
 283 }
 284 
 285 static inline struct gpio_desc *__must_check
 286 devm_gpiod_get_index_optional(struct device *dev, const char *con_id,
 287                                 unsigned int index, enum gpiod_flags flags)
 288 {
 289         return NULL;
 290 }
 291 
 292 static inline struct gpio_descs *__must_check
 293 devm_gpiod_get_array(struct device *dev, const char *con_id,
 294                      enum gpiod_flags flags)
 295 {
 296         return ERR_PTR(-ENOSYS);
 297 }
 298 
 299 static inline struct gpio_descs *__must_check
 300 devm_gpiod_get_array_optional(struct device *dev, const char *con_id,
 301                               enum gpiod_flags flags)
 302 {
 303         return NULL;
 304 }
 305 
 306 static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc)
 307 {
 308         might_sleep();
 309 
 310         /* GPIO can never have been requested */
 311         WARN_ON(desc);
 312 }
 313 
 314 static inline void devm_gpiod_put_array(struct device *dev,
 315                                         struct gpio_descs *descs)
 316 {
 317         might_sleep();
 318 
 319         /* GPIO can never have been requested */
 320         WARN_ON(descs);
 321 }
 322 
 323 
 324 static inline int gpiod_get_direction(const struct gpio_desc *desc)
 325 {
 326         /* GPIO can never have been requested */
 327         WARN_ON(desc);
 328         return -ENOSYS;
 329 }
 330 static inline int gpiod_direction_input(struct gpio_desc *desc)
 331 {
 332         /* GPIO can never have been requested */
 333         WARN_ON(desc);
 334         return -ENOSYS;
 335 }
 336 static inline int gpiod_direction_output(struct gpio_desc *desc, int value)
 337 {
 338         /* GPIO can never have been requested */
 339         WARN_ON(desc);
 340         return -ENOSYS;
 341 }
 342 static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value)
 343 {
 344         /* GPIO can never have been requested */
 345         WARN_ON(desc);
 346         return -ENOSYS;
 347 }
 348 
 349 
 350 static inline int gpiod_get_value(const struct gpio_desc *desc)
 351 {
 352         /* GPIO can never have been requested */
 353         WARN_ON(desc);
 354         return 0;
 355 }
 356 static inline int gpiod_get_array_value(unsigned int array_size,
 357                                         struct gpio_desc **desc_array,
 358                                         struct gpio_array *array_info,
 359                                         unsigned long *value_bitmap)
 360 {
 361         /* GPIO can never have been requested */
 362         WARN_ON(desc_array);
 363         return 0;
 364 }
 365 static inline void gpiod_set_value(struct gpio_desc *desc, int value)
 366 {
 367         /* GPIO can never have been requested */
 368         WARN_ON(desc);
 369 }
 370 static inline int gpiod_set_array_value(unsigned int array_size,
 371                                         struct gpio_desc **desc_array,
 372                                         struct gpio_array *array_info,
 373                                         unsigned long *value_bitmap)
 374 {
 375         /* GPIO can never have been requested */
 376         WARN_ON(desc_array);
 377         return 0;
 378 }
 379 static inline int gpiod_get_raw_value(const struct gpio_desc *desc)
 380 {
 381         /* GPIO can never have been requested */
 382         WARN_ON(desc);
 383         return 0;
 384 }
 385 static inline int gpiod_get_raw_array_value(unsigned int array_size,
 386                                             struct gpio_desc **desc_array,
 387                                             struct gpio_array *array_info,
 388                                             unsigned long *value_bitmap)
 389 {
 390         /* GPIO can never have been requested */
 391         WARN_ON(desc_array);
 392         return 0;
 393 }
 394 static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value)
 395 {
 396         /* GPIO can never have been requested */
 397         WARN_ON(desc);
 398 }
 399 static inline int gpiod_set_raw_array_value(unsigned int array_size,
 400                                             struct gpio_desc **desc_array,
 401                                             struct gpio_array *array_info,
 402                                             unsigned long *value_bitmap)
 403 {
 404         /* GPIO can never have been requested */
 405         WARN_ON(desc_array);
 406         return 0;
 407 }
 408 
 409 static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc)
 410 {
 411         /* GPIO can never have been requested */
 412         WARN_ON(desc);
 413         return 0;
 414 }
 415 static inline int gpiod_get_array_value_cansleep(unsigned int array_size,
 416                                      struct gpio_desc **desc_array,
 417                                      struct gpio_array *array_info,
 418                                      unsigned long *value_bitmap)
 419 {
 420         /* GPIO can never have been requested */
 421         WARN_ON(desc_array);
 422         return 0;
 423 }
 424 static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
 425 {
 426         /* GPIO can never have been requested */
 427         WARN_ON(desc);
 428 }
 429 static inline int gpiod_set_array_value_cansleep(unsigned int array_size,
 430                                             struct gpio_desc **desc_array,
 431                                             struct gpio_array *array_info,
 432                                             unsigned long *value_bitmap)
 433 {
 434         /* GPIO can never have been requested */
 435         WARN_ON(desc_array);
 436         return 0;
 437 }
 438 static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc)
 439 {
 440         /* GPIO can never have been requested */
 441         WARN_ON(desc);
 442         return 0;
 443 }
 444 static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size,
 445                                                struct gpio_desc **desc_array,
 446                                                struct gpio_array *array_info,
 447                                                unsigned long *value_bitmap)
 448 {
 449         /* GPIO can never have been requested */
 450         WARN_ON(desc_array);
 451         return 0;
 452 }
 453 static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc,
 454                                                 int value)
 455 {
 456         /* GPIO can never have been requested */
 457         WARN_ON(desc);
 458 }
 459 static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size,
 460                                                 struct gpio_desc **desc_array,
 461                                                 struct gpio_array *array_info,
 462                                                 unsigned long *value_bitmap)
 463 {
 464         /* GPIO can never have been requested */
 465         WARN_ON(desc_array);
 466         return 0;
 467 }
 468 
 469 static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
 470 {
 471         /* GPIO can never have been requested */
 472         WARN_ON(desc);
 473         return -ENOSYS;
 474 }
 475 
 476 static inline int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
 477 {
 478         /* GPIO can never have been requested */
 479         WARN_ON(desc);
 480         return -ENOSYS;
 481 }
 482 
 483 static inline void gpiod_toggle_active_low(struct gpio_desc *desc)
 484 {
 485         /* GPIO can never have been requested */
 486         WARN_ON(desc);
 487 }
 488 
 489 static inline int gpiod_is_active_low(const struct gpio_desc *desc)
 490 {
 491         /* GPIO can never have been requested */
 492         WARN_ON(desc);
 493         return 0;
 494 }
 495 static inline int gpiod_cansleep(const struct gpio_desc *desc)
 496 {
 497         /* GPIO can never have been requested */
 498         WARN_ON(desc);
 499         return 0;
 500 }
 501 
 502 static inline int gpiod_to_irq(const struct gpio_desc *desc)
 503 {
 504         /* GPIO can never have been requested */
 505         WARN_ON(desc);
 506         return -EINVAL;
 507 }
 508 
 509 static inline int gpiod_set_consumer_name(struct gpio_desc *desc,
 510                                           const char *name)
 511 {
 512         /* GPIO can never have been requested */
 513         WARN_ON(desc);
 514         return -EINVAL;
 515 }
 516 
 517 static inline struct gpio_desc *gpio_to_desc(unsigned gpio)
 518 {
 519         return NULL;
 520 }
 521 
 522 static inline int desc_to_gpio(const struct gpio_desc *desc)
 523 {
 524         /* GPIO can never have been requested */
 525         WARN_ON(desc);
 526         return -EINVAL;
 527 }
 528 
 529 /* Child properties interface */
 530 struct fwnode_handle;
 531 
 532 static inline
 533 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 534                                          const char *propname, int index,
 535                                          enum gpiod_flags dflags,
 536                                          const char *label)
 537 {
 538         return ERR_PTR(-ENOSYS);
 539 }
 540 
 541 static inline
 542 struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 543                                                 const char *con_id, int index,
 544                                                 struct fwnode_handle *child,
 545                                                 enum gpiod_flags flags,
 546                                                 const char *label)
 547 {
 548         return ERR_PTR(-ENOSYS);
 549 }
 550 
 551 #endif /* CONFIG_GPIOLIB */
 552 
 553 static inline
 554 struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
 555                                                    const char *con_id,
 556                                                    struct fwnode_handle *child,
 557                                                    enum gpiod_flags flags,
 558                                                    const char *label)
 559 {
 560         return devm_fwnode_get_index_gpiod_from_child(dev, con_id, 0, child,
 561                                                       flags, label);
 562 }
 563 
 564 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO)
 565 struct device_node;
 566 
 567 struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
 568                                          const char *propname, int index,
 569                                          enum gpiod_flags dflags,
 570                                          const char *label);
 571 
 572 #else  /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */
 573 
 574 struct device_node;
 575 
 576 static inline
 577 struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
 578                                          const char *propname, int index,
 579                                          enum gpiod_flags dflags,
 580                                          const char *label)
 581 {
 582         return ERR_PTR(-ENOSYS);
 583 }
 584 
 585 #endif /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */
 586 
 587 #ifdef CONFIG_GPIOLIB
 588 struct device_node;
 589 
 590 struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
 591                                               struct device_node *node,
 592                                               const char *propname, int index,
 593                                               enum gpiod_flags dflags,
 594                                               const char *label);
 595 
 596 #else  /* CONFIG_GPIOLIB */
 597 
 598 struct device_node;
 599 
 600 static inline
 601 struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
 602                                               struct device_node *node,
 603                                               const char *propname, int index,
 604                                               enum gpiod_flags dflags,
 605                                               const char *label)
 606 {
 607         return ERR_PTR(-ENOSYS);
 608 }
 609 
 610 #endif /* CONFIG_GPIOLIB */
 611 
 612 struct acpi_gpio_params {
 613         unsigned int crs_entry_index;
 614         unsigned int line_index;
 615         bool active_low;
 616 };
 617 
 618 struct acpi_gpio_mapping {
 619         const char *name;
 620         const struct acpi_gpio_params *data;
 621         unsigned int size;
 622 
 623 /* Ignore IoRestriction field */
 624 #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION       BIT(0)
 625 /*
 626  * When ACPI GPIO mapping table is in use the index parameter inside it
 627  * refers to the GPIO resource in _CRS method. That index has no
 628  * distinction of actual type of the resource. When consumer wants to
 629  * get GpioIo type explicitly, this quirk may be used.
 630  */
 631 #define ACPI_GPIO_QUIRK_ONLY_GPIOIO             BIT(1)
 632 
 633         unsigned int quirks;
 634 };
 635 
 636 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI)
 637 
 638 struct acpi_device;
 639 
 640 int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 641                               const struct acpi_gpio_mapping *gpios);
 642 void acpi_dev_remove_driver_gpios(struct acpi_device *adev);
 643 
 644 int devm_acpi_dev_add_driver_gpios(struct device *dev,
 645                                    const struct acpi_gpio_mapping *gpios);
 646 void devm_acpi_dev_remove_driver_gpios(struct device *dev);
 647 
 648 #else  /* CONFIG_GPIOLIB && CONFIG_ACPI */
 649 
 650 struct acpi_device;
 651 
 652 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 653                               const struct acpi_gpio_mapping *gpios)
 654 {
 655         return -ENXIO;
 656 }
 657 static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
 658 
 659 static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
 660                               const struct acpi_gpio_mapping *gpios)
 661 {
 662         return -ENXIO;
 663 }
 664 static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
 665 
 666 #endif /* CONFIG_GPIOLIB && CONFIG_ACPI */
 667 
 668 
 669 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
 670 
 671 int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
 672 int gpiod_export_link(struct device *dev, const char *name,
 673                       struct gpio_desc *desc);
 674 void gpiod_unexport(struct gpio_desc *desc);
 675 
 676 #else  /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
 677 
 678 static inline int gpiod_export(struct gpio_desc *desc,
 679                                bool direction_may_change)
 680 {
 681         return -ENOSYS;
 682 }
 683 
 684 static inline int gpiod_export_link(struct device *dev, const char *name,
 685                                     struct gpio_desc *desc)
 686 {
 687         return -ENOSYS;
 688 }
 689 
 690 static inline void gpiod_unexport(struct gpio_desc *desc)
 691 {
 692 }
 693 
 694 #endif /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
 695 
 696 #endif

/* [<][>][^][v][top][bottom][index][help] */