[openwrt/openwrt] mvebu: armada37xx: backport pinctrl fixes
LEDE Commits
lede-commits at lists.infradead.org
Tue May 20 11:55:23 PDT 2025
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/831994e25818cbd000e9de2eac8f7cc0a5eda181
commit 831994e25818cbd000e9de2eac8f7cc0a5eda181
Author: Robert Marko <robert.marko at sartura.hr>
AuthorDate: Tue May 20 11:23:52 2025 +0200
mvebu: armada37xx: backport pinctrl fixes
Backport upstream pinctrl fixes, these are required for the follow-up I2C
PXA recovery fixes.
Signed-off-by: Robert Marko <robert.marko at sartura.hr>
---
...ada-37xx-use-correct-OUTPUT_VAL-register-.patch | 44 ++++++++++++++++
...ada-37xx-set-GPIO-output-value-before-set.patch | 58 ++++++++++++++++++++++
...ada-37xx-propagate-error-from-armada_37xx.patch | 31 ++++++++++++
...ada-37xx-propagate-error-from-armada_37xx.patch | 36 ++++++++++++++
...ada-37xx-propagate-error-from-armada_37xx.patch | 42 ++++++++++++++++
...ada-37xx-propagate-error-from-armada_37xx.patch | 35 +++++++++++++
...ada-37xx-propagate-error-from-armada_37xx.patch | 31 ++++++++++++
7 files changed, 277 insertions(+)
diff --git a/target/linux/mvebu/patches-6.6/0001-v6.16-pinctrl-armada-37xx-use-correct-OUTPUT_VAL-register-.patch b/target/linux/mvebu/patches-6.6/0001-v6.16-pinctrl-armada-37xx-use-correct-OUTPUT_VAL-register-.patch
new file mode 100644
index 0000000000..0d594a20bf
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0001-v6.16-pinctrl-armada-37xx-use-correct-OUTPUT_VAL-register-.patch
@@ -0,0 +1,44 @@
+From 947c93eb29c2a581c0b0b6d5f21af3c2b7ff6d25 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:32 +0200
+Subject: [PATCH 1/7] pinctrl: armada-37xx: use correct OUTPUT_VAL register for
+ GPIOs > 31
+
+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 at vger.kernel.org
+Fixes: 6702abb3bf23 ("pinctrl: armada-37xx: Fix direction_output() callback behavior")
+Signed-off-by: Imre Kaloz <kaloz at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-1-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- 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_ou
+ 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_ou
+ return ret;
+
+ reg = OUTPUT_VAL;
++ armada_37xx_update_reg(®, &val_offset);
++
+ val = value ? mask : 0;
+ regmap_update_bits(info->regmap, reg, mask, val);
+
diff --git a/target/linux/mvebu/patches-6.6/0002-v6.16-pinctrl-armada-37xx-set-GPIO-output-value-before-set.patch b/target/linux/mvebu/patches-6.6/0002-v6.16-pinctrl-armada-37xx-set-GPIO-output-value-before-set.patch
new file mode 100644
index 0000000000..02f42c0324
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0002-v6.16-pinctrl-armada-37xx-set-GPIO-output-value-before-set.patch
@@ -0,0 +1,58 @@
+From e6ebd4942981f8ad37189bbb36a3c8495e21ef4c Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:33 +0200
+Subject: [PATCH 2/7] pinctrl: armada-37xx: set GPIO output value before
+ setting direction
+
+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 at vger.kernel.org
+Fixes: 6702abb3bf23 ("pinctrl: armada-37xx: Fix direction_output() callback behavior")
+Signed-off-by: Imre Kaloz <kaloz at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-2-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 15 +++++++--------
+ 1 file changed, 7 insertions(+), 8 deletions(-)
+
+--- 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_ou
+ 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;
+ }
diff --git a/target/linux/mvebu/patches-6.6/0003-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch b/target/linux/mvebu/patches-6.6/0003-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
new file mode 100644
index 0000000000..2483dedfae
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0003-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
@@ -0,0 +1,31 @@
+From 0396a8731efd17aec4719ad9981fefeaa13ffa56 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:34 +0200
+Subject: [PATCH 3/7] pinctrl: armada-37xx: propagate error from
+ armada_37xx_gpio_direction_output()
+
+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 at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-3-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+--- 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_ou
+ 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)
diff --git a/target/linux/mvebu/patches-6.6/0004-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch b/target/linux/mvebu/patches-6.6/0004-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
new file mode 100644
index 0000000000..4fe9f1b7b8
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0004-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
@@ -0,0 +1,36 @@
+From 57273ff8bb16f3842c2597b5bbcd49e7fa12edf7 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:35 +0200
+Subject: [PATCH 4/7] pinctrl: armada-37xx: propagate error from
+ armada_37xx_gpio_get()
+
+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 at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-4-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- 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 g
+ 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;
+ }
diff --git a/target/linux/mvebu/patches-6.6/0005-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch b/target/linux/mvebu/patches-6.6/0005-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
new file mode 100644
index 0000000000..2395a0665f
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0005-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
@@ -0,0 +1,42 @@
+From bfa0ff804ffa8b1246ade8be08de98c9eb19d16f Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:36 +0200
+Subject: [PATCH 5/7] pinctrl: armada-37xx: propagate error from
+ armada_37xx_pmx_gpio_set_direction()
+
+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 at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-5-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- 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_dire
+ {
+ 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,
diff --git a/target/linux/mvebu/patches-6.6/0006-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch b/target/linux/mvebu/patches-6.6/0006-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
new file mode 100644
index 0000000000..9aac2e58e1
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0006-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
@@ -0,0 +1,35 @@
+From 6481c0a83367b0672951ccc876fbae7ee37b594b Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:37 +0200
+Subject: [PATCH 6/7] pinctrl: armada-37xx: propagate error from
+ armada_37xx_gpio_get_direction()
+
+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 at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-6-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- 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_directio
+ 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;
diff --git a/target/linux/mvebu/patches-6.6/0007-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch b/target/linux/mvebu/patches-6.6/0007-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
new file mode 100644
index 0000000000..6c14e50b4a
--- /dev/null
+++ b/target/linux/mvebu/patches-6.6/0007-v6.16-pinctrl-armada-37xx-propagate-error-from-armada_37xx.patch
@@ -0,0 +1,31 @@
+From 4229c28323db141eda69cb99427be75d3edba071 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <j4g8y7 at gmail.com>
+Date: Wed, 14 May 2025 21:18:38 +0200
+Subject: [PATCH 7/7] pinctrl: armada-37xx: propagate error from
+ armada_37xx_pmx_set_by_name()
+
+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 at openwrt.org>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Signed-off-by: Gabor Juhos <j4g8y7 at gmail.com>
+Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-7-07e9ac1ab737@gmail.com
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+ drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+--- 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(s
+
+ 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,
More information about the lede-commits
mailing list