mirror of
https://github.com/torvalds/linux.git
synced 2025-11-02 17:49:03 +02:00
gpio: aggregator: export symbols of the GPIO forwarder library
Export all symbols and create header file for the GPIO forwarder library. It will be used in the next changes. Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Link: https://lore.kernel.org/r/20250811-aaeon-up-board-pinctrl-support-v9-6-29f0cbbdfb30@bootlin.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
b94cf35db6
commit
6e986f8852
2 changed files with 233 additions and 6 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <linux/configfs.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/list.h>
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/gpio/forwarder.h>
|
||||
#include <linux/gpio/machine.h>
|
||||
|
||||
#include "dev-sync-probe.h"
|
||||
|
|
@ -475,8 +477,180 @@ static int gpiochip_fwd_setup_delay_line(struct gpiochip_fwd *fwd)
|
|||
}
|
||||
#endif /* !CONFIG_OF_GPIO */
|
||||
|
||||
static struct gpiochip_fwd *
|
||||
devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios)
|
||||
/**
|
||||
* gpiochip_fwd_get_gpiochip - Get the GPIO chip for the GPIO forwarder
|
||||
* @fwd: GPIO forwarder
|
||||
*
|
||||
* Returns: The GPIO chip for the GPIO forwarder
|
||||
*/
|
||||
struct gpio_chip *gpiochip_fwd_get_gpiochip(struct gpiochip_fwd *fwd)
|
||||
{
|
||||
return &fwd->chip;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_get_gpiochip, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_get_direction - Return the current direction of a GPIO forwarder line
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
*
|
||||
* Returns: 0 for output, 1 for input, or an error code in case of error.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_get_direction(struct gpiochip_fwd *fwd, unsigned int offset)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_get_direction(gc, offset);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_get_direction, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_direction_output - Set a GPIO forwarder line direction to
|
||||
* output
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
* @value: value to set
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_direction_output(struct gpiochip_fwd *fwd, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_direction_output(gc, offset, value);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_direction_output, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_direction_input - Set a GPIO forwarder line direction to input
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_direction_input(struct gpiochip_fwd *fwd, unsigned int offset)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_direction_input(gc, offset);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_direction_input, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_get - Return a GPIO forwarder line's value
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
*
|
||||
* Returns: The GPIO's logical value, i.e. taking the ACTIVE_LOW status into
|
||||
* account, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_get(struct gpiochip_fwd *fwd, unsigned int offset)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_get(gc, offset);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_get, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_get_multiple - Get values for multiple GPIO forwarder lines
|
||||
* @fwd: GPIO forwarder
|
||||
* @mask: bit mask array; one bit per line; BITS_PER_LONG bits per word defines
|
||||
* which lines are to be read
|
||||
* @bits: bit value array; one bit per line; BITS_PER_LONG bits per word will
|
||||
* contains the read values for the lines specified by mask
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_get_multiple_locked(gc, mask, bits);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_get_multiple, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_set - Assign value to a GPIO forwarder line.
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
* @value: value to set
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_set(struct gpiochip_fwd *fwd, unsigned int offset, int value)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_set(gc, offset, value);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_set, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_set_multiple - Assign values to multiple GPIO forwarder lines
|
||||
* @fwd: GPIO forwarder
|
||||
* @mask: bit mask array; one bit per output; BITS_PER_LONG bits per word
|
||||
* defines which outputs are to be changed
|
||||
* @bits: bit value array; one bit per output; BITS_PER_LONG bits per word
|
||||
* defines the values the outputs specified by mask are to be set to
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_set_multiple_locked(gc, mask, bits);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_set_multiple, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_set_config - Set @config for a GPIO forwarder line
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
* @config: Same packed config format as generic pinconf
|
||||
*
|
||||
* Returns: 0 on success, %-ENOTSUPP if the controller doesn't support setting
|
||||
* the configuration.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_set_config(struct gpiochip_fwd *fwd, unsigned int offset,
|
||||
unsigned long config)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_set_config(gc, offset, config);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_set_config, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_gpio_to_irq - Return the IRQ corresponding to a GPIO forwarder line
|
||||
* @fwd: GPIO forwarder
|
||||
* @offset: the offset of the line
|
||||
*
|
||||
* Returns: The Linux IRQ corresponding to the passed line, or an error code in
|
||||
* case of error.
|
||||
*/
|
||||
int gpiochip_fwd_gpio_to_irq(struct gpiochip_fwd *fwd, unsigned int offset)
|
||||
{
|
||||
struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
|
||||
|
||||
return gpio_fwd_to_irq(gc, offset);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_to_irq, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* devm_gpiochip_fwd_alloc - Allocate and initialize a new GPIO forwarder
|
||||
* @dev: Parent device pointer
|
||||
* @ngpios: Number of GPIOs in the forwarder
|
||||
*
|
||||
* Returns: An opaque object pointer, or an ERR_PTR()-encoded negative error
|
||||
* code on failure.
|
||||
*/
|
||||
struct gpiochip_fwd *devm_gpiochip_fwd_alloc(struct device *dev,
|
||||
unsigned int ngpios)
|
||||
{
|
||||
struct gpiochip_fwd *fwd;
|
||||
struct gpio_chip *chip;
|
||||
|
|
@ -507,10 +681,18 @@ devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios)
|
|||
|
||||
return fwd;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(devm_gpiochip_fwd_alloc, "GPIO_FORWARDER");
|
||||
|
||||
static int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd,
|
||||
struct gpio_desc *desc,
|
||||
unsigned int offset)
|
||||
/**
|
||||
* gpiochip_fwd_desc_add - Add a GPIO desc in the forwarder
|
||||
* @fwd: GPIO forwarder
|
||||
* @desc: GPIO descriptor to register
|
||||
* @offset: offset for the GPIO in the forwarder
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc,
|
||||
unsigned int offset)
|
||||
{
|
||||
struct gpio_chip *parent = gpiod_to_chip(desc);
|
||||
struct gpio_chip *chip = &fwd->chip;
|
||||
|
|
@ -537,8 +719,15 @@ static int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd,
|
|||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_desc_add, "GPIO_FORWARDER");
|
||||
|
||||
static int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
|
||||
/**
|
||||
* gpiochip_fwd_register - Register a GPIO forwarder
|
||||
* @fwd: GPIO forwarder
|
||||
*
|
||||
* Returns: 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
|
||||
{
|
||||
struct gpio_chip *chip = &fwd->chip;
|
||||
|
||||
|
|
@ -549,6 +738,7 @@ static int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
|
|||
|
||||
return devm_gpiochip_add_data(chip->parent, chip, fwd);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_register, "GPIO_FORWARDER");
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_create() - Create a new GPIO forwarder
|
||||
|
|
|
|||
37
include/linux/gpio/forwarder.h
Normal file
37
include/linux/gpio/forwarder.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __LINUX_GPIO_FORWARDER_H
|
||||
#define __LINUX_GPIO_FORWARDER_H
|
||||
|
||||
struct gpio_desc;
|
||||
struct gpio_chip;
|
||||
struct gpiochip_fwd;
|
||||
|
||||
struct gpiochip_fwd *devm_gpiochip_fwd_alloc(struct device *dev,
|
||||
unsigned int ngpios);
|
||||
int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd,
|
||||
struct gpio_desc *desc, unsigned int offset);
|
||||
int gpiochip_fwd_register(struct gpiochip_fwd *fwd);
|
||||
|
||||
struct gpio_chip *gpiochip_fwd_get_gpiochip(struct gpiochip_fwd *fwd);
|
||||
|
||||
int gpiochip_fwd_gpio_get_direction(struct gpiochip_fwd *fwd,
|
||||
unsigned int offset);
|
||||
int gpiochip_fwd_gpio_direction_input(struct gpiochip_fwd *fwd,
|
||||
unsigned int offset);
|
||||
int gpiochip_fwd_gpio_direction_output(struct gpiochip_fwd *fwd,
|
||||
unsigned int offset,
|
||||
int value);
|
||||
int gpiochip_fwd_gpio_get(struct gpiochip_fwd *fwd, unsigned int offset);
|
||||
int gpiochip_fwd_gpio_get_multiple(struct gpiochip_fwd *fwd,
|
||||
unsigned long *mask,
|
||||
unsigned long *bits);
|
||||
int gpiochip_fwd_gpio_set(struct gpiochip_fwd *fwd, unsigned int offset,
|
||||
int value);
|
||||
int gpiochip_fwd_gpio_set_multiple(struct gpiochip_fwd *fwd,
|
||||
unsigned long *mask,
|
||||
unsigned long *bits);
|
||||
int gpiochip_fwd_gpio_set_config(struct gpiochip_fwd *fwd, unsigned int offset,
|
||||
unsigned long config);
|
||||
int gpiochip_fwd_gpio_to_irq(struct gpiochip_fwd *fwd, unsigned int offset);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue