linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: sh-pfc: r8a77990: Add support for pull-up only pins
@ 2018-12-07 14:03 Geert Uytterhoeven
  2018-12-10 11:54 ` Simon Horman
  2018-12-18 10:03 ` Geert Uytterhoeven
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2018-12-07 14:03 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Yoshihiro Shimoda, linux-renesas-soc, linux-gpio, Geert Uytterhoeven

The R-Car Gen3 HardWare Manual Errata for Rev. 1.00 (Jul 2, 2018) states
that the USB30_OVC pin supports pull-up only.  It has a bit assigned in
the pull-enable register (PUEN5), but not in the pull-up/down control
register (PUD5).

Add a check for this, to prevent configuring a prohibited setting.

Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Fixes: 83f6941a42a5e773 ("pinctrl: sh-pfc: r8a77990: Add bias pinconf support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
To be queued in sh-pfc-for-v4.22.

 drivers/pinctrl/sh-pfc/pfc-r8a77990.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
index 8c06d72753890e32..784d4400c3e0e7ea 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
@@ -4914,6 +4914,17 @@ static const struct pinmux_bias_reg pinmux_bias_regs[] = {
 	{ /* sentinel */ },
 };
 
+static bool pin_has_pud(unsigned int pin)
+{
+	/* Some pins are pull-up only */
+	switch (pin) {
+	case RCAR_GP_PIN(6, 9):	/* USB30_OVC  */
+		return false;
+	}
+
+	return true;
+}
+
 static unsigned int r8a77990_pinmux_get_bias(struct sh_pfc *pfc,
 					     unsigned int pin)
 {
@@ -4926,7 +4937,7 @@ static unsigned int r8a77990_pinmux_get_bias(struct sh_pfc *pfc,
 
 	if (!(sh_pfc_read(pfc, reg->puen) & BIT(bit)))
 		return PIN_CONFIG_BIAS_DISABLE;
-	else if (sh_pfc_read(pfc, reg->pud) & BIT(bit))
+	else if (!pin_has_pud(pin) || (sh_pfc_read(pfc, reg->pud) & BIT(bit)))
 		return PIN_CONFIG_BIAS_PULL_UP;
 	else
 		return PIN_CONFIG_BIAS_PULL_DOWN;
@@ -4947,11 +4958,13 @@ static void r8a77990_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
 	if (bias != PIN_CONFIG_BIAS_DISABLE)
 		enable |= BIT(bit);
 
-	updown = sh_pfc_read(pfc, reg->pud) & ~BIT(bit);
-	if (bias == PIN_CONFIG_BIAS_PULL_UP)
-		updown |= BIT(bit);
+	if (pin_has_pud(pin)) {
+		updown = sh_pfc_read(pfc, reg->pud) & ~BIT(bit);
+		if (bias == PIN_CONFIG_BIAS_PULL_UP)
+			updown |= BIT(bit);
 
-	sh_pfc_write(pfc, reg->pud, updown);
+		sh_pfc_write(pfc, reg->pud, updown);
+	}
 	sh_pfc_write(pfc, reg->puen, enable);
 }
 
-- 
2.17.1

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

* Re: [PATCH] pinctrl: sh-pfc: r8a77990: Add support for pull-up only pins
  2018-12-07 14:03 [PATCH] pinctrl: sh-pfc: r8a77990: Add support for pull-up only pins Geert Uytterhoeven
@ 2018-12-10 11:54 ` Simon Horman
  2018-12-18 10:03 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2018-12-10 11:54 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Yoshihiro Shimoda, linux-renesas-soc, linux-gpio

On Fri, Dec 07, 2018 at 03:03:43PM +0100, Geert Uytterhoeven wrote:
> The R-Car Gen3 HardWare Manual Errata for Rev. 1.00 (Jul 2, 2018) states
> that the USB30_OVC pin supports pull-up only.  It has a bit assigned in
> the pull-enable register (PUEN5), but not in the pull-up/down control
> register (PUD5).
> 
> Add a check for this, to prevent configuring a prohibited setting.
> 
> Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Fixes: 83f6941a42a5e773 ("pinctrl: sh-pfc: r8a77990: Add bias pinconf support")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

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

* Re: [PATCH] pinctrl: sh-pfc: r8a77990: Add support for pull-up only pins
  2018-12-07 14:03 [PATCH] pinctrl: sh-pfc: r8a77990: Add support for pull-up only pins Geert Uytterhoeven
  2018-12-10 11:54 ` Simon Horman
@ 2018-12-18 10:03 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2018-12-18 10:03 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Yoshihiro Shimoda, Linux-Renesas,
	open list:GPIO SUBSYSTEM

On Fri, Dec 7, 2018 at 3:03 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> The R-Car Gen3 HardWare Manual Errata for Rev. 1.00 (Jul 2, 2018) states
> that the USB30_OVC pin supports pull-up only.  It has a bit assigned in
> the pull-enable register (PUEN5), but not in the pull-up/down control
> register (PUD5).
>
> Add a check for this, to prevent configuring a prohibited setting.
>
> Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Fixes: 83f6941a42a5e773 ("pinctrl: sh-pfc: r8a77990: Add bias pinconf support")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> To be queued in sh-pfc-for-v4.22.

Given I have more fixes, I'm queuing this in sh-pfc-for-v4.21.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2018-12-18 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 14:03 [PATCH] pinctrl: sh-pfc: r8a77990: Add support for pull-up only pins Geert Uytterhoeven
2018-12-10 11:54 ` Simon Horman
2018-12-18 10:03 ` Geert Uytterhoeven

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