xref: /openbmc/linux/drivers/gpio/gpiolib-acpi.h (revision 0da908c2)
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 #include <linux/err.h>
12 #include <linux/errno.h>
13 #include <linux/types.h>
14 
15 #include <linux/gpio/consumer.h>
16 
17 struct acpi_device;
18 struct device;
19 struct fwnode_handle;
20 
21 struct gpio_chip;
22 struct gpio_desc;
23 struct gpio_device;
24 
25 #ifdef CONFIG_ACPI
26 void acpi_gpiochip_add(struct gpio_chip *chip);
27 void acpi_gpiochip_remove(struct gpio_chip *chip);
28 
29 void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
30 
31 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
32 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
33 
34 struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
35 				 const char *con_id,
36 				 unsigned int idx,
37 				 enum gpiod_flags *dflags,
38 				 unsigned long *lookupflags);
39 
40 int acpi_gpio_count(struct device *dev, const char *con_id);
41 #else
42 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
43 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
44 
45 static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { }
46 
47 static inline void
48 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
49 
50 static inline void
51 acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
52 
53 static inline struct gpio_desc *
54 acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id,
55 	       unsigned int idx, enum gpiod_flags *dflags,
56 	       unsigned long *lookupflags)
57 {
58 	return ERR_PTR(-ENOENT);
59 }
60 static inline int acpi_gpio_count(struct device *dev, const char *con_id)
61 {
62 	return -ENODEV;
63 }
64 #endif
65 
66 #endif /* GPIOLIB_ACPI_H */
67