1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * OF helpers for the GPIO API
5 * Copyright (c) 2007-2008 MontaVista Software, Inc.
7 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
10 #ifndef __LINUX_OF_GPIO_H
11 #define __LINUX_OF_GPIO_H
13 #include <linux/compiler.h>
14 #include <linux/gpio/driver.h>
15 #include <linux/gpio.h> /* FIXME: Shouldn't be here */
22 #include <linux/container_of.h>
25 * OF GPIO chip for memory mapped banks
27 struct of_mm_gpio_chip {
29 void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
33 static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
35 return container_of(gc, struct of_mm_gpio_chip, gc);
38 extern int of_get_named_gpio(const struct device_node *np,
39 const char *list_name, int index);
41 extern int of_mm_gpiochip_add_data(struct device_node *np,
42 struct of_mm_gpio_chip *mm_gc,
44 extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
46 #else /* CONFIG_OF_GPIO */
48 #include <linux/errno.h>
50 /* Drivers may not strictly depend on the GPIO support, so let them link. */
51 static inline int of_get_named_gpio(const struct device_node *np,
52 const char *propname, int index)
57 #endif /* CONFIG_OF_GPIO */
59 #endif /* __LINUX_OF_GPIO_H */