xref: /linux/drivers/gpio/gpiolib-of.h (revision aacc73ceeb8bf664426f0e53db2778a59325bd9f)
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 bool of_gpiochip_instance_match(struct gpio_chip *gc, unsigned int index);
26 int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id);
27 #else
of_find_gpio(struct device_node * np,const char * con_id,unsigned int idx,unsigned long * lookupflags)28 static inline struct gpio_desc *of_find_gpio(struct device_node *np,
29 					     const char *con_id,
30 					     unsigned int idx,
31 					     unsigned long *lookupflags)
32 {
33 	return ERR_PTR(-ENOENT);
34 }
of_gpiochip_add(struct gpio_chip * gc)35 static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; }
of_gpiochip_remove(struct gpio_chip * gc)36 static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
of_gpiochip_instance_match(struct gpio_chip * gc,unsigned int index)37 static inline bool of_gpiochip_instance_match(struct gpio_chip *gc,
38 					      unsigned int index)
39 {
40 	return false;
41 }
of_gpio_count(const struct fwnode_handle * fwnode,const char * con_id)42 static inline int of_gpio_count(const struct fwnode_handle *fwnode,
43 				const char *con_id)
44 {
45 	return 0;
46 }
47 #endif /* CONFIG_OF_GPIO */
48 
49 extern struct notifier_block gpio_of_notifier;
50 
51 #endif /* GPIOLIB_OF_H */
52