Skip to contentSkip to conversation

pinctrl: stm32: correction for pinmux status

PATCH New Patrick Delaunay 2 participants 7 messages Jan 21, 2021 – Feb 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover pinctrl: stm32: correction for pinmux status

This serie solve 2 issues found in output of command "pinmux status -a" when I test the serie [1].

[1] "gpio: Update and simplify the uclass API"

    http://patchwork.ozlabs.org/project/uboot/list/?series=225585

Patrick Delaunay (2):
pinctrl: stm32: correct management pin display of OTYPE
pinctrl: stm32: bind only the enabled GPIO subnode

 drivers/pinctrl/pinctrl_stm32.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 pinctrl: stm32: correct management pin display of OTYPE

OTYPE can be used for output or for alternate function to select PP = push-pull or OP = open-drain mode, according reference manual (Table 81. Port bit configuration table).

This patch removes this indication for input pins and adds it for AF and output pins for pinmux command output.

Fixes b305dbc08b08 ("pinctrl: stm32: display bias information for all pins")

---

 drivers/pinctrl/pinctrl_stm32.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl_stm32.c +8 -10
index a1f53a793b..374f76d881 100644
@@ -56,7 +56,7 @@ static const char * const pinmux_bias[] = {
 	[STM32_GPIO_PUPD_DOWN] = "pull-down",
 };
 
-static const char * const pinmux_input[] = {
+static const char * const pinmux_otype[] = {
 	[STM32_GPIO_OTYPE_PP] = "push-pull",
 	[STM32_GPIO_OTYPE_OD] = "open-drain",
 };
@@ -216,7 +216,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
 		selector, gpio_idx, mode);
 	priv = dev_get_priv(gpio_dev);
 	pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) & PUPD_MASK;
-
+	otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
 
 	switch (mode) {
 	case GPIOF_UNKNOWN:
@@ -227,18 +227,16 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
 		break;
 	case GPIOF_FUNC:
 		af_num = stm32_pinctrl_get_af(gpio_dev, gpio_idx);
-		snprintf(buf, size, "%s %d %s", pinmux_mode[mode], af_num,
-			 pinmux_bias[pupd]);
+		snprintf(buf, size, "%s %d %s %s", pinmux_mode[mode], af_num,
+			 pinmux_otype[otype], pinmux_bias[pupd]);
 		break;
 	case GPIOF_OUTPUT:
-		snprintf(buf, size, "%s %s %s",
-			 pinmux_mode[mode], pinmux_bias[pupd],
-			 label ? label : "");
+		snprintf(buf, size, "%s %s %s %s",
+			 pinmux_mode[mode], pinmux_otype[otype],
+			 pinmux_bias[pupd], label ? label : "");
 		break;
 	case GPIOF_INPUT:
-		otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
-		snprintf(buf, size, "%s %s %s %s",
-			 pinmux_mode[mode], pinmux_input[otype],
+		snprintf(buf, size, "%s %s %s", pinmux_mode[mode],
 			 pinmux_bias[pupd], label ? label : "");
 		break;
 	}
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/2 pinctrl: stm32: correct management pin display of OTYPE

Hi Patrick

Quoted 53 lines · Patrick Delaunay

OTYPE can be used for output or for alternate function to select PP = push-pull or OP = open-drain mode, according reference manual (Table 81. Port bit configuration table).

This patch removes this indication for input pins and adds it for AF and output pins for pinmux command output.

Fixes b305dbc08b08 ("pinctrl: stm32: display bias information for all pins")

---

 drivers/pinctrl/pinctrl_stm32.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl_stm32.c +6 -7
index a1f53a793b..374f76d881 100644
@@ -56,7 +56,7 @@ static const char * const pinmux_bias[] = {
 	[STM32_GPIO_PUPD_DOWN] = "pull-down",
 };
 
-static const char * const pinmux_input[] = {
+static const char * const pinmux_otype[] = {
 	[STM32_GPIO_OTYPE_PP] = "push-pull",
 	[STM32_GPIO_OTYPE_OD] = "open-drain",
 };
@@ -216,7 +216,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
 		selector, gpio_idx, mode);
 	priv = dev_get_priv(gpio_dev);
 	pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) & PUPD_MASK;
-
+	otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
 
 	switch (mode) {
 	case GPIOF_UNKNOWN:
@@ -227,18 +227,16 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
 		break;
 	case GPIOF_FUNC:
 		af_num = stm32_pinctrl_get_af(gpio_dev, gpio_idx);
-		snprintf(buf, size, "%s %d %s", pinmux_mode[mode], af_num,
-			 pinmux_bias[pupd]);
+		snprintf(buf, size, "%s %d %s %s", pinmux_mode[mode], af_num,
+			 pinmux_otype[otype], pinmux_bias[pupd]);
 		break;
 	case GPIOF_OUTPUT:
-		snprintf(buf, size, "%s %s %s",
-			 pinmux_mode[mode], pinmux_bias[pupd],
-			 label ? label : "");
+		snprintf(buf, size, "%s %s %s %s",
+			 pinmux_mode[mode], pinmux_otype[otype],

drivers/pinctrl/pinctrl_stm32.c static int stm32_pinctrl_get_pin_muxing(struct udevice *dev, · line 242

Quoted 10 lines
drivers/pinctrl/pinctrl_stm32.c +2 -3
+			 pinmux_bias[pupd], label ? label : "");
 		break;
 	case GPIOF_INPUT:
-		otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
-		snprintf(buf, size, "%s %s %s %s",
-			 pinmux_mode[mode], pinmux_input[otype],
+		snprintf(buf, size, "%s %s %s", pinmux_mode[mode],
 			 pinmux_bias[pupd], label ? label : "");
 		break;
 	}

Thanks
Patrice

#3 lore raw

PATCH 1/2 pinctrl: stm32: correct management pin display of OTYPE

In reply to Patrick Delaunay

Hi,

Quoted 7 lines · Patrick Delaunay

OTYPE can be used for output or for alternate function to select PP = push-pull or OP = open-drain mode, according reference manual (Table 81. Port bit configuration table).

This patch removes this indication for input pins and adds it for AF and output pins for pinmux command output.

Quoted 8 lines
Fixes b305dbc08b08 ("pinctrl: stm32: display bias information for all pins")

---

  drivers/pinctrl/pinctrl_stm32.c | 18 ++++++++----------
  1 file changed, 8 insertions(+), 10 deletions(-)

Applied to u-boot-stm/master, thanks!

Regards

Patrick

#4 lore raw

PATCH 2/2 pinctrl: stm32: bind only the enabled GPIO subnode

In reply to Patrick Delaunay

Bind only the enabled GPIO subnode, to avoid to probe the node "gpio-controller" present in SOC dtsi (disabled by default) but not enabled in the included pincontrol dtsi file.

For example, in stm32mp15xxac-pinctrl.dtsi 2 gpio bank are absent:
gpioj: gpio at 5000b000
gpiok: gpio at 5000c000

Then these GPIO are absent in output of command "dm tree" and "gpio status -a"

---

 drivers/pinctrl/pinctrl_stm32.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pinctrl/pinctrl_stm32.c +3 -0
index 374f76d881..6c98538f56 100644
@@ -409,6 +409,9 @@ static int stm32_pinctrl_bind(struct udevice *dev)
 	dev_for_each_subnode(node, dev) {
 		dev_dbg(dev, "bind %s\n", ofnode_get_name(node));
 
+		if (!ofnode_is_enabled(node))
+			continue;
+
 		ofnode_get_property(node, "gpio-controller", &ret);
 		if (ret < 0)
 			continue;
Signature · 1 line
2.17.1
#5 lore raw

PATCH 2/2 pinctrl: stm32: bind only the enabled GPIO subnode

Hi Patrick

Quoted 23 lines · Patrick Delaunay

Bind only the enabled GPIO subnode, to avoid to probe the node "gpio-controller" present in SOC dtsi (disabled by default) but not enabled in the included pincontrol dtsi file.

For example, in stm32mp15xxac-pinctrl.dtsi 2 gpio bank are absent:
gpioj: gpio at 5000b000
gpiok: gpio at 5000c000

Then these GPIO are absent in output of command "dm tree" and "gpio status -a"

---

 drivers/pinctrl/pinctrl_stm32.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pinctrl/pinctrl_stm32.c +0 -0
index 374f76d881..6c98538f56 100644

drivers/pinctrl/pinctrl_stm32.c static int stm32_pinctrl_bind(struct udevice *dev) · line 417

Quoted 9 lines
drivers/pinctrl/pinctrl_stm32.c +3 -0
@@ -409,6 +409,9 @@ static int stm32_pinctrl_bind(struct udevice *dev)
 	dev_for_each_subnode(node, dev) {
 		dev_dbg(dev, "bind %s\n", ofnode_get_name(node));
 
+		if (!ofnode_is_enabled(node))
+			continue;
+
 		ofnode_get_property(node, "gpio-controller", &ret);
 		if (ret < 0)
 			continue;

Thanks
Patrice

#6 lore raw

PATCH 2/2 pinctrl: stm32: bind only the enabled GPIO subnode

In reply to Patrick Delaunay

Hi,

Quoted 8 lines · Patrick Delaunay

Bind only the enabled GPIO subnode, to avoid to probe the node "gpio-controller" present in SOC dtsi (disabled by default) but not enabled in the included pincontrol dtsi file.

For example, in stm32mp15xxac-pinctrl.dtsi 2 gpio bank are absent:
gpioj: gpio at 5000b000
gpiok: gpio at 5000c000

Quoted 9 lines

Then these GPIO are absent in output of command "dm tree" and "gpio status -a"

---

  drivers/pinctrl/pinctrl_stm32.c | 3 +++
  1 file changed, 3 insertions(+)

Applied to u-boot-stm/master, thanks!

Regards

Patrick