All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI
@ 2016-09-12  7:36 Simon Horman
  2016-09-12  7:36 ` [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Horman @ 2016-09-12  7:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, linux-renesas-soc,
	linux-gpio, Simon Horman

Hi,

this series adds voltage switching for SDHI to sh-pfc for the r8a7791 and
r8a794 SoCs. It is based on work for the r8a7790 SoC by Wolfram Sang.

The r8a7793 should be able to be trivially supported using the
same mechanism as r8a7791. I intend to provide a follow-up patch
once testing is completed.

Changes since v1 detailed in per-patch changelogs.

Based on sh-pfc-for-v4.9 branch of renesas-drivers tree.

Simon Horman (3):
  pinctrl: sh-pfc: Add PORT_GP_24 helper macro
  pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI
  pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI

 drivers/pinctrl/sh-pfc/pfc-r8a7791.c | 29 ++++++++++++++++++++++++++++-
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 28 +++++++++++++++++++++++++++-
 drivers/pinctrl/sh-pfc/sh_pfc.h      |  8 ++++++--
 3 files changed, 61 insertions(+), 4 deletions(-)

-- 
2.7.0.rc3.207.g0ac5344

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

* [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro
  2016-09-12  7:36 [PATCH v2 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
@ 2016-09-12  7:36 ` Simon Horman
  2016-09-12  8:44   ` Geert Uytterhoeven
  2016-09-12  7:36 ` [PATCH v2 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
  2016-09-12  7:36 ` [PATCH v2 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman
  2 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2016-09-12  7:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, linux-renesas-soc,
	linux-gpio, Simon Horman

This follows the style of existing PORT_GP_X macros and
will be used by a follow-up patch for the r8a7791 SoC.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
v2
* Rebase
---
 drivers/pinctrl/sh-pfc/sh_pfc.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h
index c24067edcec4..2345421103db 100644
--- a/drivers/pinctrl/sh-pfc/sh_pfc.h
+++ b/drivers/pinctrl/sh-pfc/sh_pfc.h
@@ -422,9 +422,13 @@ extern const struct sh_pfc_soc_info shx3_pinmux_info;
 	PORT_GP_CFG_1(bank, 22, fn, sfx, cfg)
 #define PORT_GP_23(bank, fn, sfx)	PORT_GP_CFG_23(bank, fn, sfx, 0)
 
-#define PORT_GP_CFG_26(bank, fn, sfx, cfg)				\
+#define PORT_GP_CFG_24(bank, fn, sfx, cfg)				\
 	PORT_GP_CFG_23(bank, fn, sfx, cfg),				\
-	PORT_GP_CFG_1(bank, 23, fn, sfx, cfg),				\
+	PORT_GP_CFG_1(bank, 23, fn, sfx, cfg)
+#define PORT_GP_24(bank, fn, sfx)	PORT_GP_CFG_24(bank, fn, sfx, 0)
+
+#define PORT_GP_CFG_26(bank, fn, sfx, cfg)				\
+	PORT_GP_CFG_24(bank, fn, sfx, cfg),				\
 	PORT_GP_CFG_1(bank, 24, fn, sfx, cfg),				\
 	PORT_GP_CFG_1(bank, 25, fn, sfx, cfg)
 #define PORT_GP_26(bank, fn, sfx)	PORT_GP_CFG_26(bank, fn, sfx, 0)
-- 
2.7.0.rc3.207.g0ac5344


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

* [PATCH v2 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI
  2016-09-12  7:36 [PATCH v2 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
  2016-09-12  7:36 ` [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
@ 2016-09-12  7:36 ` Simon Horman
  2016-09-12  7:36 ` [PATCH v2 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2016-09-12  7:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, linux-renesas-soc,
	linux-gpio, Simon Horman, Wolfram Sang

All the SHDIs can operate with either 3.3V or 1.8V signals, depending
on negotiation with the card.

Based on work by Wolfram Sang for the r8a7790.

Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
v2
* Correct comment above CPU_ALL_PORT
---
 drivers/pinctrl/sh-pfc/pfc-r8a7791.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
index 0c1a60c9a844..7ca37c3019ab 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
@@ -13,6 +13,10 @@
 
 #include "sh_pfc.h"
 
+/*
+ * Pins 0-23 assigned to GPIO bank 6 can be used for SD interfaces in
+ * which case they support both 3.3V and 1.8V signalling.
+ */
 #define CPU_ALL_PORT(fn, sfx)						\
 	PORT_GP_32(0, fn, sfx),						\
 	PORT_GP_26(1, fn, sfx),						\
@@ -20,7 +24,15 @@
 	PORT_GP_32(3, fn, sfx),						\
 	PORT_GP_32(4, fn, sfx),						\
 	PORT_GP_32(5, fn, sfx),						\
-	PORT_GP_32(6, fn, sfx),						\
+	PORT_GP_CFG_24(6, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),		\
+	PORT_GP_1(6, 24, fn, sfx),					\
+	PORT_GP_1(6, 25, fn, sfx),					\
+	PORT_GP_1(6, 26, fn, sfx),					\
+	PORT_GP_1(6, 27, fn, sfx),					\
+	PORT_GP_1(6, 28, fn, sfx),					\
+	PORT_GP_1(6, 29, fn, sfx),					\
+	PORT_GP_1(6, 30, fn, sfx),					\
+	PORT_GP_1(6, 31, fn, sfx),					\
 	PORT_GP_26(7, fn, sfx)
 
 enum {
@@ -6404,9 +6416,24 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
 	{ },
 };
 
+static int r8a7791_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocctrl)
+{
+	if (pin < RCAR_GP_PIN(6, 0) || pin > RCAR_GP_PIN(6, 23))
+		return -EINVAL;
+
+	*pocctrl = 0xe606008c;
+
+	return 31 - (pin & 0x1f);
+}
+
+static const struct sh_pfc_soc_operations r8a7791_pinmux_ops = {
+	.pin_to_pocctrl = r8a7791_pin_to_pocctrl,
+};
+
 #ifdef CONFIG_PINCTRL_PFC_R8A7791
 const struct sh_pfc_soc_info r8a7791_pinmux_info = {
 	.name = "r8a77910_pfc",
+	.ops = &r8a7791_pinmux_ops,
 	.unlock_reg = 0xe6060000, /* PMMR */
 
 	.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
-- 
2.7.0.rc3.207.g0ac5344


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

* [PATCH v2 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
  2016-09-12  7:36 [PATCH v2 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
  2016-09-12  7:36 ` [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
  2016-09-12  7:36 ` [PATCH v2 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
@ 2016-09-12  7:36 ` Simon Horman
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2016-09-12  7:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, linux-renesas-soc,
	linux-gpio, Simon Horman

All the SHDIs can operate with either 3.3V or 1.8V signals, depending
on negotiation with the card.

Based on work by Wolfram Sang for the r8a7790.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
v2
* Use switch statement
---
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
index 8bc2cf0c594e..ed734f560c84 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
@@ -22,7 +22,9 @@
 	PORT_GP_32(3, fn, sfx),						\
 	PORT_GP_32(4, fn, sfx),						\
 	PORT_GP_28(5, fn, sfx),						\
-	PORT_GP_26(6, fn, sfx)
+	PORT_GP_CFG_24(6, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),		\
+	PORT_GP_1(6, 24, fn, sfx),					\
+	PORT_GP_1(6, 25, fn, sfx)
 
 enum {
 	PINMUX_RESERVED = 0,
@@ -5160,8 +5162,32 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
 	{ },
 };
 
+static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocctrl)
+{
+	*pocctrl = 0xe606006c;
+
+	switch (pin & 0x1f) {
+	case 6: return 23;
+	case 7: return 16;
+	case 14: return 15;
+	case 15: return 8;
+	case 0 ... 5:
+	case 8 ... 13:
+		return 22 - (pin & 0x1f);
+	case 16 ... 23:
+		return 47 - (pin & 0x1f);
+	}
+
+	return -EINVAL;
+}
+
+static const struct sh_pfc_soc_operations r8a7794_pinmux_ops = {
+	.pin_to_pocctrl = r8a7794_pin_to_pocctrl,
+};
+
 const struct sh_pfc_soc_info r8a7794_pinmux_info = {
 	.name = "r8a77940_pfc",
+	.ops = &r8a7794_pinmux_ops,
 	.unlock_reg = 0xe6060000, /* PMMR */
 
 	.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
-- 
2.7.0.rc3.207.g0ac5344

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

* Re: [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro
  2016-09-12  7:36 ` [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
@ 2016-09-12  8:44   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2016-09-12  8:44 UTC (permalink / raw)
  To: Simon Horman
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, Linux-Renesas, linux-gpio

On Mon, Sep 12, 2016 at 9:36 AM, Simon Horman
<horms+renesas@verge.net.au> wrote:
> This follows the style of existing PORT_GP_X macros and
> will be used by a follow-up patch for the r8a7791 SoC.
>
> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

(will queue in sh-pfc-for-v4.9)

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] 5+ messages in thread

end of thread, other threads:[~2016-09-12  8:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12  7:36 [PATCH v2 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
2016-09-12  7:36 ` [PATCH v2 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
2016-09-12  8:44   ` Geert Uytterhoeven
2016-09-12  7:36 ` [PATCH v2 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
2016-09-12  7:36 ` [PATCH v2 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman

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.