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

Message ID 20190107221320.14930-2-wsa+renesas@sang-engineering.com
State New
Headers show
Series
  • pinctrl: sh-pfc: gen2: initialize TDSEL register for ES1.0
Related show

Commit Message

Wolfram Sang Jan. 7, 2019, 10:13 p.m.
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(+)

Comments

Simon Horman Jan. 8, 2019, 3:07 p.m. | #1
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>
Geert Uytterhoeven Jan. 9, 2019, 8:34 a.m. | #2
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

Patch

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,
 };