Skip to contentSkip to conversation

rtc: rzn1: cleanups, R-Car X5H enablement

PATCH Applied Wolfram Sang 4 participants 11 messages Sep 17 – Sep 30

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

v4 cover rtc: rzn1: cleanups, R-Car X5H enablement

This series adds RTC support for the Renesas R-Car X5H SoC.

Changes since v3:
* clear RTC_FEATURE_UPDATE_INTERRUPT when no irqs
* added tags

Thanks for all the reviews of v3!

These patches have been tested on the original RZ/N1D board and the new X5H Ironhide board. 'rtctest' passed on both SoCs. On X5H, some tests are skipped, of course, because no alarms are supported.

'dt_binding_check' and 'dtbs_check' did not find any issues, for both, RZ/N1D and R-Car X5H. I also verified for both that it rightfully complains when irqs are different from what is expected.

A branch can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/x5h/rtc-experimental

Looking forward to comments.

Wolfram Sang (4):
dt-bindings: rtc: rzn1: drop unneeded 'start-year' from example
dt-bindings: rtc: rzn1: add SoC names next to their IDs
dt-bindings: rtc: rzn1: add R-Car X5H support
rtc: rzn1: add R-Car X5H support

 .../bindings/rtc/renesas,rzn1-rtc.yaml        | 30 ++++++++---
 drivers/rtc/rtc-rzn1.c                        | 52 +++++++++++++------
 2 files changed, 57 insertions(+), 25 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v4 1/4 dt-bindings: rtc: rzn1: drop unneeded 'start-year' from example

We don't use 'start-year' in upstream DTs because the driver does the right thing by default, ranging from 2000 to 2099. So, drop it from the example, too.

---

Changes since v3: none

 Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml | 1 -
 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml +0 -1
index ea7b039a91e7..e96007981c34 100644
@@ -91,5 +91,4 @@ examples:
         clocks = <&sysctrl R9A06G032_HCLK_RTC>;
         clock-names = "hclk";
         power-domains = <&sysctrl>;
-        start-year = <2000>;
     };
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v4 1/4] dt-bindings: rtc: rzn1: drop unneeded 'start-year' from example

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

We don't use 'start-year' in upstream DTs because the driver does the right thing by default, ranging from 2000 to 2099. So, drop it from the example, too.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH v4 2/4 dt-bindings: rtc: rzn1: add SoC names next to their IDs

In reply to Wolfram Sang

This helps maintaining because the numbers are easy to confuse.

---

Changes since v3: none

 .../devicetree/bindings/rtc/renesas,rzn1-rtc.yaml      | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml +5 -5
index e96007981c34..7ea77cd0bee1 100644
@@ -14,14 +14,14 @@ properties:
     oneOf:
       - items:
           - enum:
-              - renesas,r9a06g032-rtc
-          - const: renesas,rzn1-rtc
+              - renesas,r9a06g032-rtc # RZ/N1D
+          - const: renesas,rzn1-rtc   # RZ/N1
 
-      - const: renesas,r9a09g077-rtc
+      - const: renesas,r9a09g077-rtc  # RZ/T2H
 
       - items:
-          - const: renesas,r9a09g087-rtc
-          - const: renesas,r9a09g077-rtc
+          - const: renesas,r9a09g087-rtc  # RZ/N2H
+          - const: renesas,r9a09g077-rtc  # RZ/T2H
 
   reg:
     maxItems: 1
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH v4 2/4] dt-bindings: rtc: rzn1: add SoC names next to their IDs

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines

This helps maintaining because the numbers are easy to confuse.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

PATCH v4 3/4 dt-bindings: rtc: rzn1: add R-Car X5H support

In reply to Wolfram Sang

The RTC on R-Car X5H is a bit special because interrupts are not wired. Future R-Car Gen5 SoCs will have them wired again. So, create a dedicated entry for X5H without interrupts.

---

Changes since v3: tag added

 .../bindings/rtc/renesas,rzn1-rtc.yaml        | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml +17 -2
index 7ea77cd0bee1..b448725671ec 100644
@@ -23,6 +23,8 @@ properties:
           - const: renesas,r9a09g087-rtc  # RZ/N2H
           - const: renesas,r9a09g077-rtc  # RZ/T2H
 
+      - const: renesas,r8a78000-rtc   # R-Car X5H
+
   reg:
     maxItems: 1
 
@@ -52,8 +54,6 @@ properties:
 required:
   - compatible
   - reg
-  - interrupts
-  - interrupt-names
   - clocks
   - clock-names
   - power-domains
@@ -66,6 +66,7 @@ allOf:
         compatible:
           contains:
             enum:
+              - renesas,r8a78000-rtc
               - renesas,r9a09g077-rtc
               - renesas,r9a09g087-rtc
     then:
@@ -75,6 +76,20 @@ allOf:
         clock-names:
           minItems: 2
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: renesas,r8a78000-rtc
+    then:
+      properties:
+        interrupts: false
+        interrupt-names: false
+    else:
+      required:
+        - interrupts
+        - interrupt-names
+
 unevaluatedProperties: false
 
 examples:
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH v4 3/4] dt-bindings: rtc: rzn1: add R-Car X5H support

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

The RTC on R-Car X5H is a bit special because interrupts are not wired. Future R-Car Gen5 SoCs will have them wired again. So, create a dedicated entry for X5H without interrupts.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Reviewed-by Lad Prabhakar on v4 3/4
#7 lore raw

Re: [PATCH v4 3/4] dt-bindings: rtc: rzn1: add R-Car X5H support

In reply to Wolfram Sang
Quoted 5 lines · Wolfram Sang

The RTC on R-Car X5H is a bit special because interrupts are not wired. Future R-Car Gen5 SoCs will have them wired again. So, create a dedicated entry for X5H without interrupts.

Quoted 9 lines

---

Changes since v3: tag added

 .../bindings/rtc/renesas,rzn1-rtc.yaml        | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Cheers,
Prabhakar

Quoted 54 lines
Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml +17 -3
index 7ea77cd0bee1..b448725671ec 100644
@@ -23,6 +23,8 @@ properties:
           - const: renesas,r9a09g087-rtc  # RZ/N2H
           - const: renesas,r9a09g077-rtc  # RZ/T2H
 
+      - const: renesas,r8a78000-rtc   # R-Car X5H
+
   reg:
     maxItems: 1
 
@@ -52,8 +54,6 @@ properties:
 required:
   - compatible
   - reg
-  - interrupts
-  - interrupt-names
   - clocks
   - clock-names
   - power-domains
@@ -66,6 +66,7 @@ allOf:
         compatible:
           contains:
             enum:
+              - renesas,r8a78000-rtc
               - renesas,r9a09g077-rtc
               - renesas,r9a09g087-rtc
     then:
@@ -75,6 +76,20 @@ allOf:
         clock-names:
           minItems: 2
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: renesas,r8a78000-rtc
+    then:
+      properties:
+        interrupts: false
+        interrupt-names: false
+    else:
+      required:
+        - interrupts
+        - interrupt-names
+
 unevaluatedProperties: false
 
 examples:
--

2.53.0

#8 lore raw

PATCH v4 4/4 rtc: rzn1: add R-Car X5H support

In reply to Wolfram Sang

The RTC on R-Car X5H is a bit special because interrupts are not wired. Future R-Car Gen5 SoCs will have them wired again. So, create a dedicated entry for X5H without interrupts.

---

Changes since v3:

* clear RTC_FEATURE_UPDATE_INTERRUPT when no irqs
* add tag

 drivers/rtc/rtc-rzn1.c | 52 ++++++++++++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 17 deletions(-)
drivers/rtc/rtc-rzn1.c +35 -17
index b9d69ebdd224..1db518ab3a3a 100644
@@ -68,6 +68,7 @@
 
 struct rzn1_rtc_data {
 	bool has_subu;
+	bool broken_irqs;
 };
 
 struct rzn1_rtc {
@@ -396,6 +397,11 @@ static const struct rtc_class_ops rzn1_rtc_ops_scmp = {
 	.alarm_irq_enable = rzn1_rtc_alarm_irq_enable,
 };
 
+static const struct rtc_class_ops rzn1_rtc_ops_scmp_no_alarm = {
+	.read_time = rzn1_rtc_read_time,
+	.set_time = rzn1_rtc_set_time,
+};
+
 static void rzn1_rtc_disable_hardware(void *data)
 {
 	struct device *dev = data;
@@ -431,10 +437,6 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(rtc->base))
 		return dev_err_probe(dev, PTR_ERR(rtc->base), "Missing reg\n");
 
-	irq = platform_get_irq_byname(pdev, "alarm");
-	if (irq < 0)
-		return irq;
-
 	rtc->rtcdev = devm_rtc_allocate_device(dev);
 	if (IS_ERR(rtc->rtcdev))
 		return PTR_ERR(rtc->rtcdev);
@@ -503,25 +505,40 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
 
 	spin_lock_init(&rtc->ctl1_access_lock);
 
-	ret = devm_request_irq(dev, irq, rzn1_rtc_alarm_irq, 0, "RZN1 RTC Alarm", rtc);
-	if (ret)
-		return dev_err_probe(dev, ret, "RTC alarm interrupt not available\n");
-
-	irq = platform_get_irq_byname_optional(pdev, "pps");
-	if (irq == -EPROBE_DEFER)
-		return irq;
-	if (irq >= 0)
-		ret = devm_request_irq(dev, irq, rzn1_rtc_1s_irq, 0, "RZN1 RTC 1s", rtc);
-
-	if (irq < 0 || ret) {
-		set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtcdev->features);
+	if (data->broken_irqs) {
+		/* All known broken irqs are on SCMP only variants */
+		rtc->rtcdev->ops = &rzn1_rtc_ops_scmp_no_alarm;
 		clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtcdev->features);
-		dev_warn(dev, "RTC pps interrupt not available. Alarm has only minute accuracy\n");
+	} else {
+		irq = platform_get_irq_byname(pdev, "alarm");
+		if (irq < 0)
+			return irq;
+
+		ret = devm_request_irq(dev, irq, rzn1_rtc_alarm_irq, 0, "RZN1 RTC Alarm", rtc);
+		if (ret)
+			return dev_err_probe(dev, ret, "RTC alarm interrupt not available\n");
+
+		irq = platform_get_irq_byname_optional(pdev, "pps");
+		if (irq == -EPROBE_DEFER)
+			return irq;
+		if (irq >= 0)
+			ret = devm_request_irq(dev, irq, rzn1_rtc_1s_irq, 0, "RZN1 RTC 1s", rtc);
+
+		if (irq < 0 || ret) {
+			set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtcdev->features);
+			clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtcdev->features);
+			dev_warn(dev, "RTC pps interrupt not available. Alarm has only minute accuracy\n");
+		}
 	}
 
 	return devm_rtc_register_device(rtc->rtcdev);
 }
 
+static const struct rzn1_rtc_data rzn1_rtc_r8a78000_data = {
+	.has_subu = false,
+	.broken_irqs = true,
+};
+
 static const struct rzn1_rtc_data rzn1_rtc_rzt2h_data = {
 	.has_subu = false,
 };
@@ -531,6 +548,7 @@ static const struct rzn1_rtc_data rzn1_rtc_rzn1_data = {
 };
 
 static const struct of_device_id rzn1_rtc_of_match[] = {
+	{ .compatible	= "renesas,r8a78000-rtc", .data = &rzn1_rtc_r8a78000_data },
 	{ .compatible	= "renesas,r9a09g077-rtc", .data = &rzn1_rtc_rzt2h_data },
 	{ .compatible	= "renesas,rzn1-rtc", .data = &rzn1_rtc_rzn1_data },
 	{ /* sentinel */ }
Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH v4 4/4] rtc: rzn1: add R-Car X5H support

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

The RTC on R-Car X5H is a bit special because interrupts are not wired. Future R-Car Gen5 SoCs will have them wired again. So, create a dedicated entry for X5H without interrupts.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
maintainer Applied
#10 lore raw
In reply to Wolfram Sang
Quoted 9 lines · Wolfram Sang

This series adds RTC support for the Renesas R-Car X5H SoC.

Changes since v3:
* clear RTC_FEATURE_UPDATE_INTERRUPT when no irqs
* added tags

Thanks for all the reviews of v3!

[...]

Applied, thanks!

[1/4] dt-bindings: rtc: rzn1: drop unneeded 'start-year' from example

      https://git.kernel.org/abelloni/c/a867106d8a89
[2/4] dt-bindings: rtc: rzn1: add SoC names next to their IDs
      https://git.kernel.org/abelloni/c/73defdbfce62
[3/4] dt-bindings: rtc: rzn1: add R-Car X5H support
      https://git.kernel.org/abelloni/c/3b3fdc9fd40d
[4/4] rtc: rzn1: add R-Car X5H support
      https://git.kernel.org/abelloni/c/cba3b5f4cc00

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com