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