blob: e476558d947136d12d62abd29c26ca6b9b2d741b [file] [log] [blame]
Andy Shevchenko77cb9072019-07-30 13:43:36 +03001/* 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
11struct 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
Andy Shevchenko8dcb7a12020-11-09 22:53:26 +020021 * @debounce: debounce timeout as provided by ACPI
Andy Shevchenko77cb9072019-07-30 13:43:36 +030022 * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
23 */
24struct acpi_gpio_info {
25 struct acpi_device *adev;
26 enum gpiod_flags flags;
27 bool gpioint;
28 int pin_config;
29 int polarity;
30 int triggering;
Andy Shevchenko8dcb7a12020-11-09 22:53:26 +020031 unsigned int debounce;
Andy Shevchenko77cb9072019-07-30 13:43:36 +030032 unsigned int quirks;
33};
34
35#ifdef CONFIG_ACPI
36void acpi_gpiochip_add(struct gpio_chip *chip);
37void acpi_gpiochip_remove(struct gpio_chip *chip);
38
Andy Shevchenko515321a2021-03-09 11:37:34 +020039void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
40
Andy Shevchenko77cb9072019-07-30 13:43:36 +030041void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
42void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
43
44int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags,
45 struct acpi_gpio_info *info);
46int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
47 struct acpi_gpio_info *info);
48
49struct gpio_desc *acpi_find_gpio(struct device *dev,
50 const char *con_id,
51 unsigned int idx,
52 enum gpiod_flags *dflags,
53 unsigned long *lookupflags);
54struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
55 const char *propname, int index,
56 struct acpi_gpio_info *info);
57
58int acpi_gpio_count(struct device *dev, const char *con_id);
Andy Shevchenko77cb9072019-07-30 13:43:36 +030059#else
60static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
61static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
62
Andy Shevchenko515321a2021-03-09 11:37:34 +020063static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { }
64
Andy Shevchenko77cb9072019-07-30 13:43:36 +030065static inline void
66acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
67
68static inline void
69acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
70
71static inline int
72acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info)
73{
74 return 0;
75}
76static inline int
77acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
78 struct acpi_gpio_info *info)
79{
80 return 0;
81}
82
83static inline struct gpio_desc *
84acpi_find_gpio(struct device *dev, const char *con_id,
85 unsigned int idx, enum gpiod_flags *dflags,
86 unsigned long *lookupflags)
87{
88 return ERR_PTR(-ENOENT);
89}
90static inline struct gpio_desc *
91acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname,
92 int index, struct acpi_gpio_info *info)
93{
94 return ERR_PTR(-ENXIO);
95}
96static inline int acpi_gpio_count(struct device *dev, const char *con_id)
97{
98 return -ENODEV;
99}
Andy Shevchenko77cb9072019-07-30 13:43:36 +0300100#endif
101
102#endif /* GPIOLIB_ACPI_H */