Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0+ */
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>
8 */
9
10#ifndef __LINUX_OF_GPIO_H
11#define __LINUX_OF_GPIO_H
12
13#include <linux/compiler.h>
14#include <linux/gpio/driver.h>
15#include <linux/gpio.h> /* FIXME: Shouldn't be here */
16#include <linux/of.h>
17
18struct device_node;
19
20#ifdef CONFIG_OF_GPIO
21
22#include <linux/container_of.h>
23
24/*
25 * OF GPIO chip for memory mapped banks
26 */
27struct of_mm_gpio_chip {
28 struct gpio_chip gc;
29 void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
30 void __iomem *regs;
31};
32
33static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
34{
35 return container_of(gc, struct of_mm_gpio_chip, gc);
36}
37
38extern int of_get_named_gpio(const struct device_node *np,
39 const char *list_name, int index);
40
41extern int of_mm_gpiochip_add_data(struct device_node *np,
42 struct of_mm_gpio_chip *mm_gc,
43 void *data);
44extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
45
46#else /* CONFIG_OF_GPIO */
47
48#include <linux/errno.h>
49
50/* Drivers may not strictly depend on the GPIO support, so let them link. */
51static inline int of_get_named_gpio(const struct device_node *np,
52 const char *propname, int index)
53{
54 return -ENOSYS;
55}
56
57#endif /* CONFIG_OF_GPIO */
58
59#endif /* __LINUX_OF_GPIO_H */