1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * ACPI helpers for GPIO API 4 * 5 * Copyright (C) 2012,2019 Intel Corporation 6 */ 7 8 #ifndef GPIOLIB_ACPI_H 9 #define GPIOLIB_ACPI_H 10 11 struct acpi_device; 12 13 /** 14 * struct acpi_gpio_info - ACPI GPIO specific information 15 * @adev: reference to ACPI device which consumes GPIO resource 16 * @flags: GPIO initialization flags 17 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo 18 * @pin_config: pin bias as provided by ACPI 19 * @polarity: interrupt polarity as provided by ACPI 20 * @triggering: triggering type as provided by ACPI 21 * @wake_capable: wake capability as provided by ACPI 22 * @debounce: debounce timeout as provided by ACPI 23 * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping 24 */ 25 struct acpi_gpio_info { 26 struct acpi_device *adev; 27 enum gpiod_flags flags; 28 bool gpioint; 29 int pin_config; 30 int polarity; 31 int triggering; 32 bool wake_capable; 33 unsigned int debounce; 34 unsigned int quirks; 35 }; 36 37 #ifdef CONFIG_ACPI 38 void acpi_gpiochip_add(struct gpio_chip *chip); 39 void acpi_gpiochip_remove(struct gpio_chip *chip); 40 41 void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev); 42 43 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); 44 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); 45 46 int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, 47 struct acpi_gpio_info *info); 48 int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, 49 struct acpi_gpio_info *info); 50 51 struct gpio_desc *acpi_find_gpio(struct device *dev, 52 const char *con_id, 53 unsigned int idx, 54 enum gpiod_flags *dflags, 55 unsigned long *lookupflags); 56 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, 57 const char *propname, int index, 58 struct acpi_gpio_info *info); 59 60 int acpi_gpio_count(struct device *dev, const char *con_id); 61 #else 62 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } 63 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } 64 65 static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { } 66 67 static inline void 68 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } 69 70 static inline void 71 acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } 72 73 static inline int 74 acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info) 75 { 76 return 0; 77 } 78 static inline int 79 acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, 80 struct acpi_gpio_info *info) 81 { 82 return 0; 83 } 84 85 static inline struct gpio_desc * 86 acpi_find_gpio(struct device *dev, const char *con_id, 87 unsigned int idx, enum gpiod_flags *dflags, 88 unsigned long *lookupflags) 89 { 90 return ERR_PTR(-ENOENT); 91 } 92 static inline struct gpio_desc * 93 acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname, 94 int index, struct acpi_gpio_info *info) 95 { 96 return ERR_PTR(-ENXIO); 97 } 98 static inline int acpi_gpio_count(struct device *dev, const char *con_id) 99 { 100 return -ENODEV; 101 } 102 #endif 103 104 #endif /* GPIOLIB_ACPI_H */ 105