diff mbox

[U-Boot] mxs_gpio: fix the handling in gpio_direction_output()

Message ID 1383515966-16161-1-git-send-email-mhei@heimpold.de
State Accepted
Delegated to: Stefano Babic
Headers show

Commit Message

Michael Heimpold Nov. 3, 2013, 9:59 p.m. UTC
Setting the direction and an output value should be done by
1) set the desired output value,
2) switch to output.

If this is done in the inverse order, there can be a glitch on
the GPIO line.

This patch fixes this by using the order as described above.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
 drivers/gpio/mxs_gpio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Babic Nov. 4, 2013, 9:08 a.m. UTC | #1
Hi Michael,

On 03/11/2013 22:59, Michael Heimpold wrote:
> Setting the direction and an output value should be done by
> 1) set the desired output value,
> 2) switch to output.
> 
> If this is done in the inverse order, there can be a glitch on
> the GPIO line.
> 
> This patch fixes this by using the order as described above.
> 
> Signed-off-by: Michael Heimpold <mhei@heimpold.de>
> ---
>  drivers/gpio/mxs_gpio.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
> index d9a7a3a..da0199b 100644
> --- a/drivers/gpio/mxs_gpio.c
> +++ b/drivers/gpio/mxs_gpio.c
> @@ -95,10 +95,10 @@ int gpio_direction_output(unsigned gpio, int value)
>  	struct mxs_register_32 *reg =
>  		(struct mxs_register_32 *)(MXS_PINCTRL_BASE + offset);
>  
> -	writel(1 << PAD_PIN(gpio), &reg->reg_set);
> -
>  	gpio_set_value(gpio, value);
>  
> +	writel(1 << PAD_PIN(gpio), &reg->reg_set);
> +

Yes, we had the same fix for mxc (commit
04c79cbd5f8f773aa7823feec6e77862e7e6426f)

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Stefano Babic Nov. 13, 2013, 9:13 a.m. UTC | #2
On 03/11/2013 22:59, Michael Heimpold wrote:
> Setting the direction and an output value should be done by
> 1) set the desired output value,
> 2) switch to output.
> 
> If this is done in the inverse order, there can be a glitch on
> the GPIO line.
> 
> This patch fixes this by using the order as described above.
> 
> Signed-off-by: Michael Heimpold <mhei@heimpold.de>
> ---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index d9a7a3a..da0199b 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -95,10 +95,10 @@  int gpio_direction_output(unsigned gpio, int value)
 	struct mxs_register_32 *reg =
 		(struct mxs_register_32 *)(MXS_PINCTRL_BASE + offset);
 
-	writel(1 << PAD_PIN(gpio), &reg->reg_set);
-
 	gpio_set_value(gpio, value);
 
+	writel(1 << PAD_PIN(gpio), &reg->reg_set);
+
 	return 0;
 }