Skip to contentSkip to conversation

pinctrl: sh-pfc: gen2: initialize TDSEL register

PATCH Superseded Wolfram Sang 4 participants 10 messages Oct 29, 2018 – Nov 9, 2018 Pin control

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover pinctrl: sh-pfc: gen2: initialize TDSEL register

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

PATCH 1/2 pinctrl: sh-pfc: r8a7790: initialize TDSEL register

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.

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

Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register

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

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

Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register

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

Quoted 34 lines
---
 drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/pinctrl/sh-pfc/pfc-r8a7790.c +10 -0
index ab7a35392cd8..c0e679105df9 100644
@@ -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,
 };
 
Signature · 2 lines
Best regards,
Marek Vasut
Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register

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

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
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
#5 lore raw

PATCH 2/2 pinctrl: sh-pfc: r8a7794: initialize TDSEL register

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

---
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/pinctrl/sh-pfc/pfc-r8a7794.c +9 -0
index 6d1e5fdc03f8..8a16053d2bec 100644
@@ -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,
 };
 
Signature · 1 line
2.19.0
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register

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

Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register

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

Quoted 26 lines
---
 drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/pinctrl/sh-pfc/pfc-r8a7794.c +9 -0
index 6d1e5fdc03f8..8a16053d2bec 100644
@@ -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,
 };
 
Signature · 2 lines
Best regards,
Marek Vasut
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register

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

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
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
#9 lore raw
In reply to Wolfram Sang

Hi Wolfram,

CC Chris Paterson

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

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

Quoted 3 lines

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

Signature · 5 lines
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