* [PATCH v2 1/7] pinctrl: armada-37xx: use correct OUTPUT_VAL register for GPIOs > 31
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 2/7] pinctrl: armada-37xx: set GPIO output value before setting direction Gabor Juhos
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos, stable
The controller has two consecutive OUTPUT_VAL registers and both
holds output value for 32 GPIOs. Due to a missing adjustment, the
current code always uses the first register while setting the
output value whereas it should use the second one for GPIOs > 31.
Add the missing armada_37xx_update_reg() call to adjust the register
according to the 'offset' parameter of the function to fix the issue.
Cc: stable@vger.kernel.org
Fixes: 6702abb3bf23 ("pinctrl: armada-37xx: Fix direction_output() callback behavior")
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 335744ac831057576473dd62c5533168b243a656..43034d29292687e875136aafa530b62479dc55ec 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -417,6 +417,7 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{
struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
+ unsigned int val_offset = offset;
unsigned int reg = OUTPUT_EN;
unsigned int mask, val, ret;
@@ -429,6 +430,8 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
return ret;
reg = OUTPUT_VAL;
+ armada_37xx_update_reg(®, &val_offset);
+
val = value ? mask : 0;
regmap_update_bits(info->regmap, reg, mask, val);
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/7] pinctrl: armada-37xx: set GPIO output value before setting direction
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 1/7] pinctrl: armada-37xx: use correct OUTPUT_VAL register for GPIOs > 31 Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 3/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_direction_output() Gabor Juhos
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos, stable
Changing the direction before updating the output value in the
OUTPUT_VAL register may result in a glitch on the output line
if the previous value in the OUTPUT_VAL register is different
from the one we want to set.
In order to avoid that, update the output value before changing
the direction.
Cc: stable@vger.kernel.org
Fixes: 6702abb3bf23 ("pinctrl: armada-37xx: Fix direction_output() callback behavior")
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- swap with patch 3 from v1
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 43034d29292687e875136aafa530b62479dc55ec..79f9c08e5039c31acb170d4f38b516b1454fd9ea 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -417,23 +417,22 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{
struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
- unsigned int val_offset = offset;
- unsigned int reg = OUTPUT_EN;
+ unsigned int en_offset = offset;
+ unsigned int reg = OUTPUT_VAL;
unsigned int mask, val, ret;
armada_37xx_update_reg(®, &offset);
mask = BIT(offset);
+ val = value ? mask : 0;
- ret = regmap_update_bits(info->regmap, reg, mask, mask);
-
+ ret = regmap_update_bits(info->regmap, reg, mask, val);
if (ret)
return ret;
- reg = OUTPUT_VAL;
- armada_37xx_update_reg(®, &val_offset);
+ reg = OUTPUT_EN;
+ armada_37xx_update_reg(®, &en_offset);
- val = value ? mask : 0;
- regmap_update_bits(info->regmap, reg, mask, val);
+ regmap_update_bits(info->regmap, reg, mask, mask);
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_direction_output()
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 1/7] pinctrl: armada-37xx: use correct OUTPUT_VAL register for GPIOs > 31 Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 2/7] pinctrl: armada-37xx: set GPIO output value before setting direction Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 4/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get() Gabor Juhos
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos
The regmap_update_bits() function can fail, so propagate its error
up to the stack instead of silently ignoring that.
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- swap with patch 2 from v1
- remove 'stable' and 'Fixes' tags
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 79f9c08e5039c31acb170d4f38b516b1454fd9ea..8d93d36af63ab9496376219454214c05db30971f 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -432,9 +432,7 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
reg = OUTPUT_EN;
armada_37xx_update_reg(®, &en_offset);
- regmap_update_bits(info->regmap, reg, mask, mask);
-
- return 0;
+ return regmap_update_bits(info->regmap, reg, mask, mask);
}
static int armada_37xx_gpio_get(struct gpio_chip *chip, unsigned int offset)
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get()
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
` (2 preceding siblings ...)
2025-05-14 19:18 ` [PATCH v2 3/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_direction_output() Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 5/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction() Gabor Juhos
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos
The regmap_read() function can fail, so propagate its error up to
the stack instead of silently ignoring that.
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- remove 'stable' and 'Fixes' tags
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 8d93d36af63ab9496376219454214c05db30971f..2e88a0399d1a205064b58890db6477e2202bf311 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -440,11 +440,14 @@ static int armada_37xx_gpio_get(struct gpio_chip *chip, unsigned int offset)
struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
unsigned int reg = INPUT_VAL;
unsigned int val, mask;
+ int ret;
armada_37xx_update_reg(®, &offset);
mask = BIT(offset);
- regmap_read(info->regmap, reg, &val);
+ ret = regmap_read(info->regmap, reg, &val);
+ if (ret)
+ return ret;
return (val & mask) != 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 5/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction()
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
` (3 preceding siblings ...)
2025-05-14 19:18 ` [PATCH v2 4/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get() Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 6/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction() Gabor Juhos
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos
The armada_37xx_gpio_direction_{in,out}put() functions can fail, so
propagate their error values back to the stack instead of silently
ignoring those.
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- remove 'stable' and 'Fixes' tags
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 2e88a0399d1a205064b58890db6477e2202bf311..aed0069b085ced5867993e95e0244df7ccda556d 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -472,16 +472,17 @@ static int armada_37xx_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
{
struct armada_37xx_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
struct gpio_chip *chip = range->gc;
+ int ret;
dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
offset, range->name, offset, input ? "input" : "output");
if (input)
- armada_37xx_gpio_direction_input(chip, offset);
+ ret = armada_37xx_gpio_direction_input(chip, offset);
else
- armada_37xx_gpio_direction_output(chip, offset, 0);
+ ret = armada_37xx_gpio_direction_output(chip, offset, 0);
- return 0;
+ return ret;
}
static int armada_37xx_gpio_request_enable(struct pinctrl_dev *pctldev,
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 6/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction()
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
` (4 preceding siblings ...)
2025-05-14 19:18 ` [PATCH v2 5/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction() Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 7/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name() Gabor Juhos
2025-05-14 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos
The regmap_read() function can fail, so propagate its error up to
the stack instead of silently ignoring that.
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- remove 'stable' and 'Fixes' tags
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index aed0069b085ced5867993e95e0244df7ccda556d..18c6c5026b26c294ee65e3deea02d2e852e10622 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -402,10 +402,13 @@ static int armada_37xx_gpio_get_direction(struct gpio_chip *chip,
struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
unsigned int reg = OUTPUT_EN;
unsigned int val, mask;
+ int ret;
armada_37xx_update_reg(®, &offset);
mask = BIT(offset);
- regmap_read(info->regmap, reg, &val);
+ ret = regmap_read(info->regmap, reg, &val);
+ if (ret)
+ return ret;
if (val & mask)
return GPIO_LINE_DIRECTION_OUT;
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 7/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name()
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
` (5 preceding siblings ...)
2025-05-14 19:18 ` [PATCH v2 6/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction() Gabor Juhos
@ 2025-05-14 19:18 ` Gabor Juhos
2025-05-14 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
7 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-14 19:18 UTC (permalink / raw)
To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Linus Walleij, Bartosz Golaszewski
Cc: Imre Kaloz, linux-arm-kernel, linux-gpio, linux-kernel,
Gabor Juhos
The regmap_update_bits() function can fail, so propagate its error
up to the stack instead of silently ignoring that.
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- remove 'stable' and 'Fixes' tags
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 18c6c5026b26c294ee65e3deea02d2e852e10622..f35bf0cd98c97419ba0ab0291a23d4774a595d39 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -358,9 +358,7 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev,
val = grp->val[func];
- regmap_update_bits(info->regmap, reg, mask, val);
-
- return 0;
+ return regmap_update_bits(info->regmap, reg, mask, val);
}
static int armada_37xx_pmx_set(struct pinctrl_dev *pctldev,
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
` (6 preceding siblings ...)
2025-05-14 19:18 ` [PATCH v2 7/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name() Gabor Juhos
@ 2025-05-14 22:28 ` Linus Walleij
2025-05-15 7:45 ` Gabor Juhos
7 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2025-05-14 22:28 UTC (permalink / raw)
To: Gabor Juhos
Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Bartosz Golaszewski, Imre Kaloz, linux-arm-kernel, linux-gpio,
linux-kernel, stable
On Wed, May 14, 2025 at 9:18 PM Gabor Juhos <j4g8y7@gmail.com> wrote:
> The series contains several small patches to fix various
> issues in the pinctrl driver for Armada 3700.
>
> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Patches applied by applying to a separate immutable branch
and merging into my "devel" branch: we were clashing a bit
with Bartosz rewrites so I had to help git a bit.
Pushed to the autobuilders, check the result!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes
2025-05-14 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
@ 2025-05-15 7:45 ` Gabor Juhos
0 siblings, 0 replies; 10+ messages in thread
From: Gabor Juhos @ 2025-05-15 7:45 UTC (permalink / raw)
To: Linus Walleij
Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Bartosz Golaszewski, Imre Kaloz, linux-arm-kernel, linux-gpio,
linux-kernel, stable
2025. 05. 15. 0:28 keltezéssel, Linus Walleij írta:
> On Wed, May 14, 2025 at 9:18 PM Gabor Juhos <j4g8y7@gmail.com> wrote:
>
>> The series contains several small patches to fix various
>> issues in the pinctrl driver for Armada 3700.
>>
>> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
>
> Patches applied by applying to a separate immutable branch
> and merging into my "devel" branch: we were clashing a bit
> with Bartosz rewrites so I had to help git a bit.
>
> Pushed to the autobuilders, check the result!
Checked, it is fine. Thanks!
-Gabor
^ permalink raw reply [flat|nested] 10+ messages in thread