All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: freescale: avoid overwriting pin config when freeing GPIO
@ 2016-09-27  0:26 Stefan Agner
  2016-09-27 12:12   ` Vladimir Zapolskiy
  2016-10-10  8:33 ` Linus Walleij
  0 siblings, 2 replies; 22+ messages in thread
From: Stefan Agner @ 2016-09-27  0:26 UTC (permalink / raw)
  To: linus.walleij
  Cc: shawnguo, vladimir_zapolskiy, aalonso, b38343, ldewangan,
	van.freenix, p.zabel, linux-gpio, linux-kernel, Stefan Agner

If a GPIO gets freed after selecting a new pinctrl configuration
the driver should not change pinctrl anymore. Otherwise this will
likely lead to a unusable pin configuration for the newly selected
pinctrl.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
This turned out to be problematic when using the I2C GPIO bus recovery
functionality. After muxing back to I2C, the GPIO is being freed, which
cased I2C to stop working completely.

--
Stefan

 drivers/pinctrl/freescale/pinctrl-imx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 4761320..61cfa95 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -361,8 +361,13 @@ static void imx_pmx_gpio_disable_free(struct pinctrl_dev *pctldev,
 	if (pin_reg->mux_reg == -1)
 		return;
 
-	/* Clear IBE/OBE/PUE to disable the pin (Hi-Z) */
 	reg = readl(ipctl->base + pin_reg->mux_reg);
+
+	/* Only change pad configuration if pad is still a GPIO */
+	if (reg & (0x7 << 20))
+		return;
+
+	/* Clear IBE/OBE/PUE to disable the pin (Hi-Z) */
 	reg &= ~0x7;
 	writel(reg, ipctl->base + pin_reg->mux_reg);
 }
-- 
2.10.0


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

end of thread, other threads:[~2016-10-10  8:40 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27  0:26 [PATCH] pinctrl: freescale: avoid overwriting pin config when freeing GPIO Stefan Agner
2016-09-27 12:12 ` Vladimir Zapolskiy
2016-09-27 12:12   ` Vladimir Zapolskiy
2016-09-27 16:37   ` Stefan Agner
2016-09-27 18:17     ` Vladimir Zapolskiy
2016-09-27 18:17       ` Vladimir Zapolskiy
2016-09-27 19:34       ` Stefan Agner
2016-09-27 20:28         ` Vladimir Zapolskiy
2016-09-27 20:28           ` Vladimir Zapolskiy
2016-09-28  2:00         ` Viresh Kumar
2016-09-28  3:38           ` Stefan Agner
2016-09-28  4:14             ` Viresh Kumar
2016-09-29 16:33               ` Stefan Agner
2016-09-30  2:12                 ` Viresh Kumar
2016-10-10  8:32                 ` Linus Walleij
2016-09-28 12:07             ` Vladimir Zapolskiy
2016-09-28 12:07               ` Vladimir Zapolskiy
2016-09-29  6:46               ` Viresh Kumar
2016-09-29 12:16                 ` Vladimir Zapolskiy
2016-09-29 12:16                   ` Vladimir Zapolskiy
2016-09-30  2:22                   ` Viresh Kumar
2016-10-10  8:33 ` Linus Walleij

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.