diff mbox series

[2/2] gpio: stm32: correct the bias management

Message ID 20201028094908.11031-2-patrick.delaunay@st.com
State Accepted
Delegated to: Patrick Delaunay
Headers show
Series [1/2] pinctrl: stm32: display bias information for all pins | expand

Commit Message

Patrick Delaunay Oct. 28, 2020, 9:49 a.m. UTC
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(-)

Comments

Patrick Delaunay Oct. 28, 2020, 10:15 a.m. UTC | #1
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
Patrice CHOTARD Nov. 25, 2020, 9:43 a.m. UTC | #2
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
Patrick Delaunay Nov. 25, 2020, 11:03 a.m. UTC | #3
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
diff mbox series

Patch

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;