public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes
@ 2025-05-14 19:18 Gabor Juhos
  2025-05-14 19:18 ` [PATCH v2 1/7] pinctrl: armada-37xx: use correct OUTPUT_VAL register for GPIOs > 31 Gabor Juhos
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ 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 series contains several small patches to fix various
issues in the pinctrl driver for Armada 3700.

Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
  - remove 'stable' and 'Fixes' tags from the error propagating patches
  - collect 'Reviewed-by' tags from Andrew
  - swap patches 2 and 3 so the bug fix in the latter can be applied cleanly
    without depending on the change in the former
  - Link to v1: https://lore.kernel.org/r/20250512-pinctrl-a37xx-fixes-v1-0-d470fb1116a5@gmail.com

---
Gabor Juhos (7):
      pinctrl: armada-37xx: use correct OUTPUT_VAL register for GPIOs > 31
      pinctrl: armada-37xx: set GPIO output value before setting direction
      pinctrl: armada-37xx: propagate error from armada_37xx_gpio_direction_output()
      pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get()
      pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction()
      pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction()
      pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name()

 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 35 ++++++++++++++++-------------
 1 file changed, 20 insertions(+), 15 deletions(-)
---
base-commit: 82f2b0b97b36ee3fcddf0f0780a9a0825d52fec3
change-id: 20250512-pinctrl-a37xx-fixes-98fabc45cb11

Best regards,
-- 
Gabor Juhos <j4g8y7@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [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
  2025-05-14 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
  2 siblings, 0 replies; 5+ 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(&reg, &val_offset);
+
 	val = value ? mask : 0;
 	regmap_update_bits(info->regmap, reg, mask, val);
 

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ 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 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
  2 siblings, 0 replies; 5+ 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(&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(&reg, &val_offset);
+	reg = OUTPUT_EN;
+	armada_37xx_update_reg(&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] 5+ 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
  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 22:28 ` Linus Walleij
  2025-05-15  7:45   ` Gabor Juhos
  2 siblings, 1 reply; 5+ 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] 5+ 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; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2025-05-15  7:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
2025-05-15  7:45   ` Gabor Juhos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox