Commit | Line | Data |
---|---|---|
af6074fc | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
863fbf49 AV |
2 | /* |
3 | * OF helpers for the GPIO API | |
4 | * | |
5 | * Copyright (c) 2007-2008 MontaVista Software, Inc. | |
6 | * | |
7 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> | |
863fbf49 AV |
8 | */ |
9 | ||
10 | #ifndef __LINUX_OF_GPIO_H | |
11 | #define __LINUX_OF_GPIO_H | |
12 | ||
b908b53d | 13 | #include <linux/compiler.h> |
046e14af AS |
14 | #include <linux/gpio/driver.h> |
15 | #include <linux/gpio.h> /* FIXME: Shouldn't be here */ | |
15c9a0ac | 16 | #include <linux/of.h> |
863fbf49 | 17 | |
b908b53d AV |
18 | struct device_node; |
19 | ||
863fbf49 AV |
20 | #ifdef CONFIG_OF_GPIO |
21 | ||
923d011f | 22 | #include <linux/container_of.h> |
046e14af | 23 | |
863fbf49 AV |
24 | /* |
25 | * OF GPIO chip for memory mapped banks | |
26 | */ | |
27 | struct of_mm_gpio_chip { | |
a19e3da5 | 28 | struct gpio_chip gc; |
863fbf49 AV |
29 | void (*save_regs)(struct of_mm_gpio_chip *mm_gc); |
30 | void __iomem *regs; | |
31 | }; | |
32 | ||
33 | static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) | |
34 | { | |
a19e3da5 | 35 | return container_of(gc, struct of_mm_gpio_chip, gc); |
863fbf49 AV |
36 | } |
37 | ||
40fc56ee DT |
38 | extern int of_get_named_gpio(const struct device_node *np, |
39 | const char *list_name, int index); | |
a6b09191 | 40 | |
3208b0f0 LW |
41 | extern int of_mm_gpiochip_add_data(struct device_node *np, |
42 | struct of_mm_gpio_chip *mm_gc, | |
43 | void *data); | |
d621e8ba | 44 | extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); |
594fa265 | 45 | |
a19e3da5 | 46 | #else /* CONFIG_OF_GPIO */ |
863fbf49 | 47 | |
046e14af AS |
48 | #include <linux/errno.h> |
49 | ||
863fbf49 | 50 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ |
e6ae9a83 | 51 | static inline int of_get_named_gpio(const struct device_node *np, |
a6b09191 JB |
52 | const char *propname, int index) |
53 | { | |
40fc56ee | 54 | return -ENOSYS; |
a6b09191 JB |
55 | } |
56 | ||
40fc56ee | 57 | #endif /* CONFIG_OF_GPIO */ |
b908b53d | 58 | |
863fbf49 | 59 | #endif /* __LINUX_OF_GPIO_H */ |