Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #ifndef GPIOLIB_OF_H |
| 4 | #define GPIOLIB_OF_H |
| 5 | |
Andy Shevchenko | 08a149c | 2022-10-07 12:53:44 +0300 | [diff] [blame] | 6 | #include <linux/err.h> |
Andy Shevchenko | 08a149c | 2022-10-07 12:53:44 +0300 | [diff] [blame] | 7 | #include <linux/types.h> |
| 8 | |
| 9 | #include <linux/notifier.h> |
| 10 | |
| 11 | struct device; |
Andy Shevchenko | adcad53 | 2024-02-29 16:51:38 +0200 | [diff] [blame] | 12 | struct fwnode_handle; |
Andy Shevchenko | 08a149c | 2022-10-07 12:53:44 +0300 | [diff] [blame] | 13 | |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 14 | struct gpio_chip; |
Andy Shevchenko | 08a149c | 2022-10-07 12:53:44 +0300 | [diff] [blame] | 15 | struct gpio_desc; |
| 16 | struct gpio_device; |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 17 | |
| 18 | #ifdef CONFIG_OF_GPIO |
Dmitry Torokhov | 07445ae | 2022-11-15 11:16:24 +0100 | [diff] [blame] | 19 | struct gpio_desc *of_find_gpio(struct device_node *np, |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 20 | const char *con_id, |
| 21 | unsigned int idx, |
| 22 | unsigned long *lookupflags); |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 23 | int of_gpiochip_add(struct gpio_chip *gc); |
| 24 | void of_gpiochip_remove(struct gpio_chip *gc); |
Andy Shevchenko | adcad53 | 2024-02-29 16:51:38 +0200 | [diff] [blame] | 25 | int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id); |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 26 | #else |
Dmitry Torokhov | 07445ae | 2022-11-15 11:16:24 +0100 | [diff] [blame] | 27 | static inline struct gpio_desc *of_find_gpio(struct device_node *np, |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 28 | const char *con_id, |
| 29 | unsigned int idx, |
| 30 | unsigned long *lookupflags) |
| 31 | { |
| 32 | return ERR_PTR(-ENOENT); |
| 33 | } |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 34 | static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; } |
| 35 | static inline void of_gpiochip_remove(struct gpio_chip *gc) { } |
Andy Shevchenko | adcad53 | 2024-02-29 16:51:38 +0200 | [diff] [blame] | 36 | static inline int of_gpio_count(const struct fwnode_handle *fwnode, |
| 37 | const char *con_id) |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 38 | { |
| 39 | return 0; |
| 40 | } |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 41 | #endif /* CONFIG_OF_GPIO */ |
| 42 | |
Geert Uytterhoeven | 63636d9 | 2020-02-20 14:01:49 +0100 | [diff] [blame] | 43 | extern struct notifier_block gpio_of_notifier; |
| 44 | |
Linus Walleij | f626d6d | 2019-07-17 09:10:01 +0200 | [diff] [blame] | 45 | #endif /* GPIOLIB_OF_H */ |