Skip to contentSkip to conversation

pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0

PATCH In review Wolfram Sang 4 participants 8 messages Jan 7, 2019 – Jan 9, 2019 Pin control

lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0

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(+)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/2 pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0

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.

---
 drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/pinctrl/sh-pfc/pfc-r8a7790.c +17 -0
index ab7a35392cd8..a84229cb8cd4 100644
@@ -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,
 };
 
Signature · 1 line
2.11.0
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0

Quoted 11 lines · 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.

Reviewed-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register for ES1.0

In reply to Wolfram Sang
Quoted 2 lines · 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

Also in Hardware User Manual Rev.1.00.
\

Quoted 9 lines

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.

i.e. will queue in sh-pfc-for-v5.1.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#4 lore raw

PATCH v2 2/2 pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0

In reply to 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.

---
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/pinctrl/sh-pfc/pfc-r8a7794.c +16 -0
index fcf1339c4058..958a5f714c93 100644
@@ -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,
 };
 
Signature · 1 line
2.11.0
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0

Quoted 7 lines · 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.

Reviewed-by on v2 2/2
#6 lore raw

Re: [PATCH v2 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register for ES1.0

In reply to Wolfram Sang
Quoted 2 lines · 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,

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

Quoted 7 lines

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.

i.e. will queue in sh-pfc-for-v5.1.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#7 lore raw
In reply to Wolfram Sang

Hello Wolfram,

Thank you for the heads up.

Quoted 15 lines

From: Wolfram Sang <[email protected]>
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:

Quoted 7 lines

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

Quoted 3 lines

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

Quoted 18 lines

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