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