xref: /openbmc/linux/drivers/gpio/gpiolib-of.h (revision 380c7ba3)
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 
13 struct gpio_chip;
14 struct gpio_desc;
15 struct gpio_device;
16 
17 #ifdef CONFIG_OF_GPIO
18 struct gpio_desc *of_find_gpio(struct device_node *np,
19 			       const char *con_id,
20 			       unsigned int idx,
21 			       unsigned long *lookupflags);
22 int of_gpiochip_add(struct gpio_chip *gc);
23 void of_gpiochip_remove(struct gpio_chip *gc);
24 int of_gpio_get_count(struct device *dev, const char *con_id);
25 #else
of_find_gpio(struct device_node * np,const char * con_id,unsigned int idx,unsigned long * lookupflags)26 static inline struct gpio_desc *of_find_gpio(struct device_node *np,
27 					     const char *con_id,
28 					     unsigned int idx,
29 					     unsigned long *lookupflags)
30 {
31 	return ERR_PTR(-ENOENT);
32 }
of_gpiochip_add(struct gpio_chip * gc)33 static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; }
of_gpiochip_remove(struct gpio_chip * gc)34 static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
of_gpio_get_count(struct device * dev,const char * con_id)35 static inline int of_gpio_get_count(struct device *dev, const char *con_id)
36 {
37 	return 0;
38 }
39 #endif /* CONFIG_OF_GPIO */
40 
41 extern struct notifier_block gpio_of_notifier;
42 
43 #endif /* GPIOLIB_OF_H */
44