Devicetree
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document R-Car X5H (R8A78000) support
@ 2026-07-04 15:13 Marek Vasut
  2026-07-04 15:13 ` [PATCH 2/2] gpio: rcar: Add " Marek Vasut
  2026-07-05 14:40 ` [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document " Conor Dooley
  0 siblings, 2 replies; 5+ messages in thread
From: Marek Vasut @ 2026-07-04 15:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: Marek Vasut, Bartosz Golaszewski, Conor Dooley,
	Geert Uytterhoeven, Krzysztof Kozlowski, Linus Walleij,
	Rob Herring, devicetree, linux-kernel, linux-renesas-soc

Document support for the GPIO controller blocks in the
Renesas R-Car X5H (R8A78000) SoC.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Bartosz Golaszewski <brgl@kernel.org>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Linus Walleij <linusw@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
---
 .../devicetree/bindings/gpio/renesas,rcar-gpio.yaml          | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml b/Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml
index d32e103a64aac..95f5175c7a9da 100644
--- a/Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml
+++ b/Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml
@@ -56,6 +56,11 @@ properties:
               - renesas,gpio-r8a779h0     # R-Car V4M
           - const: renesas,rcar-gen4-gpio # R-Car Gen4
 
+      - items:
+          - enum:
+              - renesas,gpio-r8a78000     # R-Car X5H
+          - const: renesas,rcar-gen5-gpio # R-Car Gen5
+
   reg:
     maxItems: 1
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] gpio: rcar: Add R-Car X5H (R8A78000) support
  2026-07-04 15:13 [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document R-Car X5H (R8A78000) support Marek Vasut
@ 2026-07-04 15:13 ` Marek Vasut
  2026-07-06  9:19   ` Bartosz Golaszewski
  2026-07-05 14:40 ` [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document " Conor Dooley
  1 sibling, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2026-07-04 15:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: Marek Vasut, Bartosz Golaszewski, Conor Dooley,
	Geert Uytterhoeven, Krzysztof Kozlowski, Linus Walleij,
	Rob Herring, devicetree, linux-kernel, linux-renesas-soc

R-Car X5H (R8A78000) is the first member of the R-Car Gen5 family.
Add support for R-Car X5H, which has slightly different GPIO block
register layout compared to previous generations. Introduce offset
remap function which performs 1:1 remap for R-Car Gen1..4 and a bit
more complex remap for R-Car Gen5.

The GPIO block register offsets on R-Car Gen5 changed and the change
can be divided into five groups, registers which remained at the
same offset, INDT register shifted by +0x10, OUTDTSEL register
shifted by -0x34, INEN register shifted by -0x38 and the rest of
the registers used by the driver shifted by +0x70 .

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Bartosz Golaszewski <brgl@kernel.org>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Linus Walleij <linusw@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/gpio/gpio-rcar.c | 61 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 09bebde5c4260..a22112d9dce0f 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -36,6 +36,7 @@ struct gpio_rcar_info {
 	bool has_both_edge_trigger;
 	bool has_always_in;
 	bool has_inen;
+	bool has_layout_gen5;
 };
 
 struct gpio_rcar_priv {
@@ -65,14 +66,59 @@ struct gpio_rcar_priv {
 
 #define RCAR_MAX_GPIO_PER_BANK		32
 
+static inline int gpio_rcar_remap_offset(struct gpio_rcar_priv *p, int *offs)
+{
+	/* R-Car Gen4 and older do not need any offset remap. */
+	if (!p->info.has_layout_gen5)
+		return 0;
+
+	/*
+	 * R-Car Gen5 register layout is slightly different and the offsets
+	 * that have to be added to or subtracted from each register offset
+	 * can be divided into five groups, listed below.
+	 */
+	switch (*offs) {
+	case IOINTSEL...OUTDT:
+		return 0;
+	case INDT:
+		*offs += 0x10;
+		return 0;
+	case INTDT...EDGLEVEL:
+		fallthrough;
+	case BOTHEDGE:
+		*offs += 0x70;
+		return 0;
+	case OUTDTSEL:
+		*offs -= 0x34;
+		return 0;
+	case INEN:
+		*offs -= 0x38;
+		return 0;
+	default:
+		/*
+		 * This here must never be reached, if this is reached, that
+		 * means there is a catastrophic failure in the driver. Skip
+		 * any IO read/write to prevent further damage.
+		 */
+		WARN_ON(1);
+		return -EINVAL;
+	}
+}
+
 static inline u32 gpio_rcar_read(struct gpio_rcar_priv *p, int offs)
 {
+	if (gpio_rcar_remap_offset(p, &offs))
+		return 0;
+
 	return ioread32(p->base + offs);
 }
 
 static inline void gpio_rcar_write(struct gpio_rcar_priv *p, int offs,
 				   u32 value)
 {
+	if (gpio_rcar_remap_offset(p, &offs))
+		return;
+
 	iowrite32(value, p->base + offs);
 }
 
@@ -399,6 +445,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen1 = {
 	.has_both_edge_trigger = false,
 	.has_always_in = false,
 	.has_inen = false,
+	.has_layout_gen5 = false,
 };
 
 static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
@@ -406,6 +453,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
 	.has_both_edge_trigger = true,
 	.has_always_in = false,
 	.has_inen = false,
+	.has_layout_gen5 = false,
 };
 
 static const struct gpio_rcar_info gpio_rcar_info_gen3 = {
@@ -413,6 +461,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen3 = {
 	.has_both_edge_trigger = true,
 	.has_always_in = true,
 	.has_inen = false,
+	.has_layout_gen5 = false,
 };
 
 static const struct gpio_rcar_info gpio_rcar_info_gen4 = {
@@ -420,6 +469,15 @@ static const struct gpio_rcar_info gpio_rcar_info_gen4 = {
 	.has_both_edge_trigger = true,
 	.has_always_in = true,
 	.has_inen = true,
+	.has_layout_gen5 = false,
+};
+
+static const struct gpio_rcar_info gpio_rcar_info_gen5 = {
+	.has_outdtsel = true,
+	.has_both_edge_trigger = true,
+	.has_always_in = true,
+	.has_inen = true,
+	.has_layout_gen5 = true,
 };
 
 static const struct of_device_id gpio_rcar_of_table[] = {
@@ -438,6 +496,9 @@ static const struct of_device_id gpio_rcar_of_table[] = {
 	}, {
 		.compatible = "renesas,rcar-gen4-gpio",
 		.data = &gpio_rcar_info_gen4,
+	}, {
+		.compatible = "renesas,rcar-gen5-gpio",
+		.data = &gpio_rcar_info_gen5,
 	}, {
 		.compatible = "renesas,gpio-rcar",
 		.data = &gpio_rcar_info_gen1,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document R-Car X5H (R8A78000) support
  2026-07-04 15:13 [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document R-Car X5H (R8A78000) support Marek Vasut
  2026-07-04 15:13 ` [PATCH 2/2] gpio: rcar: Add " Marek Vasut
@ 2026-07-05 14:40 ` Conor Dooley
  1 sibling, 0 replies; 5+ messages in thread
From: Conor Dooley @ 2026-07-05 14:40 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-gpio, Bartosz Golaszewski, Conor Dooley, Geert Uytterhoeven,
	Krzysztof Kozlowski, Linus Walleij, Rob Herring, devicetree,
	linux-kernel, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 75 bytes --]

Acked-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] gpio: rcar: Add R-Car X5H (R8A78000) support
  2026-07-04 15:13 ` [PATCH 2/2] gpio: rcar: Add " Marek Vasut
@ 2026-07-06  9:19   ` Bartosz Golaszewski
  2026-07-06 13:06     ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06  9:19 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Bartosz Golaszewski, Conor Dooley, Geert Uytterhoeven,
	Krzysztof Kozlowski, Linus Walleij, Rob Herring, devicetree,
	linux-kernel, linux-renesas-soc, linux-gpio

On Sat, 4 Jul 2026 17:13:47 +0200, Marek Vasut
<marek.vasut+renesas@mailbox.org> said:
> R-Car X5H (R8A78000) is the first member of the R-Car Gen5 family.
> Add support for R-Car X5H, which has slightly different GPIO block
> register layout compared to previous generations. Introduce offset
> remap function which performs 1:1 remap for R-Car Gen1..4 and a bit
> more complex remap for R-Car Gen5.
>
> The GPIO block register offsets on R-Car Gen5 changed and the change
> can be divided into five groups, registers which remained at the
> same offset, INDT register shifted by +0x10, OUTDTSEL register
> shifted by -0x34, INEN register shifted by -0x38 and the rest of
> the registers used by the driver shifted by +0x70 .
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: Bartosz Golaszewski <brgl@kernel.org>
> Cc: Conor Dooley <conor+dt@kernel.org>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
> Cc: Linus Walleij <linusw@kernel.org>
> Cc: Rob Herring <robh@kernel.org>
> Cc: devicetree@vger.kernel.org
> Cc: linux-gpio@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  drivers/gpio/gpio-rcar.c | 61 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
>
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 09bebde5c4260..a22112d9dce0f 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -36,6 +36,7 @@ struct gpio_rcar_info {
>  	bool has_both_edge_trigger;
>  	bool has_always_in;
>  	bool has_inen;
> +	bool has_layout_gen5;
>  };
>
>  struct gpio_rcar_priv {
> @@ -65,14 +66,59 @@ struct gpio_rcar_priv {
>
>  #define RCAR_MAX_GPIO_PER_BANK		32
>
> +static inline int gpio_rcar_remap_offset(struct gpio_rcar_priv *p, int *offs)
> +{
> +	/* R-Car Gen4 and older do not need any offset remap. */
> +	if (!p->info.has_layout_gen5)
> +		return 0;
> +
> +	/*
> +	 * R-Car Gen5 register layout is slightly different and the offsets
> +	 * that have to be added to or subtracted from each register offset
> +	 * can be divided into five groups, listed below.
> +	 */
> +	switch (*offs) {
> +	case IOINTSEL...OUTDT:
> +		return 0;
> +	case INDT:
> +		*offs += 0x10;
> +		return 0;
> +	case INTDT...EDGLEVEL:
> +		fallthrough;
> +	case BOTHEDGE:
> +		*offs += 0x70;
> +		return 0;
> +	case OUTDTSEL:
> +		*offs -= 0x34;
> +		return 0;
> +	case INEN:
> +		*offs -= 0x38;
> +		return 0;
> +	default:
> +		/*
> +		 * This here must never be reached, if this is reached, that
> +		 * means there is a catastrophic failure in the driver. Skip
> +		 * any IO read/write to prevent further damage.
> +		 */
> +		WARN_ON(1);
> +		return -EINVAL;
> +	}
> +}
> +
>  static inline u32 gpio_rcar_read(struct gpio_rcar_priv *p, int offs)
>  {
> +	if (gpio_rcar_remap_offset(p, &offs))
> +		return 0;
> +
>  	return ioread32(p->base + offs);
>  }
>
>  static inline void gpio_rcar_write(struct gpio_rcar_priv *p, int offs,
>  				   u32 value)
>  {
> +	if (gpio_rcar_remap_offset(p, &offs))
> +		return;
> +
>  	iowrite32(value, p->base + offs);
>  }
>
> @@ -399,6 +445,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen1 = {
>  	.has_both_edge_trigger = false,
>  	.has_always_in = false,
>  	.has_inen = false,
> +	.has_layout_gen5 = false,
>  };
>
>  static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
> @@ -406,6 +453,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
>  	.has_both_edge_trigger = true,
>  	.has_always_in = false,
>  	.has_inen = false,
> +	.has_layout_gen5 = false,
>  };
>
>  static const struct gpio_rcar_info gpio_rcar_info_gen3 = {
> @@ -413,6 +461,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen3 = {
>  	.has_both_edge_trigger = true,
>  	.has_always_in = true,
>  	.has_inen = false,
> +	.has_layout_gen5 = false,
>  };
>
>  static const struct gpio_rcar_info gpio_rcar_info_gen4 = {
> @@ -420,6 +469,15 @@ static const struct gpio_rcar_info gpio_rcar_info_gen4 = {
>  	.has_both_edge_trigger = true,
>  	.has_always_in = true,
>  	.has_inen = true,
> +	.has_layout_gen5 = false,

This looks good but do we really need to change these lines if it's zeroes
anyway?

Bart

> +};
> +
> +static const struct gpio_rcar_info gpio_rcar_info_gen5 = {
> +	.has_outdtsel = true,
> +	.has_both_edge_trigger = true,
> +	.has_always_in = true,
> +	.has_inen = true,
> +	.has_layout_gen5 = true,
>  };
>
>  static const struct of_device_id gpio_rcar_of_table[] = {
> @@ -438,6 +496,9 @@ static const struct of_device_id gpio_rcar_of_table[] = {
>  	}, {
>  		.compatible = "renesas,rcar-gen4-gpio",
>  		.data = &gpio_rcar_info_gen4,
> +	}, {
> +		.compatible = "renesas,rcar-gen5-gpio",
> +		.data = &gpio_rcar_info_gen5,
>  	}, {
>  		.compatible = "renesas,gpio-rcar",
>  		.data = &gpio_rcar_info_gen1,
> --
> 2.53.0
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] gpio: rcar: Add R-Car X5H (R8A78000) support
  2026-07-06  9:19   ` Bartosz Golaszewski
@ 2026-07-06 13:06     ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2026-07-06 13:06 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Conor Dooley, Geert Uytterhoeven, Krzysztof Kozlowski,
	Linus Walleij, Rob Herring, devicetree, linux-kernel,
	linux-renesas-soc, linux-gpio

On 7/6/26 11:19 AM, Bartosz Golaszewski wrote:

Hello Bartosz,

>> +static inline int gpio_rcar_remap_offset(struct gpio_rcar_priv *p, int *offs)
>> +{

I am hoping to get some input on this remap function.

>> +	/* R-Car Gen4 and older do not need any offset remap. */
>> +	if (!p->info.has_layout_gen5)
>> +		return 0;
>> +
>> +	/*
>> +	 * R-Car Gen5 register layout is slightly different and the offsets
>> +	 * that have to be added to or subtracted from each register offset
>> +	 * can be divided into five groups, listed below.
>> +	 */
>> +	switch (*offs) {
>> +	case IOINTSEL...OUTDT:
>> +		return 0;
>> +	case INDT:
>> +		*offs += 0x10;
>> +		return 0;
>> +	case INTDT...EDGLEVEL:
>> +		fallthrough;
>> +	case BOTHEDGE:
>> +		*offs += 0x70;
>> +		return 0;
>> +	case OUTDTSEL:
>> +		*offs -= 0x34;
>> +		return 0;
>> +	case INEN:
>> +		*offs -= 0x38;
>> +		return 0;
>> +	default:
>> +		/*
>> +		 * This here must never be reached, if this is reached, that
>> +		 * means there is a catastrophic failure in the driver. Skip
>> +		 * any IO read/write to prevent further damage.
>> +		 */
>> +		WARN_ON(1);
>> +		return -EINVAL;
>> +	}
>> +}
>> +

[...]

>> @@ -399,6 +445,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen1 = {
>>   	.has_both_edge_trigger = false,
>>   	.has_always_in = false,
>>   	.has_inen = false,
>> +	.has_layout_gen5 = false,
>>   };
>>
>>   static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
>> @@ -406,6 +453,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
>>   	.has_both_edge_trigger = true,
>>   	.has_always_in = false,
>>   	.has_inen = false,
>> +	.has_layout_gen5 = false,
>>   };
>>
>>   static const struct gpio_rcar_info gpio_rcar_info_gen3 = {
>> @@ -413,6 +461,7 @@ static const struct gpio_rcar_info gpio_rcar_info_gen3 = {
>>   	.has_both_edge_trigger = true,
>>   	.has_always_in = true,
>>   	.has_inen = false,
>> +	.has_layout_gen5 = false,
>>   };
>>
>>   static const struct gpio_rcar_info gpio_rcar_info_gen4 = {
>> @@ -420,6 +469,15 @@ static const struct gpio_rcar_info gpio_rcar_info_gen4 = {
>>   	.has_both_edge_trigger = true,
>>   	.has_always_in = true,
>>   	.has_inen = true,
>> +	.has_layout_gen5 = false,
> 
> This looks good but do we really need to change these lines if it's zeroes
> anyway?

I'm just following the pattern in the driver, which does full assignment 
of all fields for all generations of the controller. See .has_inen = 
false in Gen1 for example. We don't have to do the assignment, but maybe 
doing so is more comprehensible ?

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-06 19:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-04 15:13 [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document R-Car X5H (R8A78000) support Marek Vasut
2026-07-04 15:13 ` [PATCH 2/2] gpio: rcar: Add " Marek Vasut
2026-07-06  9:19   ` Bartosz Golaszewski
2026-07-06 13:06     ` Marek Vasut
2026-07-05 14:40 ` [PATCH 1/2] dt-bindings: gpio: renesas,rcar-gpio: Document " Conor Dooley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox