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

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 | 34 +++++++++++++++++++++++++++++++++-
 drivers/pinctrl/sh-pfc/sh_pfc.h      |  8 ++++++--
 3 files changed, 67 insertions(+), 4 deletions(-)

-- 
2.7.0.rc3.207.g0ac5344


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

* [PATCH 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro
  2016-09-08 11:36 [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
@ 2016-09-08 11:36 ` Simon Horman
  2016-09-09  7:40   ` Geert Uytterhoeven
  2016-09-08 11:36 ` [PATCH 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Simon Horman @ 2016-09-08 11:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, linux-renesas-soc,
	linux-gpio, Wolfram Sang, 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>
---
 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 5e966c09434d..de91b5f247c0 100644
--- a/drivers/pinctrl/sh-pfc/sh_pfc.h
+++ b/drivers/pinctrl/sh-pfc/sh_pfc.h
@@ -399,11 +399,15 @@ extern const struct sh_pfc_soc_info shx3_pinmux_info;
 	PORT_GP_CFG_1(bank, 16, fn, sfx, cfg), PORT_GP_CFG_1(bank, 17, fn, sfx, cfg)
 #define PORT_GP_18(bank, fn, sfx)	PORT_GP_CFG_18(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_18(bank, fn, sfx, cfg),						\
 	PORT_GP_CFG_1(bank, 18, fn, sfx, cfg), PORT_GP_CFG_1(bank, 19, fn, sfx, cfg),	\
 	PORT_GP_CFG_1(bank, 20, fn, sfx, cfg), PORT_GP_CFG_1(bank, 21, fn, sfx, cfg),	\
-	PORT_GP_CFG_1(bank, 22, fn, sfx, cfg), PORT_GP_CFG_1(bank, 23, fn, sfx, cfg),	\
+	PORT_GP_CFG_1(bank, 22, 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] 13+ messages in thread

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

Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 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..b707fc96f208 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"
 
+/*
+ * All pins assigned to GPIO bank 3 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] 13+ messages in thread

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

Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
index 8bc2cf0c594e..c02b367837b7 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,38 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
 	{ },
 };
 
+static int r8a7794_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 = 0xe606006c;
+
+	/* GP6_16-23 -> bits 31-24 of pocctrl
+	 * GP6_06    -> bit  23    of pocctrl
+	 * GP6_00-05 -> bits 22-17 of pocctrl
+	 * GP6_07    -> bit  16    of pocctrl
+	 * GP6_14    -> bit  15    of pocctrl
+	 * GP6_08-13 -> bits 14-09 of pocctrl
+	 * GP6_15    -> bit  08    of pocctrl
+	 */
+	if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
+		return 31 - 2 - (pin & 0x1f);
+	else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
+		return 31 - 8 - (pin & 0x1f);
+	else if (pin < RCAR_GP_PIN(6, 14))
+		return 31 - 9 - (pin & 0x1f);
+	else
+		return 31 + 16 - (pin & 0x1f);
+}
+
+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] 13+ messages in thread

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

Hi Simon,

On Thu, Sep 8, 2016 at 1:36 PM, 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>
> ---
>  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 5e966c09434d..de91b5f247c0 100644
> --- a/drivers/pinctrl/sh-pfc/sh_pfc.h
> +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h
> @@ -399,11 +399,15 @@ extern const struct sh_pfc_soc_info shx3_pinmux_info;
>         PORT_GP_CFG_1(bank, 16, fn, sfx, cfg), PORT_GP_CFG_1(bank, 17, fn, sfx, cfg)
>  #define PORT_GP_18(bank, fn, sfx)      PORT_GP_CFG_18(bank, fn, sfx, 0)
>
> -#define PORT_GP_CFG_26(bank, fn, sfx, cfg)                                             \
> +#define PORT_GP_CFG_24(bank, fn, sfx, cfg)                                             \

This patch no longer applies since "pinctrl: sh-pfc: Add R8A7792 PFC support".

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

* Re: [PATCH 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI
  2016-09-08 11:36 ` [PATCH 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
@ 2016-09-09  7:52   ` Geert Uytterhoeven
  2016-09-09 12:30     ` Wolfram Sang
  0 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2016-09-09  7:52 UTC (permalink / raw)
  To: Simon Horman
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, Linux-Renesas,
	linux-gpio, Wolfram Sang

Hi Simon,

On Thu, Sep 8, 2016 at 1:36 PM, Simon Horman <horms+renesas@verge.net.au> wrote:
> 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>

If you correct the copy-and-pasted comment below, you can add my
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> ---
>  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..b707fc96f208 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"
>
> +/*
> + * All pins assigned to GPIO bank 3 can be used for SD interfaces in

Pins 0-23 assigned to GPIO bank 6...

> + * 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),          \

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

* Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
  2016-09-08 11:36 ` [PATCH 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman
@ 2016-09-09  8:08   ` Geert Uytterhoeven
  2016-09-09 12:30     ` Wolfram Sang
  2016-09-09 15:26     ` Simon Horman
  0 siblings, 2 replies; 13+ messages in thread
From: Geert Uytterhoeven @ 2016-09-09  8:08 UTC (permalink / raw)
  To: Simon Horman
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, Linux-Renesas,
	linux-gpio, Wolfram Sang

Hi Simon,

On Thu, Sep 8, 2016 at 1:36 PM, Simon Horman <horms+renesas@verge.net.au> wrote:
> 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>

> ---
>  drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> index 8bc2cf0c594e..c02b367837b7 100644
> --- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> @@ -5160,8 +5162,38 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
>         { },
>  };
>
> +static int r8a7794_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 = 0xe606006c;
> +
> +       /* GP6_16-23 -> bits 31-24 of pocctrl
> +        * GP6_06    -> bit  23    of pocctrl
> +        * GP6_00-05 -> bits 22-17 of pocctrl
> +        * GP6_07    -> bit  16    of pocctrl
> +        * GP6_14    -> bit  15    of pocctrl
> +        * GP6_08-13 -> bits 14-09 of pocctrl
> +        * GP6_15    -> bit  08    of pocctrl
> +        */
> +       if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
> +               return 31 - 2 - (pin & 0x1f);
> +       else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
> +               return 31 - 8 - (pin & 0x1f);
> +       else if (pin < RCAR_GP_PIN(6, 14))
> +               return 31 - 9 - (pin & 0x1f);
> +       else
> +               return 31 + 16 - (pin & 0x1f);

While your code is correct, I think it's easier for the casual reader to use
a plain switch () statement, and let the optimizer handle the rest.

> +}

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

* Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
  2016-09-09  8:08   ` Geert Uytterhoeven
@ 2016-09-09 12:30     ` Wolfram Sang
  2016-09-09 15:26     ` Simon Horman
  1 sibling, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2016-09-09 12:30 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, Linus Walleij, Magnus Damm,
	Linux-Renesas, linux-gpio, Wolfram Sang

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]


> > +static int r8a7794_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 = 0xe606006c;
> > +
> > +       /* GP6_16-23 -> bits 31-24 of pocctrl
> > +        * GP6_06    -> bit  23    of pocctrl
> > +        * GP6_00-05 -> bits 22-17 of pocctrl
> > +        * GP6_07    -> bit  16    of pocctrl
> > +        * GP6_14    -> bit  15    of pocctrl
> > +        * GP6_08-13 -> bits 14-09 of pocctrl
> > +        * GP6_15    -> bit  08    of pocctrl
> > +        */
> > +       if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
> > +               return 31 - 2 - (pin & 0x1f);
> > +       else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
> > +               return 31 - 8 - (pin & 0x1f);
> > +       else if (pin < RCAR_GP_PIN(6, 14))
> > +               return 31 - 9 - (pin & 0x1f);
> > +       else
> > +               return 31 + 16 - (pin & 0x1f);
> 
> While your code is correct, I think it's easier for the casual reader to use
> a plain switch () statement, and let the optimizer handle the rest.

Both is fine with me:

Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI
  2016-09-09  7:52   ` Geert Uytterhoeven
@ 2016-09-09 12:30     ` Wolfram Sang
  0 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2016-09-09 12:30 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, Linus Walleij, Magnus Damm,
	Linux-Renesas, linux-gpio, Wolfram Sang

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

On Fri, Sep 09, 2016 at 09:52:20AM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Thu, Sep 8, 2016 at 1:36 PM, Simon Horman <horms+renesas@verge.net.au> wrote:
> > 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>
> 
> If you correct the copy-and-pasted comment below, you can add my
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

> > + * All pins assigned to GPIO bank 3 can be used for SD interfaces in
> 
> Pins 0-23 assigned to GPIO bank 6...

I agree.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
  2016-09-09  8:08   ` Geert Uytterhoeven
  2016-09-09 12:30     ` Wolfram Sang
@ 2016-09-09 15:26     ` Simon Horman
  2016-09-09 16:57       ` Geert Uytterhoeven
  1 sibling, 1 reply; 13+ messages in thread
From: Simon Horman @ 2016-09-09 15:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, Linux-Renesas,
	linux-gpio, Wolfram Sang

On Fri, Sep 09, 2016 at 10:08:03AM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Thu, Sep 8, 2016 at 1:36 PM, Simon Horman <horms+renesas@verge.net.au> wrote:
> > 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>
> 
> > ---
> >  drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 34 +++++++++++++++++++++++++++++++++-
> >  1 file changed, 33 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> > index 8bc2cf0c594e..c02b367837b7 100644
> > --- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> > +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> > @@ -5160,8 +5162,38 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
> >         { },
> >  };
> >
> > +static int r8a7794_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 = 0xe606006c;
> > +
> > +       /* GP6_16-23 -> bits 31-24 of pocctrl
> > +        * GP6_06    -> bit  23    of pocctrl
> > +        * GP6_00-05 -> bits 22-17 of pocctrl
> > +        * GP6_07    -> bit  16    of pocctrl
> > +        * GP6_14    -> bit  15    of pocctrl
> > +        * GP6_08-13 -> bits 14-09 of pocctrl
> > +        * GP6_15    -> bit  08    of pocctrl
> > +        */
> > +       if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
> > +               return 31 - 2 - (pin & 0x1f);
> > +       else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
> > +               return 31 - 8 - (pin & 0x1f);
> > +       else if (pin < RCAR_GP_PIN(6, 14))
> > +               return 31 - 9 - (pin & 0x1f);
> > +       else
> > +               return 31 + 16 - (pin & 0x1f);
> 
> While your code is correct, I think it's easier for the casual reader to use
> a plain switch () statement, and let the optimizer handle the rest.

Like this? If so I don't particularly mind but it doesn't seem clearer to
me.

+static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocctrl)
+{
+	*pocctrl = 0xe606006c;
+
+	switch (pin) {
+	case RCAR_GP_PIN(6, 0):
+		return 22;
+	case RCAR_GP_PIN(6, 1):
+		return 21;
+	case RCAR_GP_PIN(6, 2):
+		return 20;
+	case RCAR_GP_PIN(6, 3):
+		return 19;
+	case RCAR_GP_PIN(6, 4):
+		return 18;
+	case RCAR_GP_PIN(6, 5):
+		return 17;
+	case RCAR_GP_PIN(6, 6):
+		return 23;
+	case RCAR_GP_PIN(6, 7):
+		return 16;
+	case RCAR_GP_PIN(6, 8):
+		return 14;
+	case RCAR_GP_PIN(6, 9):
+		return 13;
+	case RCAR_GP_PIN(6, 10):
+		return 12;
+	case RCAR_GP_PIN(6, 11):
+		return 11;
+	case RCAR_GP_PIN(6, 12):
+		return 10;
+	case RCAR_GP_PIN(6, 13):
+		return 9;
+	case RCAR_GP_PIN(6, 14):
+		return 15;
+	case RCAR_GP_PIN(6, 15):
+		return 8;
+	case RCAR_GP_PIN(6, 16):
+		return 31;
+	case RCAR_GP_PIN(6, 17):
+		return 30;
+	case RCAR_GP_PIN(6, 18):
+		return 29;
+	case RCAR_GP_PIN(6, 19):
+		return 28;
+	case RCAR_GP_PIN(6, 20):
+		return 27;
+	case RCAR_GP_PIN(6, 21):
+		return 26;
+	case RCAR_GP_PIN(6, 22):
+		return 25;
+	case RCAR_GP_PIN(6, 23):
+		return 24;
+	}
+
+	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 },

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

* Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
  2016-09-09 15:26     ` Simon Horman
@ 2016-09-09 16:57       ` Geert Uytterhoeven
  2016-09-10  6:14         ` Simon Horman
  0 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2016-09-09 16:57 UTC (permalink / raw)
  To: Simon Horman
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, Linux-Renesas,
	linux-gpio, Wolfram Sang

Hi Simon,

On Fri, Sep 9, 2016 at 5:26 PM, Simon Horman <horms@verge.net.au> wrote:
>> > +       /* GP6_16-23 -> bits 31-24 of pocctrl
>> > +        * GP6_06    -> bit  23    of pocctrl
>> > +        * GP6_00-05 -> bits 22-17 of pocctrl
>> > +        * GP6_07    -> bit  16    of pocctrl
>> > +        * GP6_14    -> bit  15    of pocctrl
>> > +        * GP6_08-13 -> bits 14-09 of pocctrl
>> > +        * GP6_15    -> bit  08    of pocctrl
>> > +        */
>> > +       if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
>> > +               return 31 - 2 - (pin & 0x1f);
>> > +       else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
>> > +               return 31 - 8 - (pin & 0x1f);
>> > +       else if (pin < RCAR_GP_PIN(6, 14))
>> > +               return 31 - 9 - (pin & 0x1f);
>> > +       else
>> > +               return 31 + 16 - (pin & 0x1f);
>>
>> While your code is correct, I think it's easier for the casual reader to use
>> a plain switch () statement, and let the optimizer handle the rest.
>
> Like this? If so I don't particularly mind but it doesn't seem clearer to
> me.
>
> +static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocctrl)
> +{
> +       *pocctrl = 0xe606006c;
> +
> +       switch (pin) {
> +       case RCAR_GP_PIN(6, 0):
> +               return 22;
> +       case RCAR_GP_PIN(6, 1):
> +               return 21;

Right, a full list of cases indeed doesn't look that much better.

Note that you can use "switch (pin & 0x1f)", and have ranges in case
statements:

        switch (pin & 0x1f) {
        case 6: return 23:
        case 7: return 16;
        case 14: return 15;
        case 15: return 8;
        case 0...5:
        case 7...13:
                return 22 - (pin & 0x1f);
        case 16..23:
                return 47 - (pin & 0x1f);
        }

Does that look better?

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

* Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
  2016-09-09 16:57       ` Geert Uytterhoeven
@ 2016-09-10  6:14         ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2016-09-10  6:14 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, Linus Walleij, Magnus Damm, Linux-Renesas,
	linux-gpio, Wolfram Sang

On Fri, Sep 09, 2016 at 06:57:54PM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Fri, Sep 9, 2016 at 5:26 PM, Simon Horman <horms@verge.net.au> wrote:
> >> > +       /* GP6_16-23 -> bits 31-24 of pocctrl
> >> > +        * GP6_06    -> bit  23    of pocctrl
> >> > +        * GP6_00-05 -> bits 22-17 of pocctrl
> >> > +        * GP6_07    -> bit  16    of pocctrl
> >> > +        * GP6_14    -> bit  15    of pocctrl
> >> > +        * GP6_08-13 -> bits 14-09 of pocctrl
> >> > +        * GP6_15    -> bit  08    of pocctrl
> >> > +        */
> >> > +       if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
> >> > +               return 31 - 2 - (pin & 0x1f);
> >> > +       else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
> >> > +               return 31 - 8 - (pin & 0x1f);
> >> > +       else if (pin < RCAR_GP_PIN(6, 14))
> >> > +               return 31 - 9 - (pin & 0x1f);
> >> > +       else
> >> > +               return 31 + 16 - (pin & 0x1f);
> >>
> >> While your code is correct, I think it's easier for the casual reader to use
> >> a plain switch () statement, and let the optimizer handle the rest.
> >
> > Like this? If so I don't particularly mind but it doesn't seem clearer to
> > me.
> >
> > +static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocctrl)
> > +{
> > +       *pocctrl = 0xe606006c;
> > +
> > +       switch (pin) {
> > +       case RCAR_GP_PIN(6, 0):
> > +               return 22;
> > +       case RCAR_GP_PIN(6, 1):
> > +               return 21;
> 
> Right, a full list of cases indeed doesn't look that much better.
> 
> Note that you can use "switch (pin & 0x1f)", and have ranges in case
> statements:
> 
>         switch (pin & 0x1f) {
>         case 6: return 23:
>         case 7: return 16;
>         case 14: return 15;
>         case 15: return 8;
>         case 0...5:
>         case 7...13:
>                 return 22 - (pin & 0x1f);
>         case 16..23:
>                 return 47 - (pin & 0x1f);
>         }
> 
> Does that look better?

Yes, I think that could be a winning combination.

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

* Re: [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI
  2016-09-08 11:36 [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
                   ` (2 preceding siblings ...)
  2016-09-08 11:36 ` [PATCH 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman
@ 2016-09-12 12:52 ` Linus Walleij
  3 siblings, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2016-09-12 12:52 UTC (permalink / raw)
  To: Simon Horman
  Cc: Geert Uytterhoeven, Laurent Pinchart, Magnus Damm, Linux-Renesas,
	linux-gpio, Wolfram Sang

On Thu, Sep 8, 2016 at 1:36 PM, Simon Horman <horms+renesas@verge.net.au> wrote:

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

Acked-by: Linus Walleij <linus.walleij@linaro.org>

I expect these to be merged by Geert who send the patches to me.

Yours,
Linus Walleij

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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 11:36 [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
2016-09-08 11:36 ` [PATCH 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
2016-09-09  7:40   ` Geert Uytterhoeven
2016-09-08 11:36 ` [PATCH 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
2016-09-09  7:52   ` Geert Uytterhoeven
2016-09-09 12:30     ` Wolfram Sang
2016-09-08 11:36 ` [PATCH 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman
2016-09-09  8:08   ` Geert Uytterhoeven
2016-09-09 12:30     ` Wolfram Sang
2016-09-09 15:26     ` Simon Horman
2016-09-09 16:57       ` Geert Uytterhoeven
2016-09-10  6:14         ` Simon Horman
2016-09-12 12:52 ` [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: " Linus Walleij

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.