Skip to contentSkip to conversation

pinctrl: sh-pfc: r8a7791: add R8A7743 support

PATCH Superseded Sergei Shtylyov 2 participants 3 messages Apr 1, 2017 – Apr 6, 2017

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: sh-pfc: r8a7791: add R8A7743 support

Renesas RZ/G1M (R8A7743) is pin compatible with R-Car M2-W/N (R8A7791/3), however it doesn't have several automotive specific peripherals. Along with adding 'struct sh_pfc_soc_info' for R8A7743, annotate all items that only exist on the R-Car SoCs.

---
This patch is against the 'devel' branch of Linus Walleij's 'linux-pinctrl.git' repo plus 4 R8A7791 fixes and the "grand I2C rename" patch...

 drivers/pinctrl/sh-pfc/Kconfig       |    5 
 drivers/pinctrl/sh-pfc/Makefile      |    1 
 drivers/pinctrl/sh-pfc/core.c        |    6 
 drivers/pinctrl/sh-pfc/pfc-r8a7791.c | 1057 +++++++++++++++++++----------------
 drivers/pinctrl/sh-pfc/sh_pfc.h      |    1 
 5 files changed, 597 insertions(+), 473 deletions(-)
drivers/pinctrl/sh-pfc/Kconfig +5 -0
Index: linux-pinctrl/drivers/pinctrl/sh-pfc/Kconfig
===================================================================
@@ -34,6 +34,11 @@ config PINCTRL_PFC_R8A7740
 	depends on ARCH_R8A7740
 	select PINCTRL_SH_PFC_GPIO
 
+config PINCTRL_PFC_R8A7743
+	def_bool y
+	depends on ARCH_R8A7743
+	select PINCTRL_SH_PFC
+
 config PINCTRL_PFC_R8A7778
 	def_bool y
 	depends on ARCH_R8A7778
drivers/pinctrl/sh-pfc/Makefile +1 -0
Index: linux-pinctrl/drivers/pinctrl/sh-pfc/Makefile
===================================================================
@@ -3,6 +3,7 @@ obj-$(CONFIG_PINCTRL_SH_PFC_GPIO)	+= gpi
 obj-$(CONFIG_PINCTRL_PFC_EMEV2)	+= pfc-emev2.o
 obj-$(CONFIG_PINCTRL_PFC_R8A73A4)	+= pfc-r8a73a4.o
 obj-$(CONFIG_PINCTRL_PFC_R8A7740)	+= pfc-r8a7740.o
+obj-$(CONFIG_PINCTRL_PFC_R8A7743)	+= pfc-r8a7791.o
 obj-$(CONFIG_PINCTRL_PFC_R8A7778)	+= pfc-r8a7778.o
 obj-$(CONFIG_PINCTRL_PFC_R8A7779)	+= pfc-r8a7779.o
 obj-$(CONFIG_PINCTRL_PFC_R8A7790)	+= pfc-r8a7790.o
drivers/pinctrl/sh-pfc/core.c +6 -0
Index: linux-pinctrl/drivers/pinctrl/sh-pfc/core.c
===================================================================
@@ -485,6 +485,12 @@ static const struct of_device_id sh_pfc_
 		.data = &r8a7740_pinmux_info,
 	},
 #endif
+#ifdef CONFIG_PINCTRL_PFC_R8A7743
+	{
+		.compatible = "renesas,pfc-r8a7743",
+		.data = &r8a7743_pinmux_info,
+	},
+#endif
 #ifdef CONFIG_PINCTRL_PFC_R8A7778
 	{
 		.compatible = "renesas,pfc-r8a7778",
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +584 -473

1,846 lines not on this page · raw message

drivers/pinctrl/sh-pfc/sh_pfc.h +1 -0
Index: linux-pinctrl/drivers/pinctrl/sh-pfc/sh_pfc.h
===================================================================
@@ -259,6 +259,7 @@ struct sh_pfc_soc_info {
 extern const struct sh_pfc_soc_info emev2_pinmux_info;
 extern const struct sh_pfc_soc_info r8a73a4_pinmux_info;
 extern const struct sh_pfc_soc_info r8a7740_pinmux_info;
+extern const struct sh_pfc_soc_info r8a7743_pinmux_info;
 extern const struct sh_pfc_soc_info r8a7778_pinmux_info;
 extern const struct sh_pfc_soc_info r8a7779_pinmux_info;
 extern const struct sh_pfc_soc_info r8a7790_pinmux_info;
#1 lore raw

Hi Sergei,

Quoted 6 lines · Sergei Shtylyov

Renesas RZ/G1M (R8A7743) is pin compatible with R-Car M2-W/N (R8A7791/3), however it doesn't have several automotive specific peripherals. Along with adding 'struct sh_pfc_soc_info' for R8A7743, annotate all items that only exist on the R-Car SoCs.

Thanks for your (big) patch!

Quoted 18 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +2 -3
@@ -1,8 +1,8 @@
 /*
- * r8a7791 processor support - PFC hardware block.
+ * r8a7791/r8a7743 processor support - PFC hardware block.
  *
  * Copyright (C) 2013 Renesas Electronics Corporation
- * Copyright (C) 2014-2015 Cogent Embedded, Inc.
+ * Copyright (C) 2014-2017 Cogent Embedded, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2
@@ -129,11 +129,12 @@ enum {
        FN_A9, FN_MSIOF1_SS2, FN_I2C0_SDA,
        FN_A10, FN_MSIOF1_TXD, FN_MSIOF1_TXD_D,
        FN_A11, FN_MSIOF1_RXD, FN_I2C3_SCL_D, FN_MSIOF1_RXD_D,
-       FN_A12, FN_FMCLK, FN_I2C3_SDA_D, FN_MSIOF1_SCK_D,

drivers/pinctrl/sh-pfc/pfc-r8a7791.c enum { · line 137

Quoted 10 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +6 -4
-       FN_A13, FN_ATAG0_N_C, FN_BPFCLK, FN_MSIOF1_SS1_D,
-       FN_A14, FN_ATADIR0_N_C, FN_FMIN, FN_FMIN_C, FN_MSIOF1_SYNC_D,
-       FN_A15, FN_BPFCLK_C,
-       FN_A16, FN_DREQ2_B, FN_FMCLK_C, FN_SCIFA1_SCK_B,
+       FN_A12, FN_FMCLK /* R8A779x only */, FN_I2C3_SDA_D, FN_MSIOF1_SCK_D,
+       FN_A13, FN_ATAG0_N_C, FN_BPFCLK /* R8A779x only */, FN_MSIOF1_SS1_D,
+       FN_A14, FN_ATADIR0_N_C, FN_FMIN /* R8A779x only */,
+       FN_FMIN_C /* R8A779x only */, FN_MSIOF1_SYNC_D,
+       FN_A15, FN_BPFCLK_C /* R8A779x only */,
+       FN_A16, FN_DREQ2_B, FN_FMCLK_C /* R8A779x only */, FN_SCIFA1_SCK_B,

I don't know if it's worth annotating all bits...

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_pin pinmux_pi · line 1795

Quoted 9 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
@@ -1702,7 +1789,7 @@ static const struct sh_pfc_pin pinmux_pi
        PINMUX_GPIO_GP_ALL(),
 };
 
-/* - ADI -------------------------------------------------------------------- */
+/* - ADI (R8A779x only) ----------------------------------------------------- */
 static const unsigned int adi_common_pins[] = {
        /* ADIDATA, ADICS/SAMP, ADICLK */
        RCAR_GP_PIN(6, 24), RCAR_GP_PIN(6, 25), RCAR_GP_PIN(6, 26),

... and pins (and groups and register bit fields), as they're used only indirectly.

Quoted 24 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +8 -8
@@ -4420,14 +4507,14 @@ static const unsigned int vin2_clk_mux[]
 };
 
 static const struct sh_pfc_pin_group pinmux_groups[] = {
-       SH_PFC_PIN_GROUP(adi_common),
-       SH_PFC_PIN_GROUP(adi_chsel0),
-       SH_PFC_PIN_GROUP(adi_chsel1),
-       SH_PFC_PIN_GROUP(adi_chsel2),
-       SH_PFC_PIN_GROUP(adi_common_b),
-       SH_PFC_PIN_GROUP(adi_chsel0_b),
-       SH_PFC_PIN_GROUP(adi_chsel1_b),
-       SH_PFC_PIN_GROUP(adi_chsel2_b),
+       SH_PFC_PIN_GROUP(adi_common),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel0),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel1),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel2),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_common_b), /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel0_b), /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel1_b), /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel2_b), /* R8A779x only */
        SH_PFC_PIN_GROUP(audio_clk_a),
        SH_PFC_PIN_GROUP(audio_clk_b),
        SH_PFC_PIN_GROUP(audio_clk_b_b),

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_pin_group pin · line 4614

Quoted 5 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
@@ -4524,7 +4611,7 @@ static const struct sh_pfc_pin_group pin
        SH_PFC_PIN_GROUP(intc_irq1),
        SH_PFC_PIN_GROUP(intc_irq2),
        SH_PFC_PIN_GROUP(intc_irq3),
-       SH_PFC_PIN_GROUP(mlb_3pin),
+       SH_PFC_PIN_GROUP(mlb_3pin),     /* R8A7794 only */

R8A779x ;-)

Quoted 14 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
        SH_PFC_PIN_GROUP(mmc_data1),
        SH_PFC_PIN_GROUP(mmc_data4),
        SH_PFC_PIN_GROUP(mmc_data8),
@@ -5288,7 +5377,7 @@ static const char * const vin2_groups[]
 };
 
 static const struct sh_pfc_function pinmux_functions[] = {
-       SH_PFC_FUNCTION(adi),
+       SH_PFC_FUNCTION(adi),           /* R8A779x only */
        SH_PFC_FUNCTION(audio_clk),
        SH_PFC_FUNCTION(avb),
        SH_PFC_FUNCTION(can0),

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_function pinm · line 5403

Quoted 8 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
@@ -5308,7 +5397,7 @@ static const struct sh_pfc_function pinm
        SH_PFC_FUNCTION(iic0),
        SH_PFC_FUNCTION(iic1),
        SH_PFC_FUNCTION(intc),
-       SH_PFC_FUNCTION(mlb),
+       SH_PFC_FUNCTION(mlb),           /* R8A779x only */
        SH_PFC_FUNCTION(mmc),
        SH_PFC_FUNCTION(msiof0),
        SH_PFC_FUNCTION(msiof1),

For pinmux_groups[] and pinmux_functions[] I agree they should be annotated.

However, you could achieve the same by using separate arrays for r8a7791 and r8a7743, with the added benefits that users cannot select nonexisting groups and functions, and that only existing groups and functions are exposed through debugfs (/sys/kernel/debug/pinctrl/e6060000.pfc/pin{conf-groups,groups,mux-functions}).

Alternatively, you could share the arrays by putting the common entries first, and the r8a7791/3-only entries last, and restricting r8a7743 to the common subsets by filling in a lower values in r8a7743_pinmux_info.nr_groups resp. r8a7743_pinmux_info.nr_functions.
Currently groups and functions do not have to be sorted, so this should work. I'm not aware of a safe and simple way of filling in .nr_groups resp. .nr_functions, and make sure everything stays in sync, except perhaps by creating a struct:

        static const struct {
                struct sh_pfc_function common[<n>];
                struct sh_pfc_function r8a7791[];
        } pinmux_functions;

and manually updating <n> when changing the initializers? Then at least the compiler will complain when adding (not when removing) entries.

Both alternatives allow to add #ifdefs to the pinmux_groups[] and pinmux_functions[] arrays (and __maybe_unused to referred arrays) to reduce kernel size when not enabling support for all SoCs.

Quoted 19 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +15 -0
@@ -6527,6 +6616,28 @@ static const struct sh_pfc_soc_operation
        .pin_to_pocctrl = r8a7791_pin_to_pocctrl,
 };
 
+#ifdef CONFIG_PINCTRL_PFC_R8A7743
+const struct sh_pfc_soc_info r8a7743_pinmux_info = {
+       .name = "r8a77430_pfc",
+       .ops = &r8a7791_pinmux_ops,
+       .unlock_reg = 0xe6060000, /* PMMR */
+
+       .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
+
+       .pins = pinmux_pins,
+       .nr_pins = ARRAY_SIZE(pinmux_pins),
+       .groups = pinmux_groups,
+       .nr_groups = ARRAY_SIZE(pinmux_groups),
+       .functions = pinmux_functions,
+       .nr_functions = ARRAY_SIZE(pinmux_functions),
+

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_soc_operation · line 6643

Quoted 10 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +7 -0
+       .cfg_regs = pinmux_config_regs,
+
+       .pinmux_data = pinmux_data,
+       .pinmux_data_size = ARRAY_SIZE(pinmux_data),
+};
+#endif
+
 #ifdef CONFIG_PINCTRL_PFC_R8A7791
 const struct sh_pfc_soc_info r8a7791_pinmux_info = {
        .name = "r8a77910_pfc",

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

#2 lore raw

Hello!

Quoted 8 lines · Geert Uytterhoeven
Quoted 6 lines

Renesas RZ/G1M (R8A7743) is pin compatible with R-Car M2-W/N (R8A7791/3), however it doesn't have several automotive specific peripherals. Along with adding 'struct sh_pfc_soc_info' for R8A7743, annotate all items that only exist on the R-Car SoCs.

Thanks for your (big) patch!

My pleasure. :-)

Quoted 35 lines
Quoted 18 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +2 -3
@@ -1,8 +1,8 @@
 /*
- * r8a7791 processor support - PFC hardware block.
+ * r8a7791/r8a7743 processor support - PFC hardware block.
  *
  * Copyright (C) 2013 Renesas Electronics Corporation
- * Copyright (C) 2014-2015 Cogent Embedded, Inc.
+ * Copyright (C) 2014-2017 Cogent Embedded, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2
@@ -129,11 +129,12 @@ enum {
        FN_A9, FN_MSIOF1_SS2, FN_I2C0_SDA,
        FN_A10, FN_MSIOF1_TXD, FN_MSIOF1_TXD_D,
        FN_A11, FN_MSIOF1_RXD, FN_I2C3_SCL_D, FN_MSIOF1_RXD_D,
-       FN_A12, FN_FMCLK, FN_I2C3_SDA_D, FN_MSIOF1_SCK_D,

drivers/pinctrl/sh-pfc/pfc-r8a7791.c enum { · line 137

Quoted 10 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +6 -4
-       FN_A13, FN_ATAG0_N_C, FN_BPFCLK, FN_MSIOF1_SS1_D,
-       FN_A14, FN_ATADIR0_N_C, FN_FMIN, FN_FMIN_C, FN_MSIOF1_SYNC_D,
-       FN_A15, FN_BPFCLK_C,
-       FN_A16, FN_DREQ2_B, FN_FMCLK_C, FN_SCIFA1_SCK_B,
+       FN_A12, FN_FMCLK /* R8A779x only */, FN_I2C3_SDA_D, FN_MSIOF1_SCK_D,
+       FN_A13, FN_ATAG0_N_C, FN_BPFCLK /* R8A779x only */, FN_MSIOF1_SS1_D,
+       FN_A14, FN_ATADIR0_N_C, FN_FMIN /* R8A779x only */,
+       FN_FMIN_C /* R8A779x only */, FN_MSIOF1_SYNC_D,
+       FN_A15, FN_BPFCLK_C /* R8A779x only */,
+       FN_A16, FN_DREQ2_B, FN_FMCLK_C /* R8A779x only */, FN_SCIFA1_SCK_B,

I don't know if it's worth annotating all bits...

Quoted 4 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +0 -0
@@ -1702,7 +1789,7 @@ static const struct sh_pfc_pin pinmux_pi
        PINMUX_GPIO_GP_ALL(),
 };
 
Quoted 8 lines

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_pin pinmux_pi · line 1795

Quoted 5 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
-/* - ADI -------------------------------------------------------------------- */
+/* - ADI (R8A779x only) ----------------------------------------------------- */
 static const unsigned int adi_common_pins[] = {
        /* ADIDATA, ADICS/SAMP, ADICLK */
        RCAR_GP_PIN(6, 24), RCAR_GP_PIN(6, 25), RCAR_GP_PIN(6, 26),

... and pins (and groups and register bit fields), as they're used only indirectly.

As I've said already (on IRC?), I was aiming at a self-documented driver.

Quoted 23 lines
Quoted 23 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +8 -8
@@ -4420,14 +4507,14 @@ static const unsigned int vin2_clk_mux[]
 };
 
 static const struct sh_pfc_pin_group pinmux_groups[] = {
-       SH_PFC_PIN_GROUP(adi_common),
-       SH_PFC_PIN_GROUP(adi_chsel0),
-       SH_PFC_PIN_GROUP(adi_chsel1),
-       SH_PFC_PIN_GROUP(adi_chsel2),
-       SH_PFC_PIN_GROUP(adi_common_b),
-       SH_PFC_PIN_GROUP(adi_chsel0_b),
-       SH_PFC_PIN_GROUP(adi_chsel1_b),
-       SH_PFC_PIN_GROUP(adi_chsel2_b),
+       SH_PFC_PIN_GROUP(adi_common),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel0),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel1),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel2),   /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_common_b), /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel0_b), /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel1_b), /* R8A779x only */
+       SH_PFC_PIN_GROUP(adi_chsel2_b), /* R8A779x only */
        SH_PFC_PIN_GROUP(audio_clk_a),
        SH_PFC_PIN_GROUP(audio_clk_b),
        SH_PFC_PIN_GROUP(audio_clk_b_b),
Quoted 8 lines

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_pin_group pin · line 4614

Quoted 6 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
@@ -4524,7 +4611,7 @@ static const struct sh_pfc_pin_group pin
        SH_PFC_PIN_GROUP(intc_irq1),
        SH_PFC_PIN_GROUP(intc_irq2),
        SH_PFC_PIN_GROUP(intc_irq3),
-       SH_PFC_PIN_GROUP(mlb_3pin),
+       SH_PFC_PIN_GROUP(mlb_3pin),     /* R8A7794 only */

R8A779x ;-)

Oops, so this one did slip thru... :-(

Quoted 25 lines
Quoted 14 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
        SH_PFC_PIN_GROUP(mmc_data1),
        SH_PFC_PIN_GROUP(mmc_data4),
        SH_PFC_PIN_GROUP(mmc_data8),
@@ -5288,7 +5377,7 @@ static const char * const vin2_groups[]
 };
 
 static const struct sh_pfc_function pinmux_functions[] = {
-       SH_PFC_FUNCTION(adi),
+       SH_PFC_FUNCTION(adi),           /* R8A779x only */
        SH_PFC_FUNCTION(audio_clk),
        SH_PFC_FUNCTION(avb),
        SH_PFC_FUNCTION(can0),

drivers/pinctrl/sh-pfc/pfc-r8a7791.c static const struct sh_pfc_function pinm · line 5403

Quoted 8 lines
drivers/pinctrl/sh-pfc/pfc-r8a7791.c +1 -1
@@ -5308,7 +5397,7 @@ static const struct sh_pfc_function pinm
        SH_PFC_FUNCTION(iic0),
        SH_PFC_FUNCTION(iic1),
        SH_PFC_FUNCTION(intc),
-       SH_PFC_FUNCTION(mlb),
+       SH_PFC_FUNCTION(mlb),           /* R8A779x only */
        SH_PFC_FUNCTION(mmc),
        SH_PFC_FUNCTION(msiof0),
        SH_PFC_FUNCTION(msiof1),

For pinmux_groups[] and pinmux_functions[] I agree they should be annotated.

Quoted 5 lines

However, you could achieve the same by using separate arrays for r8a7791 and r8a7743, with the added benefits that users cannot select nonexisting groups and functions, and that only existing groups and functions are exposed through debugfs (/sys/kernel/debug/pinctrl/e6060000.pfc/pin{conf-groups,groups,mux-functions}).

I didn't know about debugfs...

Quoted 14 lines

Alternatively, you could share the arrays by putting the common entries first, and the r8a7791/3-only entries last, and restricting r8a7743 to the common subsets by filling in a lower values in r8a7743_pinmux_info.nr_groups resp. r8a7743_pinmux_info.nr_functions.
Currently groups and functions do not have to be sorted, so this should work. I'm not aware of a safe and simple way of filling in .nr_groups resp. .nr_functions, and make sure everything stays in sync, except perhaps by creating a struct:

        static const struct {
                struct sh_pfc_function common[<n>];
                struct sh_pfc_function r8a7791[];
        } pinmux_functions;
Quoted 7 lines

and manually updating <n> when changing the initializers? Then at least the compiler will complain when adding (not when removing) entries.

Both alternatives allow to add #ifdefs to the pinmux_groups[] and pinmux_functions[] arrays (and __maybe_unused to referred arrays) to reduce kernel size when not enabling support for all SoCs.

I'll give that a thought...

[...]

Quoted 3 lines

Gr{oetje,eeting}s,

Geert

MBR, Sergei