Linux-Renesas-SoC Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0
@ 2019-01-07 22:13 Wolfram Sang
  2019-01-07 22:13 ` [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Wolfram Sang @ 2019-01-07 22:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-renesas-soc, Geert Uytterhoeven, Chris Paterson, 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).

Changes since V1:

* we discussed this with the HW team internally and concluded this is only
  needed for ES1.0 versions of these SoCs. So, setting TDSEL is now
  whitelisted using soc_device_match.

* Chris added to CC
  For two reasons: first, to give him a chance to test this so we don't
  break the RZ series. Second, according to Geert, R-Car E2X and RZ/G1C
  might have the same 'non-zero default value of TDSEL' problem and maybe
  need fixing, too. But we don't have HW to check/test this.

Looking forward to comments!

Thanks,

   Wolfram


Wolfram Sang (2):
  pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0
  pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0

 drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 17 +++++++++++++++++
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 16 ++++++++++++++++
 2 files changed, 33 insertions(+)

-- 
2.11.0


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

* [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0
  2019-01-07 22:13 [PATCH v2 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0 Wolfram Sang
@ 2019-01-07 22:13 ` " Wolfram Sang
  2019-01-08 15:07   ` Simon Horman
  2019-01-09  8:34   ` Geert Uytterhoeven
  2019-01-07 22:13 ` [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
  2019-01-08 11:18 ` [PATCH v2 0/2] pinctrl: sh-pfc: gen2: " Chris Paterson
  2 siblings, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2019-01-07 22:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-renesas-soc, Geert Uytterhoeven, Chris Paterson, Wolfram Sang

Documentation for ES1.0 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 and use
whitelisting for ES versions known to need this.

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 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
index ab7a35392cd8..a84229cb8cd4 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
@@ -10,7 +10,9 @@
 
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/sys_soc.h>
 
+#include "core.h"
 #include "sh_pfc.h"
 
 /*
@@ -5691,7 +5693,22 @@ static int r8a7790_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
 	return 31 - (pin & 0x1f);
 }
 
+static const struct soc_device_attribute r8a7790_tdsel[] = {
+	{ .soc_id = "r8a7790", .revision = "ES1.0" },
+	{ /* sentinel */ }
+};
+
+static int r8a7790_pinmux_soc_init(struct sh_pfc *pfc)
+{
+	/* Initialize TDSEL on old revisions */
+	if (soc_device_match(r8a7790_tdsel))
+		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.11.0


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

* [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0
  2019-01-07 22:13 [PATCH v2 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0 Wolfram Sang
  2019-01-07 22:13 ` [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
@ 2019-01-07 22:13 ` " Wolfram Sang
  2019-01-08 15:07   ` Simon Horman
  2019-01-09  8:35   ` Geert Uytterhoeven
  2019-01-08 11:18 ` [PATCH v2 0/2] pinctrl: sh-pfc: gen2: " Chris Paterson
  2 siblings, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2019-01-07 22:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-renesas-soc, Geert Uytterhoeven, Chris Paterson, Wolfram Sang

Documentation for ES1.0 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 and use whitelisting for
ES versions known to need this.

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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
index fcf1339c4058..958a5f714c93 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/sys_soc.h>
 
 #include "core.h"
 #include "sh_pfc.h"
@@ -5560,7 +5561,22 @@ static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
 	return -EINVAL;
 }
 
+static const struct soc_device_attribute r8a7794_tdsel[] = {
+	{ .soc_id = "r8a7794", .revision = "ES1.0" },
+	{ /* sentinel */ }
+};
+
+static int r8a7794_pinmux_soc_init(struct sh_pfc *pfc)
+{
+	/* Initialize TDSEL on old revisions */
+	if (soc_device_match(r8a7794_tdsel))
+		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.11.0


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

* RE: [PATCH v2 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0
  2019-01-07 22:13 [PATCH v2 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0 Wolfram Sang
  2019-01-07 22:13 ` [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
  2019-01-07 22:13 ` [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
@ 2019-01-08 11:18 ` " Chris Paterson
  2 siblings, 0 replies; 8+ messages in thread
From: Chris Paterson @ 2019-01-08 11:18 UTC (permalink / raw)
  To: Wolfram Sang, linux-gpio; +Cc: linux-renesas-soc, Geert Uytterhoeven

Hello Wolfram,

Thank you for the heads up.

> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Sent: 07 January 2019 22:13
> 
> 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).
> 
> Changes since V1:
> 
> * we discussed this with the HW team internally and concluded this is only
>   needed for ES1.0 versions of these SoCs. So, setting TDSEL is now
>   whitelisted using soc_device_match.
> 
> * Chris added to CC
>   For two reasons: first, to give him a chance to test this so we don't
>   break the RZ series.

Neither RZ/G1[HE] devices are based on ES1.0 so these patches shouldn't have an effect.
According to the RZ/G1 H/W manuals, all RZ/G1[HMNE] devices are expecting 0 for TDSEL.

> Second, according to Geert, R-Car E2X and RZ/G1C
>   might have the same 'non-zero default value of TDSEL' problem and maybe
>   need fixing, too. But we don't have HW to check/test this.

Geert is correct. We'll have to look into it.

Kind regards, Chris

> 
> Looking forward to comments!
> 
> Thanks,
> 
>    Wolfram
> 
> 
> Wolfram Sang (2):
>   pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0
>   pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0
> 
>  drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 17 +++++++++++++++++
>  drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 16 ++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> --
> 2.11.0


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

* Re: [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0
  2019-01-07 22:13 ` [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
@ 2019-01-08 15:07   ` Simon Horman
  2019-01-09  8:34   ` Geert Uytterhoeven
  1 sibling, 0 replies; 8+ messages in thread
From: Simon Horman @ 2019-01-08 15:07 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-gpio, linux-renesas-soc, Geert Uytterhoeven, Chris Paterson

On Mon, Jan 07, 2019 at 11:13:19PM +0100, Wolfram Sang wrote:
> Documentation for ES1.0 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 and use
> whitelisting for ES versions known to need this.
> 
> 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] 8+ messages in thread

* Re: [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0
  2019-01-07 22:13 ` [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
@ 2019-01-08 15:07   ` Simon Horman
  2019-01-09  8:35   ` Geert Uytterhoeven
  1 sibling, 0 replies; 8+ messages in thread
From: Simon Horman @ 2019-01-08 15:07 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-gpio, linux-renesas-soc, Geert Uytterhoeven, Chris Paterson

On Mon, Jan 07, 2019 at 11:13:20PM +0100, Wolfram Sang wrote:
> Documentation for ES1.0 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 and use whitelisting for
> ES versions known to need this.
> 
> This is needed for some SD cards supporting SDR104 transfer mode.

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


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

* Re: [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0
  2019-01-07 22:13 ` [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
  2019-01-08 15:07   ` Simon Horman
@ 2019-01-09  8:34   ` Geert Uytterhoeven
  1 sibling, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2019-01-09  8:34 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:GPIO SUBSYSTEM, Linux-Renesas, Chris Paterson

On Mon, Jan 7, 2019 at 11:13 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Documentation for ES1.0 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

Also in Hardware User Manual Rev.1.00.
\
> 0, so software has to do it. Add this to the kernel driver to ensure
> this is really done independent of firmware versions and use
> whitelisting for ES versions known to need this.
>
> 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>
i.e. will queue in sh-pfc-for-v5.1.

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

* Re: [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0
  2019-01-07 22:13 ` [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
  2019-01-08 15:07   ` Simon Horman
@ 2019-01-09  8:35   ` Geert Uytterhoeven
  1 sibling, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2019-01-09  8:35 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:GPIO SUBSYSTEM, Linux-Renesas, Chris Paterson

On Mon, Jan 7, 2019 at 11:13 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Documentation for ES1.0 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,

Hardware User Manual Rev.1.10 says the values must be 00, so I assume
that manual applies to later ES versions.

> so software has to do it. Add this to the kernel driver to ensure this
> is really done independent of firmware versions and use whitelisting for
> ES versions known to need this.
>
> 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>
i.e. will queue in sh-pfc-for-v5.1.

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

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 22:13 [PATCH v2 0/2] pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0 Wolfram Sang
2019-01-07 22:13 ` [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: " Wolfram Sang
2019-01-08 15:07   ` Simon Horman
2019-01-09  8:34   ` Geert Uytterhoeven
2019-01-07 22:13 ` [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: " Wolfram Sang
2019-01-08 15:07   ` Simon Horman
2019-01-09  8:35   ` Geert Uytterhoeven
2019-01-08 11:18 ` [PATCH v2 0/2] pinctrl: sh-pfc: gen2: " Chris Paterson

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox