blob: 16d6ac8cb156c02232ea868b755bbdc46c78e3c7 [file] [log] [blame]
Linus Walleijf626d6d2019-07-17 09:10:01 +02001/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef GPIOLIB_OF_H
4#define GPIOLIB_OF_H
5
Andy Shevchenko08a149c2022-10-07 12:53:44 +03006#include <linux/err.h>
Andy Shevchenko08a149c2022-10-07 12:53:44 +03007#include <linux/types.h>
8
9#include <linux/notifier.h>
10
11struct device;
Andy Shevchenkoadcad532024-02-29 16:51:38 +020012struct fwnode_handle;
Andy Shevchenko08a149c2022-10-07 12:53:44 +030013
Linus Walleijf626d6d2019-07-17 09:10:01 +020014struct gpio_chip;
Andy Shevchenko08a149c2022-10-07 12:53:44 +030015struct gpio_desc;
16struct gpio_device;
Linus Walleijf626d6d2019-07-17 09:10:01 +020017
18#ifdef CONFIG_OF_GPIO
Dmitry Torokhov07445ae2022-11-15 11:16:24 +010019struct gpio_desc *of_find_gpio(struct device_node *np,
Linus Walleijf626d6d2019-07-17 09:10:01 +020020 const char *con_id,
21 unsigned int idx,
22 unsigned long *lookupflags);
Linus Walleijf626d6d2019-07-17 09:10:01 +020023int of_gpiochip_add(struct gpio_chip *gc);
24void of_gpiochip_remove(struct gpio_chip *gc);
Andy Shevchenkoadcad532024-02-29 16:51:38 +020025int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id);
Linus Walleijf626d6d2019-07-17 09:10:01 +020026#else
Dmitry Torokhov07445ae2022-11-15 11:16:24 +010027static inline struct gpio_desc *of_find_gpio(struct device_node *np,
Linus Walleijf626d6d2019-07-17 09:10:01 +020028 const char *con_id,
29 unsigned int idx,
30 unsigned long *lookupflags)
31{
32 return ERR_PTR(-ENOENT);
33}
Linus Walleijf626d6d2019-07-17 09:10:01 +020034static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; }
35static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
Andy Shevchenkoadcad532024-02-29 16:51:38 +020036static inline int of_gpio_count(const struct fwnode_handle *fwnode,
37 const char *con_id)
Linus Walleijf626d6d2019-07-17 09:10:01 +020038{
39 return 0;
40}
Linus Walleijf626d6d2019-07-17 09:10:01 +020041#endif /* CONFIG_OF_GPIO */
42
Geert Uytterhoeven63636d92020-02-20 14:01:49 +010043extern struct notifier_block gpio_of_notifier;
44
Linus Walleijf626d6d2019-07-17 09:10:01 +020045#endif /* GPIOLIB_OF_H */