FAILED: patch "[PATCH] gpio: idio-16: Define fixed direction of the GPIO lines" failed to apply to 6.17-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.17-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.17.y
git checkout FETCH_HEAD
git cherry-pick -x 2ba5772e530f73eb847fb96ce6c4017894869552
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025102645-grueling-ramrod-c231@gregkh' --subject-prefix 'PATCH 6.17.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2ba5772e530f73eb847fb96ce6c4017894869552 Mon Sep 17 00:00:00 2001
From: William Breathitt Gray <[email protected]>
Date: Mon, 20 Oct 2025 17:51:46 +0900
Subject: [PATCH] gpio: idio-16: Define fixed direction of the GPIO lines
The direction of the IDIO-16 GPIO lines is fixed with the first 16 lines as output and the remaining 16 lines as input. Set the gpio_config fixed_direction_output member to represent the fixed direction of the GPIO lines.
drivers/gpio/gpio-idio-16.c +5 -0
@@ -6,6 +6,7 @@#define DEFAULT_SYMBOL_NAMESPACE "GPIO_IDIO_16" +#include <linux/bitmap.h> #include <linux/bits.h> #include <linux/device.h> #include <linux/err.h>
@@ -107,6 +108,7 @@ int devm_idio_16_regmap_register(struct device *const dev,struct idio_16_data *data;struct regmap_irq_chip *chip;struct regmap_irq_chip_data *chip_data; +DECLARE_BITMAP (fixed_direction_output,IDIO_16_NGPIO );if (!config->parent)return -EINVAL ;
@@ -164,6 +166,9 @@ int devm_idio_16_regmap_register(struct device *const dev, gpio_config.irq_domain =regmap_irq_get_domain (chip_data); gpio_config.reg_mask_xlate = idio_16_reg_mask_xlate; +bitmap_from_u64 (fixed_direction_output,GENMASK_U64 (15 ,0 )); + gpio_config.fixed_direction_output = fixed_direction_output; +return PTR_ERR_OR_ZERO (devm_gpio_regmap_register (dev, &gpio_config)); }EXPORT_SYMBOL_GPL (devm_idio_16_regmap_register);
Sasha Levin
maintainerPATCH 1/3 gpio: regmap: Allow to allocate regmap-irq device
From: Mathieu Dubois-Briand <[email protected]>
[ Upstream commit 553b75d4bfe9264f631d459fe9996744e0672b0e ]
GPIO controller often have support for IRQ: allow to easily allocate both gpio-regmap and regmap-irq in one operation.
Stable-dep-of: 2ba5772e530f ("gpio: idio-16: Define fixed direction of the GPIO lines")
--- drivers/gpio/gpio-regmap.c | 29 +++++++++++++++++++++++++++-- include/linux/gpio/regmap.h | 11 +++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-)
drivers/gpio/gpio-regmap.c +27 -2
@@ -32,6 +32,11 @@ struct gpio_regmap {unsigned int reg_dir_in_base;unsigned int reg_dir_out_base; +#ifdef CONFIG_REGMAP_IRQ +int regmap_irq_line; +struct regmap_irq_chip_data *irq_chip_data; +#endif +int (*reg_mask_xlate)(struct gpio_regmap *gpio,unsigned int base,unsigned int offset,unsigned int *reg,unsigned int *mask);
@@ -215,6 +220,7 @@ EXPORT_SYMBOL_GPL(gpio_regmap_get_drvdata);*/ struct gpio_regmap *gpio_regmap_register (const struct gpio_regmap_config *config) { +struct irq_domain *irq_domain;struct gpio_regmap *gpio;struct gpio_chip *chip;int ret;
@@ -295,8 +301,22 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *configif (ret <0 ) goto err_free_gpio; -if (config->irq_domain) { - ret =gpiochip_irqchip_add_domain (chip, config->irq_domain); +#ifdef CONFIG_REGMAP_IRQ +if (config->regmap_irq_chip) { + gpio->regmap_irq_line = config->regmap_irq_line; + ret =regmap_add_irq_chip_fwnode (dev_fwnode (config->parent), config->regmap, + config->regmap_irq_line, config->regmap_irq_flags, +0 , config->regmap_irq_chip, &gpio->irq_chip_data); +if (ret) + goto err_free_gpio; + + irq_domain =regmap_irq_get_domain (gpio->irq_chip_data); + } else +#endif + irq_domain = config->irq_domain; + +if (irq_domain) { + ret =gpiochip_irqchip_add_domain (chip, irq_domain);if (ret) goto err_remove_gpiochip; }
@@ -317,6 +337,11 @@ EXPORT_SYMBOL_GPL(gpio_regmap_register);*/ void gpio_regmap_unregister (struct gpio_regmap *gpio) { +#ifdef CONFIG_REGMAP_IRQ +if (gpio->irq_chip_data) +regmap_del_irq_chip (gpio->regmap_irq_line, gpio->irq_chip_data); +#endif +gpiochip_remove (&gpio->gpio_chip);kfree (gpio); }
include/linux/gpio/regmap.h +11 -0
@@ -40,6 +40,11 @@ struct regmap;* @drvdata: (Optional) Pointer to driver specific data which is * not used by gpio-remap but is provided "as is" to the * driver callback(s). +* @regmap_irq_chip: (Optional) Pointer on an regmap_irq_chip structure. If +* set, a regmap-irq device will be created and the IRQ +* domain will be set accordingly. +* @regmap_irq_line (Optional) The IRQ the device uses to signal interrupts. +* @regmap_irq_flags (Optional) The IRQF_ flags to use for the interrupt. * * The ->reg_mask_xlate translates a given base address and GPIO offset to * register and mask pair. The base address is one of the given register
@@ -78,6 +83,12 @@ struct gpio_regmap_config {int ngpio_per_reg;struct irq_domain *irq_domain; +#ifdef CONFIG_REGMAP_IRQ +struct regmap_irq_chip *regmap_irq_chip; +int regmap_irq_line; +unsigned long regmap_irq_flags; +#endif +int (*reg_mask_xlate)(struct gpio_regmap *gpio,unsigned int base,unsigned int offset,unsigned int *reg,unsigned int *mask);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/3 gpio: regmap: add the .fixed_direction_output configuration parameter
From: Ioana Ciornei <[email protected]>
[ Upstream commit 00aaae60faf554c27c95e93d47f200a93ff266ef ]
There are GPIO controllers such as the one present in the LX2160ARDB QIXIS FPGA which have fixed-direction input and output GPIO lines mixed together in a single register. This cannot be modeled using the gpio-regmap as-is since there is no way to present the true direction of a GPIO line.
In order to make this use case possible, add a new configuration parameter - fixed_direction_output - into the gpio_regmap_config structure. This will enable user drivers to provide a bitmap that represents the fixed direction of the GPIO lines.
Stable-dep-of: 2ba5772e530f ("gpio: idio-16: Define fixed direction of the GPIO lines")
--- drivers/gpio/gpio-regmap.c | 26 ++++++++++++++++++++++++-- include/linux/gpio/regmap.h | 5 +++++ 2 files changed, 29 insertions(+), 2 deletions(-)
drivers/gpio/gpio-regmap.c +24 -2
@@ -31,6 +31,7 @@ struct gpio_regmap {unsigned int reg_clr_base;unsigned int reg_dir_in_base;unsigned int reg_dir_out_base; +unsigned long *fixed_direction_output;#ifdef CONFIG_REGMAP_IRQ int regmap_irq_line;
@@ -134,6 +135,13 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,unsigned int base, val, reg, mask;int invert, ret; +if (gpio->fixed_direction_output) { +if (test_bit (offset, gpio->fixed_direction_output)) +return GPIO_LINE_DIRECTION_OUT ; +else +return GPIO_LINE_DIRECTION_IN ; + } +if (gpio->reg_dat_base && !gpio->reg_set_base)return GPIO_LINE_DIRECTION_IN ;if (gpio->reg_set_base && !gpio->reg_dat_base)
@@ -283,6 +291,17 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config goto err_free_gpio; } +if (config->fixed_direction_output) { + gpio->fixed_direction_output =bitmap_alloc (chip->ngpio, +GFP_KERNEL ); +if (!gpio->fixed_direction_output) { + ret = -ENOMEM ; + goto err_free_gpio; + } +bitmap_copy (gpio->fixed_direction_output, + config->fixed_direction_output, chip->ngpio); + } +/* if not set, assume there is only one register */ gpio->ngpio_per_reg = config->ngpio_per_reg;if (!gpio->ngpio_per_reg)
@@ -299,7 +318,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config ret =gpiochip_add_data (chip, gpio);if (ret <0 ) - goto err_free_gpio; + goto err_free_bitmap;#ifdef CONFIG_REGMAP_IRQ if (config->regmap_irq_chip) {
@@ -308,7 +327,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config config->regmap_irq_line, config->regmap_irq_flags, 0, config->regmap_irq_chip, &gpio->irq_chip_data);if (ret) - goto err_free_gpio; + goto err_free_bitmap; irq_domain =regmap_irq_get_domain (gpio->irq_chip_data); }else
@@ -325,6 +344,8 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config err_remove_gpiochip:gpiochip_remove (chip); +err_free_bitmap: +bitmap_free (gpio->fixed_direction_output); err_free_gpio:kfree (gpio);return ERR_PTR (ret);
@@ -343,6 +364,7 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio)#endif gpiochip_remove (&gpio->gpio_chip); +bitmap_free (gpio->fixed_direction_output);kfree (gpio); }EXPORT_SYMBOL_GPL (gpio_regmap_unregister);
include/linux/gpio/regmap.h +5 -0
@@ -37,6 +37,10 @@ struct regmap;* offset to a register/bitmask pair. If not * given the default gpio_regmap_simple_xlate() * is used. +* @fixed_direction_output: +* (Optional) Bitmap representing the fixed direction of +* the GPIO lines. Useful when there are GPIO lines with a +* fixed direction mixed together in the same register. * @drvdata: (Optional) Pointer to driver specific data which is * not used by gpio-remap but is provided "as is" to the * driver callback(s).
@@ -82,6 +86,7 @@ struct gpio_regmap_config {int reg_stride;int ngpio_per_reg;struct irq_domain *irq_domain; +unsigned long *fixed_direction_output;#ifdef CONFIG_REGMAP_IRQ struct regmap_irq_chip *regmap_irq_chip;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 3/3 gpio: idio-16: Define fixed direction of the GPIO lines
In reply to Sasha LevinFrom: William Breathitt Gray <[email protected]>
[ Upstream commit 2ba5772e530f73eb847fb96ce6c4017894869552 ]
The direction of the IDIO-16 GPIO lines is fixed with the first 16 lines as output and the remaining 16 lines as input. Set the gpio_config fixed_direction_output member to represent the fixed direction of the GPIO lines.
--- drivers/gpio/gpio-idio-16.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpio/gpio-idio-16.c +5 -0
@@ -6,6 +6,7 @@#define DEFAULT_SYMBOL_NAMESPACE "GPIO_IDIO_16" +#include <linux/bitmap.h> #include <linux/bits.h> #include <linux/device.h> #include <linux/err.h>
@@ -107,6 +108,7 @@ int devm_idio_16_regmap_register(struct device *const dev,struct idio_16_data *data;struct regmap_irq_chip *chip;struct regmap_irq_chip_data *chip_data; +DECLARE_BITMAP (fixed_direction_output,IDIO_16_NGPIO );if (!config->parent)return -EINVAL ;
@@ -164,6 +166,9 @@ int devm_idio_16_regmap_register(struct device *const dev, gpio_config.irq_domain =regmap_irq_get_domain (chip_data); gpio_config.reg_mask_xlate = idio_16_reg_mask_xlate; +bitmap_from_u64 (fixed_direction_output,GENMASK_U64 (15 ,0 )); + gpio_config.fixed_direction_output = fixed_direction_output; +return PTR_ERR_OR_ZERO (devm_gpio_regmap_register (dev, &gpio_config)); }EXPORT_SYMBOL_GPL (devm_idio_16_regmap_register);
Signature · 1 line
2.51.0