mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
gpiolib: add get_config() and gpiochip_generic_get_config()
A chip with a pin control backend sets a line's configuration through set_config() and gpiochip_generic_config(), but has no way to read one back. gpio-mmio needs that to learn the direction of a line whose direction lives in the pin controller. Add the optional get_config() callback, taking the packed parameter to query and returning its bare argument the way pinctrl_gpio_get_config() does, and gpiochip_generic_get_config() as the pin control backed implementation, the mirror of gpiochip_generic_config(): a chip without pin ranges, or a kernel without pinctrl, gets -ENOTSUPP. Nothing in gpiolib calls get_config() and there is no consumer API; it is for the chip's own use. Suggested-by: Linus Walleij <linusw@kernel.org> Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260915080501.329424-4-mehmet.fide@gmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
parent
9fbdc9ab1c
commit
fc291104d0
|
|
@ -134,6 +134,13 @@ ending up in the pin control back-end "behind" the GPIO controller, usually
|
|||
closer to the actual pins. This way the pin controller can manage the below
|
||||
listed GPIO configurations.
|
||||
|
||||
The optional .get_config() callback reads a configuration back: the packed
|
||||
parameter to query goes in, its bare argument comes out, the way
|
||||
pinctrl_gpio_get_config() answers. gpiochip_generic_get_config() is its pin
|
||||
control backed counterpart. Nothing in gpiolib calls it; it is for the GPIO
|
||||
driver's own use, for example to learn the direction of a line when the pin
|
||||
controller owns it.
|
||||
|
||||
If a pin controller back-end is used, the GPIO controller or hardware
|
||||
description needs to provide "GPIO ranges" mapping the GPIO line offsets to pin
|
||||
numbers on the pin controller so they can properly cross-reference each other.
|
||||
|
|
|
|||
|
|
@ -2440,6 +2440,27 @@ int gpiochip_generic_config(struct gpio_chip *gc, unsigned int offset,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(gpiochip_generic_config);
|
||||
|
||||
/**
|
||||
* gpiochip_generic_get_config() - read back the configuration of a pin
|
||||
* @gc: the gpiochip owning the GPIO
|
||||
* @offset: the offset of the GPIO to query
|
||||
* @config: the packed parameter to query, replaced by its bare argument
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, or negative errno on failure.
|
||||
*/
|
||||
int gpiochip_generic_get_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long *config)
|
||||
{
|
||||
#ifdef CONFIG_PINCTRL
|
||||
if (list_empty(&gc->gpiodev->pin_ranges))
|
||||
return -ENOTSUPP;
|
||||
#endif
|
||||
|
||||
return pinctrl_gpio_get_config(gc, offset, config);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpiochip_generic_get_config);
|
||||
|
||||
#ifdef CONFIG_PINCTRL
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -359,6 +359,10 @@ struct gpio_irq_chip {
|
|||
* @set_config: optional hook for all kinds of settings. Uses the same
|
||||
* packed config format as generic pinconf. Must return 0 on success and
|
||||
* a negative error number on failure.
|
||||
* @get_config: optional hook to read back a setting. Takes the packed
|
||||
* generic pinconf parameter to query and returns its bare argument in
|
||||
* the same variable, like pinctrl_gpio_get_config(). Must return 0 on
|
||||
* success and a negative error number on failure.
|
||||
* @to_irq: optional hook supporting non-static gpiod_to_irq() mappings;
|
||||
* implementation may not sleep
|
||||
* @dbg_show: optional routine to show contents in debugfs; default code
|
||||
|
|
@ -434,6 +438,9 @@ struct gpio_chip {
|
|||
int (*set_config)(struct gpio_chip *gc,
|
||||
unsigned int offset,
|
||||
unsigned long config);
|
||||
int (*get_config)(struct gpio_chip *gc,
|
||||
unsigned int offset,
|
||||
unsigned long *config);
|
||||
int (*to_irq)(struct gpio_chip *gc,
|
||||
unsigned int offset);
|
||||
|
||||
|
|
@ -708,6 +715,8 @@ int gpiochip_generic_request(struct gpio_chip *gc, unsigned int offset);
|
|||
void gpiochip_generic_free(struct gpio_chip *gc, unsigned int offset);
|
||||
int gpiochip_generic_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long config);
|
||||
int gpiochip_generic_get_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long *config);
|
||||
|
||||
/**
|
||||
* struct gpio_pin_range - pin range controlled by a gpio chip
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user