From fa359d75f35900293ca8ee3189d9f0f867f4f8c0 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 26 Sep 2016 15:34:59 -0700 Subject: pinctrl: freescale: avoid overwriting pin config when freeing GPIO 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 Acked-by: Max Krummenacher --- drivers/pinctrl/freescale/pinctrl-imx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index a7e1cc80d904..3035d33f5957 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -363,8 +363,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); } -- cgit v1.2.3