Skip to contentSkip to conversation

pinctrl: armada-37xx: Add missing GPIO-only pins

PATCH Superseded Pali Rohár 2 participants 5 messages Aug 4, 2022 – Aug 5, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 pinctrl: armada-37xx: Add missing GPIO-only pins

gpio1_5 and gpio2_2 are GPIO-only pins. Add them into MPP groups table so they are properly exported as valid pin numbers.

Fixes 87466ccd9401 ("pinctrl: armada-37xx: Add pin controller support for Armada 37xx")
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +12 -0
index a140b6bfbfaa..2b44c634ccb5 100644
@@ -122,6 +122,16 @@ struct armada_37xx_pinctrl {
 		.funcs = {_func1, _func2}	\
 	}
 
+#define PIN_GRP_GPIO_0(_name, _start, _nr)	\
+	{					\
+		.name = _name,			\
+		.start_pin = _start,		\
+		.npins = _nr,			\
+		.reg_mask = 0,			\
+		.val = {0},			\
+		.funcs = {"gpio"}		\
+	}
+
 #define PIN_GRP_GPIO(_name, _start, _nr, _mask, _func1)	\
 	{					\
 		.name = _name,			\
@@ -179,6 +189,7 @@ static struct armada_37xx_pin_group armada_37xx_nb_groups[] = {
 		       "pwm", "led"),
 	PIN_GRP_GPIO("pmic1", 7, 1, BIT(7), "pmic"),
 	PIN_GRP_GPIO("pmic0", 6, 1, BIT(8), "pmic"),
+	PIN_GRP_GPIO_0("gpio1_5", 5, 1),
 	PIN_GRP_GPIO("i2c2", 2, 2, BIT(9), "i2c"),
 	PIN_GRP_GPIO("i2c1", 0, 2, BIT(10), "i2c"),
 	PIN_GRP_GPIO("spi_cs1", 17, 1, BIT(12), "spi"),
@@ -195,6 +206,7 @@ static struct armada_37xx_pin_group armada_37xx_nb_groups[] = {
 static struct armada_37xx_pin_group armada_37xx_sb_groups[] = {
 	PIN_GRP_GPIO("usb32_drvvbus0", 0, 1, BIT(0), "drvbus"),
 	PIN_GRP_GPIO("usb2_drvvbus1", 1, 1, BIT(1), "drvbus"),
+	PIN_GRP_GPIO_0("gpio2_2", 2, 1),
 	PIN_GRP_GPIO("sdio_sb", 24, 6, BIT(2), "sdio"),
 	PIN_GRP_GPIO("rgmii", 6, 12, BIT(3), "mii"),
 	PIN_GRP_GPIO("smi", 18, 2, BIT(4), "smi"),
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/4 pinctrl: armada-37xx: Fix definitions for MPP pins 20-22

All 3 MPP pins (20, 21 and 22) can be configured individually and also can be configured to GPIO functions. Fix definitions for these MPP pins in existing pin groups. After this change GPIO function can be enabled just for one of these 3 pins.

Fixes 87466ccd9401 ("pinctrl: armada-37xx: Add pin controller support for Armada 37xx")
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +5 -3
index 2b44c634ccb5..e5e5f0ea0e77 100644
@@ -213,9 +213,11 @@ static struct armada_37xx_pin_group armada_37xx_sb_groups[] = {
 	PIN_GRP_GPIO("pcie1", 3, 1, BIT(5), "pcie"), /* this actually controls "pcie1_reset" */
 	PIN_GRP_GPIO("pcie1_clkreq", 4, 1, BIT(9), "pcie"),
 	PIN_GRP_GPIO("pcie1_wakeup", 5, 1, BIT(10), "pcie"),
-	PIN_GRP_GPIO("ptp", 20, 3, BIT(11) | BIT(12) | BIT(13), "ptp"),
-	PIN_GRP("ptp_clk", 21, 1, BIT(6), "ptp", "mii"),
-	PIN_GRP("ptp_trig", 22, 1, BIT(7), "ptp", "mii"),
+	PIN_GRP_GPIO("ptp", 20, 1, BIT(11), "ptp"),
+	PIN_GRP_GPIO_3("ptp_clk", 21, 1, BIT(6) | BIT(12), 0, BIT(6), BIT(12),
+		       "ptp", "mii"),
+	PIN_GRP_GPIO_3("ptp_trig", 22, 1, BIT(7) | BIT(13), 0, BIT(7), BIT(13),
+		       "ptp", "mii"),
 	PIN_GRP_GPIO_3("mii_col", 23, 1, BIT(8) | BIT(14), 0, BIT(8), BIT(14),
 		       "mii", "mii_err"),
 };
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/4 pinctrl: armada-37xx: Checks for errors in gpio_request_enable callback

In reply to Pali Rohár

Now when all MPP pins are properly defined and every MPP pin has GPIO function, always checks for errors in armada_37xx_gpio_request_enable() function when calling armada_37xx_pmx_set_by_name(). Function armada_37xx_pmx_set_by_name() should not return "not supported" error anymore for any GPIO pin when requesting GPIO mode.

Fixes 87466ccd9401 ("pinctrl: armada-37xx: Add pin controller support for Armada 37xx")
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +5 -2
index e5e5f0ea0e77..8978e6c15905 100644
@@ -503,8 +503,11 @@ static int armada_37xx_gpio_request_enable(struct pinctrl_dev *pctldev,
 
 	dev_dbg(info->dev, "requesting gpio %d\n", offset);
 
-	while ((group = armada_37xx_find_next_grp_by_pin(info, offset, &grp)))
-		armada_37xx_pmx_set_by_name(pctldev, "gpio", group);
+	while ((group = armada_37xx_find_next_grp_by_pin(info, offset, &grp))) {
+		ret = armada_37xx_pmx_set_by_name(pctldev, "gpio", group);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
Signature · 1 line
2.20.1
#3 lore raw

Re: [PATCH 3/4] pinctrl: armada-37xx: Checks for errors in gpio_request_enable callback

I love your patch! Yet something to improve:

Hi "Pali,

I love your patch! Yet something to improve:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linus/master v5.19 next-20220804] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pali-Roh-r/pinctrl-armada-37xx-Add-missing-GPIO-only-pins/20220804-185128
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: arm64-randconfig-r024-20220804 (https://download.01.org/0day-ci/archive/20220805/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 26dd42705c2af0b8f6e5d6cdb32c9bd5ed9524eb)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/eafc74555d185a2f106a91f29e9884ef4c2e0458
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Pali-Roh-r/pinctrl-armada-37xx-Add-missing-GPIO-only-pins/20220804-185128 git checkout eafc74555d185a2f106a91f29e9884ef4c2e0458
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable

All errors (new ones prefixed by >>):

>> drivers/pinctrl/mvebu/pinctrl-armada-37xx.c:507:3: error: use of undeclared identifier 'ret'
                   ret = armada_37xx_pmx_set_by_name(pctldev, "gpio", group);
                   ^
   drivers/pinctrl/mvebu/pinctrl-armada-37xx.c:508:7: error: use of undeclared identifier 'ret'
                   if (ret)
                       ^
   drivers/pinctrl/mvebu/pinctrl-armada-37xx.c:509:11: error: use of undeclared identifier 'ret'
                           return ret;
                                  ^
   drivers/pinctrl/mvebu/pinctrl-armada-37xx.c:834:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]
           int i = 0;
               ^

1 warning and 3 errors generated.

vim +/ret +507 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c

495
496 static int armada_37xx_gpio_request_enable(struct pinctrl_dev *pctldev,
497 struct pinctrl_gpio_range *range,
498 unsigned int offset)
499 {
500 struct armada_37xx_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
501 struct armada_37xx_pin_group *group;
502 int grp = 0;
503
504 dev_dbg(info->dev, "requesting gpio %d\n", offset);
505
506 while ((group = armada_37xx_find_next_grp_by_pin(info, offset, &grp))) {

 > 507			ret = armada_37xx_pmx_set_by_name(pctldev, "gpio", group);

508 if (ret)
509 return ret;
510 }
511
512 return 0;
513 }
514

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#4 lore raw

PATCH 4/4 pinctrl: armada-37xx: Remove unused macro PIN_GRP()

In reply to Pali Rohár

Macro PIN_GRP() is not used, remove it.

---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +0 -10
index 8978e6c15905..1b48c4db2f28 100644
@@ -112,16 +112,6 @@ struct armada_37xx_pinctrl {
 	struct armada_37xx_pm_state	pm;
 };
 
-#define PIN_GRP(_name, _start, _nr, _mask, _func1, _func2)	\
-	{					\
-		.name = _name,			\
-		.start_pin = _start,		\
-		.npins = _nr,			\
-		.reg_mask = _mask,		\
-		.val = {0, _mask},		\
-		.funcs = {_func1, _func2}	\
-	}
-
 #define PIN_GRP_GPIO_0(_name, _start, _nr)	\
 	{					\
 		.name = _name,			\
Signature · 1 line
2.20.1