pinctrl: sh-pfc: gen2: initialize TDSEL register
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
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
@@ -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 *pocreturn 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
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.
Signed-off-by Wolfram Sang <[email protected]>
Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register
In reply to Wolfram SangQuoted 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.
Signed-off-by Wolfram Sang <[email protected]>
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@@ -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 *pocreturn 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
Re: [PATCH 1/2] pinctrl: sh-pfc: r8a7790: initialize TDSEL register
In reply to Wolfram SangQuoted 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.
Signed-off-by Wolfram Sang <[email protected]>
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
PATCH 2/2 pinctrl: sh-pfc: r8a7794: initialize TDSEL register
In reply to Wolfram SangDocumentation 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
@@ -5560,7 +5560,16 @@ static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocreturn -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
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.
Signed-off-by Wolfram Sang <[email protected]>
Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register
In reply to Wolfram SangQuoted 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.
Signed-off-by Wolfram Sang <[email protected]>
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@@ -5560,7 +5560,16 @@ static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocreturn -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
Re: [PATCH 2/2] pinctrl: sh-pfc: r8a7794: initialize TDSEL register
In reply to Wolfram SangQuoted 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.
Signed-off-by Wolfram Sang <[email protected]>
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
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