Skip to contentSkip to conversation

mxs_gpio: fix the handling in gpio_direction_output()

PATCH New Michael Heimpold 2 participants 3 messages Nov 3, 2013 – Nov 13, 2013

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

PATCH 1/1 mxs_gpio: fix the handling in gpio_direction_output()

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.

---
 drivers/gpio/mxs_gpio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/mxs_gpio.c +2 -2
index d9a7a3a..da0199b 100644
@@ -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;
 }
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 mxs_gpio: fix the handling in gpio_direction_output()

Hi Michael,

Quoted 19 lines · Michael Heimpold

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.

---
 drivers/gpio/mxs_gpio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/mxs_gpio.c +0 -0
index d9a7a3a..da0199b 100644

drivers/gpio/mxs_gpio.c int gpio_direction_output(unsigned gpio, int value) · line 101

Quoted 9 lines
drivers/gpio/mxs_gpio.c +2 -2
@@ -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)

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#2 lore raw

PATCH 1/1 mxs_gpio: fix the handling in gpio_direction_output()

In reply to Michael Heimpold
Quoted 11 lines · Michael Heimpold

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.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================