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