Skip to contentSkip to conversation

rtc: Introduce rtc-ti-k3

PATCH Superseded Nishanth Menon 3 participants 7 messages May 11, 2022 – May 12, 2022

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover rtc: Introduce rtc-ti-k3

Hi,

This series adds support for TI K3 RTC as instantiated on TI's AM625 SoC.

Documentation in the current early release version of Technical Reference Manual is incomplete at the moment, but due to be updated later this year.
https://www.ti.com/lit/pdf/spruiv7

Testing log can be found here (next-20220509 + additional node for dts):

	https://gist.github.com/nmenon/df536a01c3c14cf8b6c809aec8972339

Changes since V1:
* bindings updated for review comments
* driver modified to move to regmap fields and review comments incorporated.

V1: https://lore.kernel.org/all/[email protected]/

Nishanth Menon (2):
dt-bindings: rtc: Add TI K3 RTC description
rtc: Introduce ti-k3-rtc

 .../devicetree/bindings/rtc/ti,k3-rtc.yaml    |  61 ++
 drivers/rtc/Kconfig                           |  11 +
 drivers/rtc/Makefile                          |   1 +
 drivers/rtc/rtc-ti-k3.c                       | 688 ++++++++++++++++++
 4 files changed, 761 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml
 create mode 100644 drivers/rtc/rtc-ti-k3.c
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/2 dt-bindings: rtc: Add TI K3 RTC description

This adds the documentation for the devicetree bindings of the Texas Instruments RTC modules on K3 family of SoCs such as AM62x SoCs or newer.

---
Changes since V1:
Krzysztof's comments addressed:
* $subject updated
* assigned-clocks* dropped
* Dropped the un-necessary quotes
* Dropped the extra example, which serves no purpose now.
* compatible is just an enum now.

V1: https://lore.kernel.org/all/[email protected]/

 .../devicetree/bindings/rtc/ti,k3-rtc.yaml    | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml
Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml new file +61 -0
new file mode 100644
index 000000000000..444e18df6231
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/rtc/ti,k3-rtc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Real Time Clock
+
+maintainers:
+  - Nishanth Menon <[email protected]>
+
+description: |
+  This RTC appears in the AM62x family of SoCs.
+
+properties:
+  compatible:
+    enum:
+      - ti,am62-rtc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: VBUS Interface clock
+      - description: 32k Clock source (external or internal).
+
+  clock-names:
+    items:
+      - const: vbus
+      - const: osc32k
+
+  power-domains:
+    maxItems: 1
+
+  wakeup-source: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    rtc@2b1f0000 {
+        compatible = "ti,am62-rtc";
+        reg = <0x2b1f0000 0x100>;
+        interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
+        power-domains = <&bar 0>;
+        clocks = <&foo 0>, <&foo 1>;
+        clock-names = "vbus", "osc32k";
+        wakeup-source;
+    };
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH V2 1/2] dt-bindings: rtc: Add TI K3 RTC description

Quoted 64 lines · Nishanth Menon

This adds the documentation for the devicetree bindings of the Texas Instruments RTC modules on K3 family of SoCs such as AM62x SoCs or newer.

---
Changes since V1:
Krzysztof's comments addressed:
* $subject updated
* assigned-clocks* dropped
* Dropped the un-necessary quotes
* Dropped the extra example, which serves no purpose now.
* compatible is just an enum now.

V1: https://lore.kernel.org/all/[email protected]/

 .../devicetree/bindings/rtc/ti,k3-rtc.yaml    | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml
Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml new file +38 -0
new file mode 100644
index 000000000000..444e18df6231
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/rtc/ti,k3-rtc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Real Time Clock
+
+maintainers:
+  - Nishanth Menon <[email protected]>
+
+description: |
+  This RTC appears in the AM62x family of SoCs.
+
+properties:
+  compatible:
+    enum:
+      - ti,am62-rtc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: VBUS Interface clock
+      - description: 32k Clock source (external or internal).
+
+  clock-names:
+    items:
+      - const: vbus
+      - const: osc32k
+
+  power-domains:
+    maxItems: 1
+

Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml line 48

Quoted 10 lines
Documentation/devicetree/bindings/rtc/ti,k3-rtc.yaml new file +10 -0
+  wakeup-source: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false

I didn't brought it earlier (I assumed you used existing RTC examples for your schema): why this is not including generic rtc.yaml schema? Isn't this a RTC?

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH V2 1/2] dt-bindings: rtc: Add TI K3 RTC description

Quoted 1 line · Krzysztof Kozlowski

On 11/05/2022 02:25, Nishanth Menon wrote:

[...]

Quoted 4 lines

I didn't brought it earlier (I assumed you used existing RTC examples for your schema): why this is not including generic rtc.yaml schema? Isn't this a RTC?

Oversight, and I suppose I picked a bad example to emulate :(

I assume you mean adding:
allOf:
- $ref: "rtc.yaml#"

Like this:
https://gist.github.com/nmenon/0c326c92fbadecd042209c0078f0af99 ?

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#4 lore raw

Re: [PATCH V2 1/2] dt-bindings: rtc: Add TI K3 RTC description

Quoted 9 lines · Nishanth Menon
Quoted 1 line · Krzysztof Kozlowski

On 11/05/2022 02:25, Nishanth Menon wrote:

[...]

Quoted 4 lines

I didn't brought it earlier (I assumed you used existing RTC examples for your schema): why this is not including generic rtc.yaml schema? Isn't this a RTC?

Quoted 8 lines

Oversight, and I suppose I picked a bad example to emulate :(

I assume you mean adding:
allOf:
- $ref: "rtc.yaml#"

Like this:
https://gist.github.com/nmenon/0c326c92fbadecd042209c0078f0af99 ?

Yes plus you need to use unevaluatedProperties:false and remove wakeup-source (it's coming from rtc.yaml).

Best regards,
Krzysztof

#5 lore raw

PATCH v2 2/2 rtc: Introduce ti-k3-rtc

In reply to Nishanth Menon

Introduce support for Texas Instruments Real Time Clock controller on newer K3 family of SoCs such as AM62x.

The hardware module that is being supported is the "digital only" version which does'nt have capability of external wakeup sources and external power backup. However, for many practical applications, this should suffice as RTC is operational across low power sequences.

The hardware block by itself is split into two distinct domains internally to further reduce the power consumption with the actual counter block and comparators clocked off a 32k clock source (which based on SoC integration can be sourced by an external crystal) and an register interface block which is driven by the bus clock. While optimal from power perspective, it does create some complicated synchronizations and sequences that one must be wary of in the driver handling.

---
Changes since V1:
(Andrew's comments):
* Moved entirely to regmap fields - except for setting time, which I have documented as to why regmap is necessary
* Dropped the redundant MOD_ALIAS
(Vignesh's comments):
* poll_timeouts now in use.
* Dropped un-necessary prints around fence just before returning
* __maybe_unused for suspend/resume handlers
* Fixed up extra tab.
(Alexandre's comments):
* Reduced the verbosity of error messages to what is probably necessary to debug at field.

(other changes):
* Rebased to next-20220509, so updated Makefile to maintain alphabetical order.

V1: https://lore.kernel.org/all/[email protected]/

 drivers/rtc/Kconfig     |  11 +
 drivers/rtc/Makefile    |   1 +
 drivers/rtc/rtc-ti-k3.c | 688 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 700 insertions(+)
 create mode 100644 drivers/rtc/rtc-ti-k3.c
drivers/rtc/Kconfig +11 -0
index 41c65b4d2baf..fc57977b417c 100644
@@ -1922,6 +1922,17 @@ config RTC_DRV_ASPEED
 	  This driver can also be built as a module, if so, the module
 	  will be called "rtc-aspeed".
 
+config RTC_DRV_TI_K3
+	tristate "TI K3 RTC"
+	depends on ARCH_K3 || COMPILE_TEST
+	select REGMAP_MMIO
+	help
+	  If you say yes here you get support for the Texas Instruments's
+	  Real Time Clock for K3 architecture.
+
+	  This driver can also be built as a module, if so, the module
+	  will be called "rtc-ti-k3".
+
 comment "HID Sensor RTC drivers"
 
 config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
index 2d827d8261d5..d3d5964fe352 100644
@@ -171,6 +171,7 @@ obj-$(CONFIG_RTC_DRV_SUNPLUS)	+= rtc-sunplus.o
 obj-$(CONFIG_RTC_DRV_SUNXI)	+= rtc-sunxi.o
 obj-$(CONFIG_RTC_DRV_TEGRA)	+= rtc-tegra.o
 obj-$(CONFIG_RTC_DRV_TEST)	+= rtc-test.o
+obj-$(CONFIG_RTC_DRV_TI_K3)	+= rtc-ti-k3.o
 obj-$(CONFIG_RTC_DRV_TPS6586X)	+= rtc-tps6586x.o
 obj-$(CONFIG_RTC_DRV_TPS65910)	+= rtc-tps65910.o
 obj-$(CONFIG_RTC_DRV_TWL4030)	+= rtc-twl.o
drivers/rtc/rtc-ti-k3.c new file +688 -0

688 lines not on this page · raw message

Signature · 1 line
2.31.1
Acked-by on v2 2/2
#6 lore raw

Re: [PATCH V2 2/2] rtc: Introduce ti-k3-rtc

Quoted 16 lines · Nishanth Menon

Introduce support for Texas Instruments Real Time Clock controller on newer K3 family of SoCs such as AM62x.

The hardware module that is being supported is the "digital only" version which does'nt have capability of external wakeup sources and external power backup. However, for many practical applications, this should suffice as RTC is operational across low power sequences.

The hardware block by itself is split into two distinct domains internally to further reduce the power consumption with the actual counter block and comparators clocked off a 32k clock source (which based on SoC integration can be sourced by an external crystal) and an register interface block which is driven by the bus clock. While optimal from power perspective, it does create some complicated synchronizations and sequences that one must be wary of in the driver handling.

Quoted 7 lines

---
Changes since V1:
(Andrew's comments):
* Moved entirely to regmap fields - except for setting time, which I have documented as to why regmap is necessary
* Dropped the redundant MOD_ALIAS

Isn't regmap fun :)