LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] pinctrl: cherryview: Configure HiZ pins to be input when requested as GPIOs
@ 2015-01-29 10:44 Mika Westerberg
  2015-02-04  9:01 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2015-01-29 10:44 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jerome Blin, Heikki Krogerus, Mika Westerberg, linux-gpio, linux-kernel

If the pin is in HiZ mode when it is requested as GPIO its value cannot be
read (it always returns 0). In order to cope with the Linux GPIO subsystem
where we do not have such state at all, turn the pin to be input instead.

Reported-by: Jerome Blin <jerome.blin@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index dde67d425e9c..abe18960933d 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -880,9 +880,22 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
 		value &= ~CHV_PADCTRL1_INVRXTX_MASK;
 		chv_writel(value, reg);
 
-		/* Switch to a GPIO mode */
 		reg = chv_padreg(pctrl, offset, CHV_PADCTRL0);
-		value = readl(reg) | CHV_PADCTRL0_GPIOEN;
+		value = readl(reg);
+
+		/*
+		 * If the pin is in HiZ mode (both TX and RX buffers are
+		 * disabled) we turn it to be input now.
+		 */
+		if ((value & CHV_PADCTRL0_GPIOCFG_MASK) ==
+		     (CHV_PADCTRL0_GPIOCFG_HIZ << CHV_PADCTRL0_GPIOCFG_SHIFT)) {
+			value &= ~CHV_PADCTRL0_GPIOCFG_MASK;
+			value |= CHV_PADCTRL0_GPIOCFG_GPI <<
+				CHV_PADCTRL0_GPIOCFG_SHIFT;
+		}
+
+		/* Switch to a GPIO mode */
+		value |= CHV_PADCTRL0_GPIOEN;
 		chv_writel(value, reg);
 	}
 
-- 
2.1.4


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

* Re: [PATCH] pinctrl: cherryview: Configure HiZ pins to be input when requested as GPIOs
  2015-01-29 10:44 [PATCH] pinctrl: cherryview: Configure HiZ pins to be input when requested as GPIOs Mika Westerberg
@ 2015-02-04  9:01 ` Linus Walleij
  2015-02-04 15:37   ` Mika Westerberg
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2015-02-04  9:01 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: Jerome Blin, Heikki Krogerus, linux-gpio, linux-kernel

On Thu, Jan 29, 2015 at 11:44 AM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:

> If the pin is in HiZ mode when it is requested as GPIO its value cannot be
> read (it always returns 0). In order to cope with the Linux GPIO subsystem
> where we do not have such state at all, turn the pin to be input instead.
>
> Reported-by: Jerome Blin <jerome.blin@intel.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Patch applied.

Since putting a pin into GPIO mode start poking around in essentially pin
control registers, we may need to revisit the issue of the pin control subsystem
not denying simultaneous use of a pin for a device muxing and GPIO.
Maybe the "strict" setting forcing a pin to be either one or the other on
a per-driver basis would enforce a better policy on this driver (and some
others).

Yours,
Linus Walleij

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

* Re: [PATCH] pinctrl: cherryview: Configure HiZ pins to be input when requested as GPIOs
  2015-02-04  9:01 ` Linus Walleij
@ 2015-02-04 15:37   ` Mika Westerberg
  0 siblings, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2015-02-04 15:37 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jerome Blin, Heikki Krogerus, linux-gpio, linux-kernel

On Wed, Feb 04, 2015 at 10:01:49AM +0100, Linus Walleij wrote:
> On Thu, Jan 29, 2015 at 11:44 AM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> 
> > If the pin is in HiZ mode when it is requested as GPIO its value cannot be
> > read (it always returns 0). In order to cope with the Linux GPIO subsystem
> > where we do not have such state at all, turn the pin to be input instead.
> >
> > Reported-by: Jerome Blin <jerome.blin@intel.com>
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> 
> Patch applied.

Thanks.

> Since putting a pin into GPIO mode start poking around in essentially pin
> control registers, we may need to revisit the issue of the pin control subsystem
> not denying simultaneous use of a pin for a device muxing and GPIO.
> Maybe the "strict" setting forcing a pin to be either one or the other on
> a per-driver basis would enforce a better policy on this driver (and some
> others).

Yes, something like that sounds reasonable.

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

end of thread, other threads:[~2015-02-04 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 10:44 [PATCH] pinctrl: cherryview: Configure HiZ pins to be input when requested as GPIOs Mika Westerberg
2015-02-04  9:01 ` Linus Walleij
2015-02-04 15:37   ` Mika Westerberg

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).