Skip to contentSkip to conversation

Add RZ/V2H RTC support

PATCH Applied Ovidiu Panait 2 participants 11 messages Jan 9 – Jan 12

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Add RZ/V2H RTC support

Hi,

This patch series adds RTC support for the Renesas RZ/V2H SoC.

Patches were cherry-picked from mainline kernel.

Best regards,
Ovidiu

Alexandre Belloni (1):
rtc: renesas-rtca3: stop setting max_user_freq

Claudiu Beznea (1):
rtc: renesas-rtca3: Disable interrupts only if the RTC is enabled

Ovidiu Panait (6):
dt-bindings: rtc: renesas,rz-rtca3: Add RZ/V2H support
clk: renesas: r9a09g057: Add clock and reset entries for RTC
rtc: renesas-rtca3: Add support for multiple reset lines
arm64: dts: renesas: r9a09g057: Add RTC node
arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable RTC
arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Add NMI pushbutton
support

 .../bindings/rtc/renesas,rz-rtca3.yaml        | 46 +++++++++++++++++--
 arch/arm64/boot/dts/renesas/r9a09g057.dtsi    | 15 ++++++
 .../dts/renesas/r9a09g057h44-rzv2h-evk.dts    | 17 +++++++
 drivers/clk/renesas/r9a09g057-cpg.c           |  4 ++
 drivers/rtc/rtc-renesas-rtca3.c               | 18 +++-----
 5 files changed, 84 insertions(+), 16 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/8 dt-bindings: rtc: renesas,rz-rtca3: Add RZ/V2H support

commit 4800046b56a5b240ab280f55165484a9dbdf7092 upstream.

The Renesas RZ/V2H RTC IP is based on the same RTCA3 IP as RZ/G3S (r9a08g045), with the following differences:
- It lacks the time capture functionality
- The maximum supported periodic interrupt frequency is 128Hz instead of 256Hz
- It requires two reset lines instead of one

Add new compatible string "renesas,r9a09g057-rtca3" for RZ/V2H and update the binding accordingly:
- Allow "resets" to contain one or two entries depending on the SoC.
- Add "reset-names" property, but make it required only for RZ/V2H.

---
 .../bindings/rtc/renesas,rz-rtca3.yaml        | 46 +++++++++++++++++--
 1 file changed, 41 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml +41 -5
index e70eeb66aa64..ccb1638c35b9 100644
@@ -9,14 +9,12 @@ title: Renesas RTCA-3 Real Time Clock
 maintainers:
   - Claudiu Beznea <[email protected]>
 
-allOf:
-  - $ref: rtc.yaml#
-
 properties:
   compatible:
     items:
       - enum:
           - renesas,r9a08g045-rtca3 # RZ/G3S
+          - renesas,r9a09g057-rtca3 # RZ/V2H
       - const: renesas,rz-rtca3
 
   reg:
@@ -48,8 +46,12 @@ properties:
     maxItems: 1
 
   resets:
-    items:
-      - description: VBATTB module reset
+    minItems: 1
+    maxItems: 2
+
+  reset-names:
+    minItems: 1
+    maxItems: 2
 
 required:
   - compatible
@@ -61,6 +63,39 @@ required:
   - power-domains
   - resets
 
+allOf:
+  - $ref: rtc.yaml#
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: renesas,r9a08g045-rtca3
+    then:
+      properties:
+        resets:
+          items:
+            - description: VBATTB module reset
+        reset-names:
+          const: vbattb
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: renesas,r9a09g057-rtca3
+    then:
+      properties:
+        resets:
+          items:
+            - description: RTC reset
+            - description: Reset for the RTEST registers
+        reset-names:
+          items:
+            - const: rtc
+            - const: rtest
+      required:
+        - reset-names
+
 additionalProperties: false
 
 examples:
@@ -81,4 +116,5 @@ examples:
         clock-names = "bus", "counter";
         power-domains = <&cpg>;
         resets = <&cpg R9A08G045_VBAT_BRESETN>;
+        reset-names = "vbattb";
     };
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/8 clk: renesas: r9a09g057: Add clock and reset entries for RTC

In reply to Ovidiu Panait

commit 7a03ef9f8223434f19e19a37acc32dcb581ab475 upstream.

Add module clock and reset entries for the RTC module on the Renesas RZ/V2H (R9A09G057) SoC.

---
 drivers/clk/renesas/r9a09g057-cpg.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clk/renesas/r9a09g057-cpg.c +4 -0
index 687c25f76852..7595632e3918 100644
@@ -240,6 +240,8 @@ static const struct rzv2h_mod_clk r9a09g057_mod_clks[] __initconst = {
 						BUS_MSTOP(5, BIT(13))),
 	DEF_MOD("wdt_3_clk_loco",		CLK_QEXTAL, 5, 2, 2, 18,
 						BUS_MSTOP(5, BIT(13))),
+	DEF_MOD("rtc_0_clk_rtc",		CLK_PLLCM33_DIV16, 5, 3, 2, 19,
+						BUS_MSTOP(3, BIT(11) | BIT(12))),
 	DEF_MOD("scif_0_clk_pck",		CLK_PLLCM33_DIV16, 8, 15, 4, 15,
 						BUS_MSTOP(3, BIT(14))),
 	DEF_MOD("riic_8_ckm",			CLK_PLLCM33_DIV16, 9, 3, 4, 19,
@@ -378,6 +380,8 @@ static const struct rzv2h_reset r9a09g057_resets[] __initconst = {
 	DEF_RST(7, 6, 3, 7),		/* WDT_1_RESET */
 	DEF_RST(7, 7, 3, 8),		/* WDT_2_RESET */
 	DEF_RST(7, 8, 3, 9),		/* WDT_3_RESET */
+	DEF_RST(7, 9, 3, 10),		/* RTC_0_RST_RTC */
+	DEF_RST(7, 10, 3, 11),		/* RTC_0_RST_RTC_V */
 	DEF_RST(9, 5, 4, 6),		/* SCIF_0_RST_SYSTEM_N */
 	DEF_RST(9, 8, 4, 9),		/* RIIC_0_MRST */
 	DEF_RST(9, 9, 4, 10),		/* RIIC_1_MRST */
Signature · 1 line
2.51.0
#3 lore raw

PATCH 3/8 rtc: renesas-rtca3: Disable interrupts only if the RTC is enabled

In reply to Ovidiu Panait

From: Claudiu Beznea <[email protected]>

commit 27b2fcbd6b98204b0dce62e9aa9540ca0a2b70f1 upstream.

If the RTC is not enabled and the code attempts to disable the interrupt, the readb_poll_timeout_atomic() function in the rtca3_alarm_irq_set_helper() may timeout, leading to probe failures. This issue is reproducible on some devices because the initial values of the PIE and AIE bits in the RCR1 register are undefined.

To prevent probe failures in this scenario, disable RTC interrupts only when the RTC is actually enabled.

Fixes d4488377609e ("rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC")
---
 drivers/rtc/rtc-renesas-rtca3.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/rtc/rtc-renesas-rtca3.c +6 -9
index 4bc28680f650..bd9f809a04ad 100644
@@ -586,17 +586,14 @@ static int rtca3_initial_setup(struct clk *clk, struct rtca3_priv *priv)
 	 */
 	usleep_range(sleep_us, sleep_us + 10);
 
-	/* Disable all interrupts. */
-	mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE;
-	ret = rtca3_alarm_irq_set_helper(priv, mask, 0);
-	if (ret)
-		return ret;
-
 	mask = RTCA3_RCR2_START | RTCA3_RCR2_HR24;
 	val = readb(priv->base + RTCA3_RCR2);
-	/* Nothing to do if already started in 24 hours and calendar count mode. */
-	if ((val & mask) == mask)
-		return 0;
+	/* Only disable the interrupts if already started in 24 hours and calendar count mode. */
+	if ((val & mask) == mask) {
+		/* Disable all interrupts. */
+		mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE;
+		return rtca3_alarm_irq_set_helper(priv, mask, 0);
+	}
 
 	/* Reconfigure the RTC in 24 hours and calendar count mode. */
 	mask = RTCA3_RCR2_START | RTCA3_RCR2_CNTMD;
Signature · 1 line
2.51.0
#4 lore raw

PATCH 4/8 rtc: renesas-rtca3: stop setting max_user_freq

In reply to Ovidiu Panait

From: Alexandre Belloni <[email protected]>

commit 358867b551660ac7d0987fe5fad8518cbfd5e415 upstream.

max_user_freq has not been related to the hardware RTC since commit 6610e0893b8b ("RTC: Rework RTC code to use timerqueue for events"). Stop setting it from individual driver to avoid confusing new contributors.

---
 drivers/rtc/rtc-renesas-rtca3.c | 1 -
 1 file changed, 1 deletion(-)
drivers/rtc/rtc-renesas-rtca3.c +0 -1
index bd9f809a04ad..b9630c800343 100644
@@ -772,7 +772,6 @@ static int rtca3_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->rtc_dev);
 
 	priv->rtc_dev->ops = &rtca3_ops;
-	priv->rtc_dev->max_user_freq = 256;
 	priv->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	priv->rtc_dev->range_max = RTC_TIMESTAMP_END_2099;
 
Signature · 1 line
2.51.0
#5 lore raw

PATCH 5/8 rtc: renesas-rtca3: Add support for multiple reset lines

In reply to Ovidiu Panait

commit 6ada8e24238dd57b38faca503b09757e17819b05 upstream.

Switch from devm_reset_control_get_shared() to devm_reset_control_array_get_shared() when retrieving resets.

The RZ/V2H SoC requires two resets for the RTC block instead of one, so this will allow to handle multiple resets without additional changes.

---
 drivers/rtc/rtc-renesas-rtca3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-renesas-rtca3.c +1 -1
index b9630c800343..3c677790d8fa 100644
@@ -726,7 +726,7 @@ static int rtca3_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	priv->rstc = devm_reset_control_get_shared(dev, NULL);
+	priv->rstc = devm_reset_control_array_get_shared(dev);
 	if (IS_ERR(priv->rstc))
 		return PTR_ERR(priv->rstc);
 
Signature · 1 line
2.51.0
#6 lore raw

PATCH 6/8 arm64: dts: renesas: r9a09g057: Add RTC node

In reply to Ovidiu Panait

commit cfc733da4e79018f88d8ac5f3a5306abbba8ef89 upstream.

Add RTC node to Renesas RZ/V2H ("R9A09G057") SoC DTSI.

---
 arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/renesas/r9a09g057.dtsi +15 -0
index 7cfdf9db851d..3eaa9b2698af 100644
@@ -557,6 +557,21 @@ wdt3: watchdog@13000400 {
 			status = "disabled";
 		};
 
+		rtc: rtc@11c00800 {
+			compatible = "renesas,r9a09g057-rtca3", "renesas,rz-rtca3";
+			reg = <0 0x11c00800 0 0x400>;
+			interrupts = <GIC_SPI 524 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 525 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 526 IRQ_TYPE_EDGE_RISING>;
+			interrupt-names = "alarm", "period", "carry";
+			clocks = <&cpg CPG_MOD 0x53>, <&rtxin_clk>;
+			clock-names = "bus", "counter";
+			power-domains = <&cpg>;
+			resets = <&cpg 0x79>, <&cpg 0x7a>;
+			reset-names = "rtc", "rtest";
+			status = "disabled";
+		};
+
 		scif: serial@11c01400 {
 			compatible = "renesas,scif-r9a09g057";
 			reg = <0 0x11c01400 0 0x400>;
Signature · 1 line
2.51.0
#7 lore raw

PATCH 7/8 arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable RTC

In reply to Ovidiu Panait

commit 1eb61aa4d88d916f2d5aaf2a1fe30b3d01354bbe upstream.

Enable RTC.

---
 arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts +4 -0
index 3a413837c58f..3225d6065a85 100644
@@ -358,6 +358,10 @@ &qextal_clk {
 	clock-frequency = <24000000>;
 };
 
+&rtc {
+	status = "okay";
+};
+
 &rtxin_clk {
 	clock-frequency = <32768>;
 };
Signature · 1 line
2.51.0
#8 lore raw

PATCH 8/8 arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Add NMI pushbutton support

In reply to Ovidiu Panait

commit f61c497a91c4f7f5b34e78475dafc511cdcebca6 upstream.

RZ/V2H EVK has a user pushbutton connected to the SoC NMI pin, which can be used to wake up the system from suspend to idle. Add a DT node in the device tree to instantiate the gpio-keys driver for this button.

---
 .../boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts +13 -0
index 3225d6065a85..b428c0cff030 100644
@@ -9,6 +9,7 @@
 
 #include <dt-bindings/pinctrl/renesas,r9a09g057-pinctrl.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 #include "r9a09g057.dtsi"
 
 / {
@@ -34,6 +35,18 @@ chosen {
 		stdout-path = "serial0:115200n8";
 	};
 
+	keys: keys {
+		compatible = "gpio-keys";
+
+		key-wakeup {
+			interrupts-extended = <&icu 0 IRQ_TYPE_EDGE_FALLING>;
+			linux,code = <KEY_WAKEUP>;
+			label = "NMI_SW";
+			debounce-interval = <20>;
+			wakeup-source;
+		};
+	};
+
 	memory@48000000 {
 		device_type = "memory";
 		/* first 128MB is reserved for secure area. */
Signature · 1 line
2.51.0
Applied
#10 lore raw
In reply to Ovidiu Panait

Hi!

Quoted 3 lines

This patch series adds RTC support for the Renesas RZ/V2H SoC.

Patches were cherry-picked from mainline kernel.

Thank you, applied and pushed out.

Best regards,
Pavel

Signature · 1 line
In cooperation with Nabla.