xref: /linux/drivers/gpio/gpiolib-of.h (revision 955abe0a1b41de5ba61fe4cd614ebc123084d499)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef GPIOLIB_OF_H
4 #define GPIOLIB_OF_H
5 
6 #include <linux/err.h>
7 #include <linux/types.h>
8 
9 #include <linux/notifier.h>
10 
11 struct device;
12 struct fwnode_handle;
13 
14 struct gpio_chip;
15 struct gpio_desc;
16 struct gpio_device;
17 
18 #ifdef CONFIG_OF_GPIO
19 struct gpio_desc *of_find_gpio(struct device_node *np,
20 			       const char *con_id,
21 			       unsigned int idx,
22 			       unsigned long *lookupflags);
23 int of_gpiochip_add(struct gpio_chip *gc);
24 void of_gpiochip_remove(struct gpio_chip *gc);
25 int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id);
26 #else
27 static inline struct gpio_desc *of_find_gpio(struct device_node *np,
28 					     const char *con_id,
29 					     unsigned int idx,
30 					     unsigned long *lookupflags)
31 {
32 	return ERR_PTR(-ENOENT);
33 }
34 static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; }
35 static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
36 static inline int of_gpio_count(const struct fwnode_handle *fwnode,
37 				const char *con_id)
38 {
39 	return 0;
40 }
41 #endif /* CONFIG_OF_GPIO */
42 
43 extern struct notifier_block gpio_of_notifier;
44 
45 #endif /* GPIOLIB_OF_H */
46