All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register
@ 2018-10-28 21:24 Wolfram Sang
  2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Wolfram Sang @ 2018-10-28 21:24 UTC (permalink / raw)
  To: linux-gpio; +Cc: linux-renesas-soc, Geert Uytterhoeven, Wolfram Sang

During our SDHI hackathon, we found that Lager was the only Gen2 board
having issues with a stubborn SD card. The issue went away when setting
TDSEL to the expected value mentioned in the H2 documentation which is
sadly not the default value. M2-W, M2-N, and V2H have an expected value
of 0 for TDSEL, so this is why they likely work out of the box (V2H has
non-zero drive strength bit, though). I can't verify those SoCs here, no
boards. E2 has a non-zero expected value as well, so we fix it in this
patch series as well (although on my board the bootloader prepares TDSEL
correctly, but let's not rely on that).

Based on an RFC patch for H2 sent two years ago.


Wolfram Sang (2):
  pinctrl: sh-pfc: r8a7790: initialize TDSEL register
  pinctrl: sh-pfc: r8a7794: initialize TDSEL register

 drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 10 ++++++++++
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c |  9 +++++++++
 2 files changed, 19 insertions(+)

-- 
2.19.0

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

* [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register
  2018-10-28 21:24 [PATCH 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register Wolfram Sang
@ 2018-10-28 21:24 ` Wolfram Sang
  2018-10-30 13:55   ` Simon Horman
                     ` (2 more replies)
  2018-10-28 21:24 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
  2018-11-08 20:00 ` [PATCH 0/2] pinctrl: sh-pfc: gen2: " Geert Uytterhoeven
  2 siblings, 3 replies; 10+ messages in thread
From: Wolfram Sang @ 2018-10-28 21:24 UTC (permalink / raw)
  To: linux-gpio; +Cc: linux-renesas-soc, Geert Uytterhoeven, Wolfram Sang

Documentation says that some bits in TDSEL must be set (ch 5.3.39 in R-Car H2
v0.91). However, the reset value of the register is 0, so software has to do
it. Add this to the kernel driver to ensure this is really done independent of
firmware versions.

This is needed for some SD cards supporting SDR104 transfer mode. For
me, TDSEL was not initialized by the firmware and I had problems with
the card when re-inserting it.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
index ab7a35392cd8..c0e679105df9 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
@@ -11,6 +11,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 
+#include "core.h"
 #include "sh_pfc.h"
 
 /*
@@ -5691,7 +5692,16 @@ static int r8a7790_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
 	return 31 - (pin & 0x1f);
 }
 
+static int r8a7790_pinmux_soc_init(struct sh_pfc *pfc)
+{
+	/* Initialize TDSEL according to datasheet */
+	sh_pfc_write(pfc, 0xe6060088, 0x00155554);
+
+	return 0;
+}
+
 static const struct sh_pfc_soc_operations r8a7790_pinmux_ops = {
+	.init = r8a7790_pinmux_soc_init,
 	.pin_to_pocctrl = r8a7790_pin_to_pocctrl,
 };
 
-- 
2.19.0

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

* [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register
  2018-10-28 21:24 [PATCH 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register Wolfram Sang
  2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
@ 2018-10-28 21:24 ` Wolfram Sang
  2018-10-30 13:55   ` Simon Horman
                     ` (2 more replies)
  2018-11-08 20:00 ` [PATCH 0/2] pinctrl: sh-pfc: gen2: " Geert Uytterhoeven
  2 siblings, 3 replies; 10+ messages in thread
From: Wolfram Sang @ 2018-10-28 21:24 UTC (permalink / raw)
  To: linux-gpio; +Cc: linux-renesas-soc, Geert Uytterhoeven, Wolfram Sang

Documentation says that some bits in TDSEL must be set (ch 5.3.35 in
R-Car E2 v0.5). However, the reset value of the register is 0, so
software has to do it. Add this to the kernel driver to ensure this is
really done independent of firmware versions. This is needed for some SD
cards supporting SDR104 transfer mode.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
index 6d1e5fdc03f8..8a16053d2bec 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
@@ -5560,7 +5560,16 @@ static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
 	return -EINVAL;
 }
 
+static int r8a7794_pinmux_soc_init(struct sh_pfc *pfc)
+{
+	/* Initialize TDSEL according to datasheet */
+	sh_pfc_write(pfc, 0xe6060068, 0x55555500);
+
+	return 0;
+}
+
 static const struct sh_pfc_soc_operations r8a7794_pinmux_ops = {
+	.init = r8a7794_pinmux_soc_init,
 	.pin_to_pocctrl = r8a7794_pin_to_pocctrl,
 };
 
-- 
2.19.0

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

* Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register
  2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
@ 2018-10-30 13:55   ` Simon Horman
  2018-10-31  1:19   ` Marek Vasut
  2018-11-08 19:44   ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Simon Horman @ 2018-10-30 13:55 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-gpio, linux-renesas-soc, Geert Uytterhoeven

On Sun, Oct 28, 2018 at 09:24:56PM +0000, Wolfram Sang wrote:
> Documentation says that some bits in TDSEL must be set (ch 5.3.39 in R-Car H2
> v0.91). However, the reset value of the register is 0, so software has to do
> it. Add this to the kernel driver to ensure this is really done independent of
> firmware versions.
> 
> This is needed for some SD cards supporting SDR104 transfer mode. For
> me, TDSEL was not initialized by the firmware and I had problems with
> the card when re-inserting it.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

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

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

* Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register
  2018-10-28 21:24 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
@ 2018-10-30 13:55   ` Simon Horman
  2018-10-31  1:19   ` Marek Vasut
  2018-11-08 19:46   ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Simon Horman @ 2018-10-30 13:55 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-gpio, linux-renesas-soc, Geert Uytterhoeven

On Sun, Oct 28, 2018 at 09:24:57PM +0000, Wolfram Sang wrote:
> Documentation says that some bits in TDSEL must be set (ch 5.3.35 in
> R-Car E2 v0.5). However, the reset value of the register is 0, so
> software has to do it. Add this to the kernel driver to ensure this is
> really done independent of firmware versions. This is needed for some SD
> cards supporting SDR104 transfer mode.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

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

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

* Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register
  2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
  2018-10-30 13:55   ` Simon Horman
@ 2018-10-31  1:19   ` Marek Vasut
  2018-11-08 19:44   ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Marek Vasut @ 2018-10-31  1:19 UTC (permalink / raw)
  To: Wolfram Sang, linux-gpio; +Cc: linux-renesas-soc, Geert Uytterhoeven

On 10/28/2018 10:24 PM, Wolfram Sang wrote:
> Documentation says that some bits in TDSEL must be set (ch 5.3.39 in R-Car H2
> v0.91). However, the reset value of the register is 0, so software has to do
> it. Add this to the kernel driver to ensure this is really done independent of
> firmware versions.
> 
> This is needed for some SD cards supporting SDR104 transfer mode. For
> me, TDSEL was not initialized by the firmware and I had problems with
> the card when re-inserting it.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Marek Vasut <marek.vasut@gmail.com>

> ---
>  drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
> index ab7a35392cd8..c0e679105df9 100644
> --- a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
> +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
> @@ -11,6 +11,7 @@
>  #include <linux/io.h>
>  #include <linux/kernel.h>
>  
> +#include "core.h"
>  #include "sh_pfc.h"
>  
>  /*
> @@ -5691,7 +5692,16 @@ static int r8a7790_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
>  	return 31 - (pin & 0x1f);
>  }
>  
> +static int r8a7790_pinmux_soc_init(struct sh_pfc *pfc)
> +{
> +	/* Initialize TDSEL according to datasheet */
> +	sh_pfc_write(pfc, 0xe6060088, 0x00155554);
> +
> +	return 0;
> +}
> +
>  static const struct sh_pfc_soc_operations r8a7790_pinmux_ops = {
> +	.init = r8a7790_pinmux_soc_init,
>  	.pin_to_pocctrl = r8a7790_pin_to_pocctrl,
>  };
>  
> 


-- 
Best regards,
Marek Vasut

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

* Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register
  2018-10-28 21:24 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
  2018-10-30 13:55   ` Simon Horman
@ 2018-10-31  1:19   ` Marek Vasut
  2018-11-08 19:46   ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Marek Vasut @ 2018-10-31  1:19 UTC (permalink / raw)
  To: Wolfram Sang, linux-gpio; +Cc: linux-renesas-soc, Geert Uytterhoeven

On 10/28/2018 10:24 PM, Wolfram Sang wrote:
> Documentation says that some bits in TDSEL must be set (ch 5.3.35 in
> R-Car E2 v0.5). However, the reset value of the register is 0, so
> software has to do it. Add this to the kernel driver to ensure this is
> really done independent of firmware versions. This is needed for some SD
> cards supporting SDR104 transfer mode.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Marek Vasut <marek.vasut@gmail.com>

> ---
>  drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> index 6d1e5fdc03f8..8a16053d2bec 100644
> --- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
> @@ -5560,7 +5560,16 @@ static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
>  	return -EINVAL;
>  }
>  
> +static int r8a7794_pinmux_soc_init(struct sh_pfc *pfc)
> +{
> +	/* Initialize TDSEL according to datasheet */
> +	sh_pfc_write(pfc, 0xe6060068, 0x55555500);
> +
> +	return 0;
> +}
> +
>  static const struct sh_pfc_soc_operations r8a7794_pinmux_ops = {
> +	.init = r8a7794_pinmux_soc_init,
>  	.pin_to_pocctrl = r8a7794_pin_to_pocctrl,
>  };
>  
> 


-- 
Best regards,
Marek Vasut

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

* Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register
  2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
  2018-10-30 13:55   ` Simon Horman
  2018-10-31  1:19   ` Marek Vasut
@ 2018-11-08 19:44   ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2018-11-08 19:44 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:GPIO SUBSYSTEM, Linux-Renesas

On Sun, Oct 28, 2018 at 10:25 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Documentation says that some bits in TDSEL must be set (ch 5.3.39 in R-Car H2
> v0.91). However, the reset value of the register is 0, so software has to do
> it. Add this to the kernel driver to ensure this is really done independent of
> firmware versions.
>
> This is needed for some SD cards supporting SDR104 transfer mode. For
> me, TDSEL was not initialized by the firmware and I had problems with
> the card when re-inserting it.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

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

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

* Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register
  2018-10-28 21:24 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
  2018-10-30 13:55   ` Simon Horman
  2018-10-31  1:19   ` Marek Vasut
@ 2018-11-08 19:46   ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2018-11-08 19:46 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:GPIO SUBSYSTEM, Linux-Renesas

On Sun, Oct 28, 2018 at 10:25 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Documentation says that some bits in TDSEL must be set (ch 5.3.35 in
> R-Car E2 v0.5). However, the reset value of the register is 0, so
> software has to do it. Add this to the kernel driver to ensure this is
> really done independent of firmware versions. This is needed for some SD
> cards supporting SDR104 transfer mode.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

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

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

* Re: [PATCH 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register
  2018-10-28 21:24 [PATCH 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register Wolfram Sang
  2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
  2018-10-28 21:24 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
@ 2018-11-08 20:00 ` Geert Uytterhoeven
  2 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2018-11-08 20:00 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:GPIO SUBSYSTEM, Linux-Renesas, Chris Paterson

Hi Wolfram,

CC Chris Paterson

On Sun, Oct 28, 2018 at 10:25 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> During our SDHI hackathon, we found that Lager was the only Gen2 board
> having issues with a stubborn SD card. The issue went away when setting
> TDSEL to the expected value mentioned in the H2 documentation which is
> sadly not the default value. M2-W, M2-N, and V2H have an expected value
> of 0 for TDSEL, so this is why they likely work out of the box (V2H has
> non-zero drive strength bit, though). I can't verify those SoCs here, no

But the default non-zero drive strength bit does match the required value
on V2H.

> boards. E2 has a non-zero expected value as well, so we fix it in this
> patch series as well (although on my board the bootloader prepares TDSEL
> correctly, but let's not rely on that).

Probably we should program TDSEL regardless, to avoid any dependency on
reset state or boot loader.

Note that all RZ/G1 SoCs requires zero TDSEL values, except for RZ/G1C
(which doesn't document required values, just the initial values).
So we need some soc_device_match() handling to obtain the required value.

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

end of thread, other threads:[~2018-11-09  5:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-28 21:24 [PATCH 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register Wolfram Sang
2018-10-28 21:24 ` [PATCH 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
2018-10-30 13:55   ` Simon Horman
2018-10-31  1:19   ` Marek Vasut
2018-11-08 19:44   ` Geert Uytterhoeven
2018-10-28 21:24 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
2018-10-30 13:55   ` Simon Horman
2018-10-31  1:19   ` Marek Vasut
2018-11-08 19:46   ` Geert Uytterhoeven
2018-11-08 20:00 ` [PATCH 0/2] pinctrl: sh-pfc: gen2: " Geert Uytterhoeven

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.