1 /* SPDX-License-Identifier: GPL-2.0 */
3 * ACPI helpers for GPIO API
5 * Copyright (C) 2012,2019 Intel Corporation
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 * @debounce: debounce timeout as provided by ACPI
22 * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
24 struct acpi_gpio_info {
25 struct acpi_device *adev;
26 enum gpiod_flags flags;
31 unsigned int debounce;
36 void acpi_gpiochip_add(struct gpio_chip *chip);
37 void acpi_gpiochip_remove(struct gpio_chip *chip);
39 void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
41 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
42 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
44 int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags,
45 struct acpi_gpio_info *info);
46 int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
47 struct acpi_gpio_info *info);
49 struct gpio_desc *acpi_find_gpio(struct device *dev,
52 enum gpiod_flags *dflags,
53 unsigned long *lookupflags);
54 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
55 const char *propname, int index,
56 struct acpi_gpio_info *info);
58 int acpi_gpio_count(struct device *dev, const char *con_id);
60 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
61 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
63 static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { }
66 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
69 acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
72 acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info)
77 acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
78 struct acpi_gpio_info *info)
83 static inline struct gpio_desc *
84 acpi_find_gpio(struct device *dev, const char *con_id,
85 unsigned int idx, enum gpiod_flags *dflags,
86 unsigned long *lookupflags)
88 return ERR_PTR(-ENOENT);
90 static inline struct gpio_desc *
91 acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname,
92 int index, struct acpi_gpio_info *info)
94 return ERR_PTR(-ENXIO);
96 static inline int acpi_gpio_count(struct device *dev, const char *con_id)
102 #endif /* GPIOLIB_ACPI_H */