2017-12-27 18:55:14 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2008-04-11 13:06:45 +00:00
|
|
|
/*
|
|
|
|
* OF helpers for the GPIO API
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007-2008 MontaVista Software, Inc.
|
|
|
|
*
|
|
|
|
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_OF_GPIO_H
|
|
|
|
#define __LINUX_OF_GPIO_H
|
|
|
|
|
2008-12-01 06:30:04 +00:00
|
|
|
#include <linux/compiler.h>
|
2020-02-05 13:43:36 +00:00
|
|
|
#include <linux/gpio/driver.h>
|
|
|
|
#include <linux/gpio.h> /* FIXME: Shouldn't be here */
|
2011-12-12 16:25:57 +00:00
|
|
|
#include <linux/of.h>
|
2008-04-11 13:06:45 +00:00
|
|
|
|
2008-12-01 06:30:04 +00:00
|
|
|
struct device_node;
|
|
|
|
|
2008-04-11 13:06:45 +00:00
|
|
|
#ifdef CONFIG_OF_GPIO
|
|
|
|
|
2022-11-27 21:52:10 +00:00
|
|
|
#include <linux/container_of.h>
|
2020-02-05 13:43:36 +00:00
|
|
|
|
2008-04-11 13:06:45 +00:00
|
|
|
/*
|
|
|
|
* OF GPIO chip for memory mapped banks
|
|
|
|
*/
|
|
|
|
struct of_mm_gpio_chip {
|
2010-06-08 13:48:16 +00:00
|
|
|
struct gpio_chip gc;
|
2008-04-11 13:06:45 +00:00
|
|
|
void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
|
|
|
|
void __iomem *regs;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
|
|
|
|
{
|
2010-06-08 13:48:16 +00:00
|
|
|
return container_of(gc, struct of_mm_gpio_chip, gc);
|
2008-04-11 13:06:45 +00:00
|
|
|
}
|
|
|
|
|
2022-12-19 19:20:15 +00:00
|
|
|
extern int of_get_named_gpio(const struct device_node *np,
|
|
|
|
const char *list_name, int index);
|
2011-06-27 23:49:57 +00:00
|
|
|
|
2015-12-04 14:13:53 +00:00
|
|
|
extern int of_mm_gpiochip_add_data(struct device_node *np,
|
|
|
|
struct of_mm_gpio_chip *mm_gc,
|
|
|
|
void *data);
|
2014-12-17 15:51:13 +00:00
|
|
|
extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
|
2010-06-08 13:48:16 +00:00
|
|
|
|
2010-06-08 13:48:16 +00:00
|
|
|
#else /* CONFIG_OF_GPIO */
|
2008-04-11 13:06:45 +00:00
|
|
|
|
2020-02-05 13:43:36 +00:00
|
|
|
#include <linux/errno.h>
|
|
|
|
|
2008-04-11 13:06:45 +00:00
|
|
|
/* Drivers may not strictly depend on the GPIO support, so let them link. */
|
2021-07-28 14:42:28 +00:00
|
|
|
static inline int of_get_named_gpio(const struct device_node *np,
|
2011-06-27 23:49:57 +00:00
|
|
|
const char *propname, int index)
|
|
|
|
{
|
2022-12-19 19:20:15 +00:00
|
|
|
return -ENOSYS;
|
2011-06-27 23:49:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-19 19:20:15 +00:00
|
|
|
#endif /* CONFIG_OF_GPIO */
|
2008-12-01 06:30:04 +00:00
|
|
|
|
2008-04-11 13:06:45 +00:00
|
|
|
#endif /* __LINUX_OF_GPIO_H */
|