linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: intel: Implements gpio free function
@ 2019-03-21  2:35 zhuchangchun
  2019-03-21  8:44 ` Mika Westerberg
  0 siblings, 1 reply; 18+ messages in thread
From: zhuchangchun @ 2019-03-21  2:35 UTC (permalink / raw)
  To: mika.westerberg, andriy.shevchenko
  Cc: linus.walleij, linux-gpio, linux-kernel, hendychu, zhuchangchun

When we use the gpio to control some peripheral devices,and try to
export the gpio first,then unexport the gpio, we test the signal with
oscilloscope,and find the signal can't meet the requirements,because
after we unexported the gpio,the gpio's register(tx and rx)value can't
be recovered,and this will infruence the device work flow.

We check the gpio's unexport code work flow, then find the gpio's free
hook function has not been implemented, After we add pinmux_ops' free
function to set exported gpio to recover its original value,the problem
is fixed.

Signed-off-by: zhuchangchun <zhuchangchun@cvte.com>
---
 drivers/pinctrl/intel/pinctrl-intel.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 3b18181..002b9d3 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -480,6 +480,33 @@ static int intel_gpio_set_direction(struct pinctrl_dev *pctldev,
 	return 0;
 }
 
+static int intel_gpio_free(struct pinctrl_dev *pctldev, unsigned int pin)
+{
+	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
+	void __iomem *padcfg0;
+	unsigned long flags;
+	u32 value;
+
+	spin_lock_irqsave(&pctrl->lock, flags);
+
+	if (!intel_pad_usable(pctrl, pin)) {
+		spin_unlock_irqrestore(&pctrl->lock, flags);
+		return -EBUSY;
+	}
+	padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
+
+	/* Put the pad into GPIO mode */
+	value = readl(padcfg0) & ~PADCFG0_PMODE_MASK;
+	/* enable TX buffer and disable RX (this will be input) */
+	value |= PADCFG0_GPIORXDIS;
+	value &= ~PADCFG0_GPIOTXDIS;
+	writel(value, padcfg0);
+
+	spin_unlock_irqrestore(&pctrl->lock, flags);
+
+	return 0;
+}
+
 static const struct pinmux_ops intel_pinmux_ops = {
 	.get_functions_count = intel_get_functions_count,
 	.get_function_name = intel_get_function_name,
@@ -487,6 +514,7 @@ static const struct pinmux_ops intel_pinmux_ops = {
 	.set_mux = intel_pinmux_set_mux,
 	.gpio_request_enable = intel_gpio_request_enable,
 	.gpio_set_direction = intel_gpio_set_direction,
+	.free = intel_gpio_free,
 };
 
 static int intel_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
-- 
2.7.4




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

end of thread, other threads:[~2019-04-04 16:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21  2:35 [PATCH] pinctrl: intel: Implements gpio free function zhuchangchun
2019-03-21  8:44 ` Mika Westerberg
2019-03-21  9:23   ` Andy Shevchenko
2019-03-22 18:32     ` Enrico Weigelt, metux IT consult
2019-03-22 19:06       ` Andy Shevchenko
2019-03-25  9:36         ` Enrico Weigelt, metux IT consult
2019-03-25 11:45           ` Andy Shevchenko
2019-04-03  4:13       ` Linus Walleij
2019-04-04 10:51         ` Enrico Weigelt, metux IT consult
2019-04-04 11:52           ` Andy Shevchenko
2019-04-04 16:03           ` Linus Walleij
     [not found]   ` <2019032119195575582546@cvte.com>
2019-03-21 12:03     ` Mika Westerberg
     [not found]       ` <2019032120213955866649@cvte.com>
2019-03-21 12:36         ` Mika Westerberg
     [not found]           ` <2019032121342663125658@cvte.com>
2019-03-21 13:56             ` Mika Westerberg
     [not found]               ` <2019032211131426883268@cvte.com>
2019-03-22 10:42                 ` Mika Westerberg
     [not found]                   ` <2019032314505202825175@cvte.com>
2019-03-23 16:48                     ` andriy.shevchenko
     [not found]                       ` <2019032517511048990383@cvte.com>
2019-03-25 11:48                         ` andriy.shevchenko
2019-03-22 18:35               ` Enrico Weigelt, metux IT consult

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).