All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: stm32: display bias information for all pins
@ 2020-10-28  9:49 Patrick Delaunay
  2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Patrick Delaunay @ 2020-10-28  9:49 UTC (permalink / raw)
  To: u-boot

Display the bias information for input gpios or AF configuration,
and not only for output pin, as described in Reference manual
(Table 81. Port bit configuration table).

Fixes: da7a0bb1f279 ("pinctrl: stm32: add information on pin configuration")
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/pinctrl/pinctrl_stm32.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index dbea99532c..262b2c3d7e 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -48,15 +48,15 @@ static const char * const pinmux_mode[PINMUX_MODE_COUNT] = {
 	"alt function",
 };
 
-static const char * const pinmux_output[] = {
-	[STM32_GPIO_PUPD_NO] = "bias-disable",
-	[STM32_GPIO_PUPD_UP] = "bias-pull-up",
-	[STM32_GPIO_PUPD_DOWN] = "bias-pull-down",
+static const char * const pinmux_bias[] = {
+	[STM32_GPIO_PUPD_NO] = "",
+	[STM32_GPIO_PUPD_UP] = "pull-up",
+	[STM32_GPIO_PUPD_DOWN] = "pull-down",
 };
 
 static const char * const pinmux_input[] = {
-	[STM32_GPIO_OTYPE_PP] = "drive-push-pull",
-	[STM32_GPIO_OTYPE_OD] = "drive-open-drain",
+	[STM32_GPIO_OTYPE_PP] = "push-pull",
+	[STM32_GPIO_OTYPE_OD] = "open-drain",
 };
 
 static int stm32_pinctrl_get_af(struct udevice *dev, unsigned int offset)
@@ -213,6 +213,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
 	dev_dbg(dev, "selector = %d gpio_idx = %d mode = %d\n",
 		selector, gpio_idx, mode);
 	priv = dev_get_priv(gpio_dev);
+	pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) & PUPD_MASK;
 
 
 	switch (mode) {
@@ -224,20 +225,19 @@ 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", pinmux_mode[mode], af_num);
+		snprintf(buf, size, "%s %d %s", pinmux_mode[mode], af_num,
+			 pinmux_bias[pupd]);
 		break;
 	case GPIOF_OUTPUT:
-		pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) &
-		       PUPD_MASK;
 		snprintf(buf, size, "%s %s %s",
-			 pinmux_mode[mode], pinmux_output[pupd],
+			 pinmux_mode[mode], pinmux_bias[pupd],
 			 label ? label : "");
 		break;
 	case GPIOF_INPUT:
 		otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
-		snprintf(buf, size, "%s %s %s",
+		snprintf(buf, size, "%s %s %s %s",
 			 pinmux_mode[mode], pinmux_input[otype],
-			 label ? label : "");
+			 pinmux_bias[pupd], label ? label : "");
 		break;
 	}
 
-- 
2.17.1

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

* [PATCH 2/2] gpio: stm32: correct the bias management
  2020-10-28  9:49 [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrick Delaunay
@ 2020-10-28  9:49 ` Patrick Delaunay
  2020-10-28 10:15   ` Patrick DELAUNAY
                     ` (2 more replies)
  2020-11-25  9:43 ` [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrice CHOTARD
  2020-11-25 11:03 ` Patrick DELAUNAY
  2 siblings, 3 replies; 7+ messages in thread
From: Patrick Delaunay @ 2020-10-28  9:49 UTC (permalink / raw)
  To: u-boot

Use the bias configuration for all the GPIO configurations and not
only for input GPIO, as indicated in Reference manual
(Table 81. Port bit configuration table).

Fixes: 43efbb6a3ebf0223f9eab8d45916f602d876319f ("gpio: stm32: add ops get_dir_flags")
Fixes: f13ff88b61c32ac8f0e9068c41328b265ef619eb ("gpio: stm32: add ops set_dir_flags")
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/gpio/stm32_gpio.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
index b885cfb57e..51e1efd701 100644
--- a/drivers/gpio/stm32_gpio.c
+++ b/drivers/gpio/stm32_gpio.c
@@ -212,11 +212,11 @@ static int stm32_gpio_set_dir_flags(struct udevice *dev, unsigned int offset,
 
 	} else if (flags & GPIOD_IS_IN) {
 		stm32_gpio_set_moder(regs, idx, STM32_GPIO_MODE_IN);
-		if (flags & GPIOD_PULL_UP)
-			stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_UP);
-		else if (flags & GPIOD_PULL_DOWN)
-			stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_DOWN);
 	}
+	if (flags & GPIOD_PULL_UP)
+		stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_UP);
+	else if (flags & GPIOD_PULL_DOWN)
+		stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_DOWN);
 
 	return 0;
 }
@@ -243,16 +243,16 @@ static int stm32_gpio_get_dir_flags(struct udevice *dev, unsigned int offset,
 		break;
 	case STM32_GPIO_MODE_IN:
 		dir_flags |= GPIOD_IS_IN;
-		switch (stm32_gpio_get_pupd(regs, idx)) {
-		case STM32_GPIO_PUPD_UP:
-			dir_flags |= GPIOD_PULL_UP;
-			break;
-		case STM32_GPIO_PUPD_DOWN:
-			dir_flags |= GPIOD_PULL_DOWN;
-			break;
-		default:
-			break;
-		}
+		break;
+	default:
+		break;
+	}
+	switch (stm32_gpio_get_pupd(regs, idx)) {
+	case STM32_GPIO_PUPD_UP:
+		dir_flags |= GPIOD_PULL_UP;
+		break;
+	case STM32_GPIO_PUPD_DOWN:
+		dir_flags |= GPIOD_PULL_DOWN;
 		break;
 	default:
 		break;
-- 
2.17.1

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

* [PATCH 2/2] gpio: stm32: correct the bias management
  2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
@ 2020-10-28 10:15   ` Patrick DELAUNAY
  2020-11-25  9:43   ` Patrice CHOTARD
  2020-11-25 11:03   ` Patrick DELAUNAY
  2 siblings, 0 replies; 7+ messages in thread
From: Patrick DELAUNAY @ 2020-10-28 10:15 UTC (permalink / raw)
  To: u-boot

Hi Marek,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: mercredi 28 octobre 2020 10:49
> 
> Use the bias configuration for all the GPIO configurations and not only for input
> GPIO, as indicated in Reference manual (Table 81. Port bit configuration table).
> 
> Fixes: 43efbb6a3ebf0223f9eab8d45916f602d876319f ("gpio: stm32: add ops
> get_dir_flags")
> Fixes: f13ff88b61c32ac8f0e9068c41328b265ef619eb ("gpio: stm32: add ops
> set_dir_flags")
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
>  drivers/gpio/stm32_gpio.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
(...)

Can you test this patch on avenger board,
I expect it correct the SD card detect issue (pull-up not configurated).

Thanks.

Patrick

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

* [PATCH 1/2] pinctrl: stm32: display bias information for all pins
  2020-10-28  9:49 [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrick Delaunay
  2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
@ 2020-11-25  9:43 ` Patrice CHOTARD
  2020-11-25 11:03 ` Patrick DELAUNAY
  2 siblings, 0 replies; 7+ messages in thread
From: Patrice CHOTARD @ 2020-11-25  9:43 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 10/28/20 10:49 AM, Patrick Delaunay wrote:
> Display the bias information for input gpios or AF configuration,
> and not only for output pin, as described in Reference manual
> (Table 81. Port bit configuration table).
>
> Fixes: da7a0bb1f279 ("pinctrl: stm32: add information on pin configuration")
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  drivers/pinctrl/pinctrl_stm32.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
> index dbea99532c..262b2c3d7e 100644
> --- a/drivers/pinctrl/pinctrl_stm32.c
> +++ b/drivers/pinctrl/pinctrl_stm32.c
> @@ -48,15 +48,15 @@ static const char * const pinmux_mode[PINMUX_MODE_COUNT] = {
>  	"alt function",
>  };
>  
> -static const char * const pinmux_output[] = {
> -	[STM32_GPIO_PUPD_NO] = "bias-disable",
> -	[STM32_GPIO_PUPD_UP] = "bias-pull-up",
> -	[STM32_GPIO_PUPD_DOWN] = "bias-pull-down",
> +static const char * const pinmux_bias[] = {
> +	[STM32_GPIO_PUPD_NO] = "",
> +	[STM32_GPIO_PUPD_UP] = "pull-up",
> +	[STM32_GPIO_PUPD_DOWN] = "pull-down",
>  };
>  
>  static const char * const pinmux_input[] = {
> -	[STM32_GPIO_OTYPE_PP] = "drive-push-pull",
> -	[STM32_GPIO_OTYPE_OD] = "drive-open-drain",
> +	[STM32_GPIO_OTYPE_PP] = "push-pull",
> +	[STM32_GPIO_OTYPE_OD] = "open-drain",
>  };
>  
>  static int stm32_pinctrl_get_af(struct udevice *dev, unsigned int offset)
> @@ -213,6 +213,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
>  	dev_dbg(dev, "selector = %d gpio_idx = %d mode = %d\n",
>  		selector, gpio_idx, mode);
>  	priv = dev_get_priv(gpio_dev);
> +	pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) & PUPD_MASK;
>  
>  
>  	switch (mode) {
> @@ -224,20 +225,19 @@ 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", pinmux_mode[mode], af_num);
> +		snprintf(buf, size, "%s %d %s", pinmux_mode[mode], af_num,
> +			 pinmux_bias[pupd]);
>  		break;
>  	case GPIOF_OUTPUT:
> -		pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) &
> -		       PUPD_MASK;
>  		snprintf(buf, size, "%s %s %s",
> -			 pinmux_mode[mode], pinmux_output[pupd],
> +			 pinmux_mode[mode], pinmux_bias[pupd],
>  			 label ? label : "");
>  		break;
>  	case GPIOF_INPUT:
>  		otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
> -		snprintf(buf, size, "%s %s %s",
> +		snprintf(buf, size, "%s %s %s %s",
>  			 pinmux_mode[mode], pinmux_input[otype],
> -			 label ? label : "");
> +			 pinmux_bias[pupd], label ? label : "");
>  		break;
>  	}
>  

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

Patrice

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

* [PATCH 2/2] gpio: stm32: correct the bias management
  2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
  2020-10-28 10:15   ` Patrick DELAUNAY
@ 2020-11-25  9:43   ` Patrice CHOTARD
  2020-11-25 11:03   ` Patrick DELAUNAY
  2 siblings, 0 replies; 7+ messages in thread
From: Patrice CHOTARD @ 2020-11-25  9:43 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 10/28/20 10:49 AM, Patrick Delaunay wrote:
> Use the bias configuration for all the GPIO configurations and not
> only for input GPIO, as indicated in Reference manual
> (Table 81. Port bit configuration table).
>
> Fixes: 43efbb6a3ebf0223f9eab8d45916f602d876319f ("gpio: stm32: add ops get_dir_flags")
> Fixes: f13ff88b61c32ac8f0e9068c41328b265ef619eb ("gpio: stm32: add ops set_dir_flags")
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  drivers/gpio/stm32_gpio.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
> index b885cfb57e..51e1efd701 100644
> --- a/drivers/gpio/stm32_gpio.c
> +++ b/drivers/gpio/stm32_gpio.c
> @@ -212,11 +212,11 @@ static int stm32_gpio_set_dir_flags(struct udevice *dev, unsigned int offset,
>  
>  	} else if (flags & GPIOD_IS_IN) {
>  		stm32_gpio_set_moder(regs, idx, STM32_GPIO_MODE_IN);
> -		if (flags & GPIOD_PULL_UP)
> -			stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_UP);
> -		else if (flags & GPIOD_PULL_DOWN)
> -			stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_DOWN);
>  	}
> +	if (flags & GPIOD_PULL_UP)
> +		stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_UP);
> +	else if (flags & GPIOD_PULL_DOWN)
> +		stm32_gpio_set_pupd(regs, idx, STM32_GPIO_PUPD_DOWN);
>  
>  	return 0;
>  }
> @@ -243,16 +243,16 @@ static int stm32_gpio_get_dir_flags(struct udevice *dev, unsigned int offset,
>  		break;
>  	case STM32_GPIO_MODE_IN:
>  		dir_flags |= GPIOD_IS_IN;
> -		switch (stm32_gpio_get_pupd(regs, idx)) {
> -		case STM32_GPIO_PUPD_UP:
> -			dir_flags |= GPIOD_PULL_UP;
> -			break;
> -		case STM32_GPIO_PUPD_DOWN:
> -			dir_flags |= GPIOD_PULL_DOWN;
> -			break;
> -		default:
> -			break;
> -		}
> +		break;
> +	default:
> +		break;
> +	}
> +	switch (stm32_gpio_get_pupd(regs, idx)) {
> +	case STM32_GPIO_PUPD_UP:
> +		dir_flags |= GPIOD_PULL_UP;
> +		break;
> +	case STM32_GPIO_PUPD_DOWN:
> +		dir_flags |= GPIOD_PULL_DOWN;
>  		break;
>  	default:
>  		break;

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

Patrice

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

* [PATCH 1/2] pinctrl: stm32: display bias information for all pins
  2020-10-28  9:49 [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrick Delaunay
  2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
  2020-11-25  9:43 ` [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrice CHOTARD
@ 2020-11-25 11:03 ` Patrick DELAUNAY
  2 siblings, 0 replies; 7+ messages in thread
From: Patrick DELAUNAY @ 2020-11-25 11:03 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: mercredi 28 octobre 2020 10:49
> 
> Display the bias information for input gpios or AF configuration, and not only for
> output pin, as described in Reference manual (Table 81. Port bit configuration
> table).
> 
> Fixes: da7a0bb1f279 ("pinctrl: stm32: add information on pin configuration")
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
>  drivers/pinctrl/pinctrl_stm32.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 

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

Regards

Patrick

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

* [PATCH 2/2] gpio: stm32: correct the bias management
  2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
  2020-10-28 10:15   ` Patrick DELAUNAY
  2020-11-25  9:43   ` Patrice CHOTARD
@ 2020-11-25 11:03   ` Patrick DELAUNAY
  2 siblings, 0 replies; 7+ messages in thread
From: Patrick DELAUNAY @ 2020-11-25 11:03 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: mercredi 28 octobre 2020 10:49
> 
> Use the bias configuration for all the GPIO configurations and not only for input
> GPIO, as indicated in Reference manual (Table 81. Port bit configuration table).
> 
> Fixes: 43efbb6a3ebf0223f9eab8d45916f602d876319f ("gpio: stm32: add ops
> get_dir_flags")
> Fixes: f13ff88b61c32ac8f0e9068c41328b265ef619eb ("gpio: stm32: add ops
> set_dir_flags")
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
>  drivers/gpio/stm32_gpio.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 

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

Regards

Patrick

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

end of thread, other threads:[~2020-11-25 11:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28  9:49 [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrick Delaunay
2020-10-28  9:49 ` [PATCH 2/2] gpio: stm32: correct the bias management Patrick Delaunay
2020-10-28 10:15   ` Patrick DELAUNAY
2020-11-25  9:43   ` Patrice CHOTARD
2020-11-25 11:03   ` Patrick DELAUNAY
2020-11-25  9:43 ` [PATCH 1/2] pinctrl: stm32: display bias information for all pins Patrice CHOTARD
2020-11-25 11:03 ` Patrick DELAUNAY

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.