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 * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping 22 */ 23 struct acpi_gpio_info { 24 struct acpi_device *adev; 25 enum gpiod_flags flags; 26 bool gpioint; 27 int pin_config; 28 int polarity; 29 int triggering; 30 unsigned int quirks; 31 }; 32 33 #ifdef CONFIG_ACPI 34 void acpi_gpiochip_add(struct gpio_chip *chip); 35 void acpi_gpiochip_remove(struct gpio_chip *chip); 36 37 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); 38 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); 39 40 int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, 41 struct acpi_gpio_info *info); 42 int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, 43 struct acpi_gpio_info *info); 44 45 struct gpio_desc *acpi_find_gpio(struct device *dev, 46 const char *con_id, 47 unsigned int idx, 48 enum gpiod_flags *dflags, 49 unsigned long *lookupflags); 50 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, 51 const char *propname, int index, 52 struct acpi_gpio_info *info); 53 54 int acpi_gpio_count(struct device *dev, const char *con_id); 55 #else 56 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } 57 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } 58 59 static inline void 60 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } 61 62 static inline void 63 acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } 64 65 static inline int 66 acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info) 67 { 68 return 0; 69 } 70 static inline int 71 acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, 72 struct acpi_gpio_info *info) 73 { 74 return 0; 75 } 76 77 static inline struct gpio_desc * 78 acpi_find_gpio(struct device *dev, const char *con_id, 79 unsigned int idx, enum gpiod_flags *dflags, 80 unsigned long *lookupflags) 81 { 82 return ERR_PTR(-ENOENT); 83 } 84 static inline struct gpio_desc * 85 acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname, 86 int index, struct acpi_gpio_info *info) 87 { 88 return ERR_PTR(-ENXIO); 89 } 90 static inline int acpi_gpio_count(struct device *dev, const char *con_id) 91 { 92 return -ENODEV; 93 } 94 #endif 95 96 #endif /* GPIOLIB_ACPI_H */ 97