rtc: Add StarFive JH7110 RTC support
Subsystems (4)
v3 cover rtc: Add StarFive JH7110 RTC support
The JH7110 has an RTC in its always-on domain that mainline does not support. This series adds a binding, a driver, a MAINTAINERS entry and the SoC DT node.
The driver is based on the StarFive vendor driver (rtc-starfive.c, commit ebac2b5 in the StarFive 6.12 tree), reworked for mainline:
- hardware calibration and the default time set in probe are dropped
- wakeup uses the generic wake IRQ helpers instead of the irq_desc hack
- set_time waits for the counter to load the new time
- read_time re-reads if the time rolls over between TIME and DATE
- the offset rounds to the nearest step and follows the sysfs sign convention (positive = slower)
- the 32.768 kHz counter clock is described in the binding and enabled
Thanks to ziv.xu and Hal Feng at StarFive for the original driver.
Tested on a VisionFive 2 v1.3B with next-20261105 and v7.3.1: setting and reading the time across the 2000-2099 range (out-of-range years refused), leap day and century rollover, the alarm interrupt with cancel, the offset, the rate over 60 s, and setting the system clock at boot. Not tested: suspend wakeup, drift over hours, and keeping time across a power-off, as the board has no RTC battery connector.
Known behaviour: the RTC loses about the length of a reboot across a warm reboot; the counter appears to stop during reset. After the StarFive vendor kernel the first boot found an invalid time. I would appreciate an opinion on whether this is expected of the hardware or something the driver should handle.
Changes in v3:
- dt-bindings: add Conor's Acked-by
- driver: add my copyright line; drop the extra space before the register bit field defines (as requested by E Shattow)
- dts: rename the node label from rtc to soc_rtc, leaving rtc free for a carrier board's RTC (as requested by E Shattow)
Changes in v2:
- dt-bindings: list myself as maintainer instead of the RTC subsystem maintainer (as requested by Conor)
- MAINTAINERS: new patch adding an entry for the driver & binding
- driver: drop the <linux/mod_devicetable.h> include (as requested by Uwe)
v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
Owen O'Hehir (3):
dt-bindings: rtc: Add StarFive JH7110 RTC
MAINTAINERS: Add entry for the StarFive JH7110 RTC driver
riscv: dts: starfive: jh7110: Add the RTC node
ziv.xu (1):
rtc: Add StarFive JH7110 RTC driver
.../bindings/rtc/starfive,jh7110-rtc.yaml | 85 +++++ MAINTAINERS | 7 + arch/riscv/boot/dts/starfive/jh7110.dtsi | 14 + drivers/rtc/Kconfig | 11 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-jh7110.c | 324 ++++++++++++++++++ 6 files changed, 442 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/starfive,jh7110-rtc.yaml create mode 100644 drivers/rtc/rtc-jh7110.c
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b
Signature · 1 line
2.43.0
PATCH v3 1/4 dt-bindings: rtc: Add StarFive JH7110 RTC
Describe the RTC in the always-on domain of the StarFive JH7110 SoC.
--- .../bindings/rtc/starfive,jh7110-rtc.yaml | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/starfive,jh7110-rtc.yaml
Documentation/devicetree/bindings/rtc/starfive,jh7110-rtc.yaml new file +85 -0
@@ -0,0 +1,85 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/starfive,jh7110-rtc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 Real Time Clock + +maintainers: + - Owen O'Hehir <[email protected]> + +description: + The RTC in the always-on domain of the StarFive JH7110 SoC. It counts BCD + time and date from a 32.768 kHz clock and has an alarm, a frequency offset + adjustment and millisecond and one-second pulse outputs. + +allOf: + - $ref: rtc.yaml# + +properties: + compatible: + const: starfive,jh7110-rtc + + reg: + maxItems: 1 + + interrupts: + items: + - description: Millisecond pulse + - description: One-second pulse + - description: Alarm and calibration events + + interrupt-names: + items: + - const: ms-pulse + - const: sec-pulse + - const: rtc + + clocks: + items: + - description: APB bus clock + - description: Calibration reference clock + - description: 32.768 kHz counter clock + + clock-names: + items: + - const: apb + - const: cal + - const: 32k + + resets: + items: + - description: 32.768 kHz counter domain reset + - description: APB bus reset + - description: Calibration reset + +required: + - compatible + - reg + - interrupts + - interrupt-names + - clocks + - clock-names + - resets + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/starfive,jh7110-crg.h> + #include <dt-bindings/reset/starfive,jh7110-crg.h> + + rtc@17040000 { + compatible = "starfive,jh7110-rtc"; + reg = <0x17040000 0x10000>; + interrupts = <10>, <11>, <12>; + interrupt-names = "ms-pulse", "sec-pulse", "rtc"; + clocks = <&aoncrg JH7110_AONCLK_RTC_APB>, + <&aoncrg JH7110_AONCLK_RTC_CAL>, + <&aoncrg JH7110_AONCLK_RTC_32K>; + clock-names = "apb", "cal", "32k"; + resets = <&aoncrg JH7110_AONRST_RTC_32K>, + <&aoncrg JH7110_AONRST_RTC_APB>, + <&aoncrg JH7110_AONRST_RTC_CAL>; + };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 1/4] dt-bindings: rtc: Add StarFive JH7110 RTC
Sashiko has reviewed this patch and found no issues.
Quoted 3 lines
Describe the RTC in the always-on domain of the StarFive JH7110 SoC.
Signed-off-by Owen O'Hehir <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v3 2/4 rtc: Add StarFive JH7110 RTC driver
In reply to Owen O'HehirFrom: "ziv.xu" <[email protected]>
Add a driver for the RTC in the always-on domain of the StarFive JH7110 SoC. It supports time, alarm with wakeup, and the frequency offset.
[Owen: rework of the StarFive vendor driver for mainline: drop hardware
calibration & the default time set in probe, use the generic wake IRQ helpers, wait for the update bit in set_time, re-read a time that rolls over during the read, round the offset to the nearest step & follow the sysfs offset sign, enable the 32k counter clock]
--- drivers/rtc/Kconfig | 11 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-jh7110.c | 324 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 336 insertions(+) create mode 100644 drivers/rtc/rtc-jh7110.c
drivers/rtc/Kconfig +11 -0
@@ -1807,6 +1807,17 @@ config RTC_DRV_MPC5121 This driver can also be built as a module. If so, the module will be called rtc-mpc5121. +config RTC_DRV_JH7110 + tristate "StarFive JH7110 RTC" + depends on ARCH_STARFIVE || COMPILE_TEST + help + If you say yes here you get support for the RTC in the always-on + domain of StarFive JH7110 SoCs, with alarm and frequency offset + support. + + This driver can also be built as a module. If so, the module + will be called rtc-jh7110. + config RTC_DRV_JZ4740 tristate "Ingenic JZ4740 SoC" depends on MIPS || COMPILE_TEST
drivers/rtc/Makefile +1 -0
@@ -82,6 +82,7 @@ obj-$(CONFIG_RTC_DRV_IMX_BBM_SCMI) += rtc-imx-sm-bbm.o obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o +obj-$(CONFIG_RTC_DRV_JH7110) += rtc-jh7110.o obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o obj-$(CONFIG_RTC_DRV_LOONGSON) += rtc-loongson.o obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o
drivers/rtc/rtc-jh7110.c new file +324 -0
324 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 2/4] rtc: Add StarFive JH7110 RTC driver
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
From: "ziv.xu" <[email protected]>
Add a driver for the RTC in the always-on domain of the StarFive JH7110 SoC. It supports time, alarm with wakeup, and the frequency offset.
Signed-off-by ziv.xu <[email protected]>Signed-off-by Hal Feng <[email protected]>
Quoted 7 lines
[Owen: rework of the StarFive vendor driver for mainline: drop hardware
calibration & the default time set in probe, use the generic wake IRQ helpers, wait for the update bit inset_time, re-read a time that rolls over during the read, round the offset to the nearest step & follow the sysfs offset sign, enable the 32k counter clock]Co-developed-by Owen O'Hehir <[email protected]>Signed-off-by Owen O'Hehir <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v3 3/4 MAINTAINERS: Add entry for the StarFive JH7110 RTC driver
In reply to Owen O'HehirAdd myself as maintainer of the StarFive JH7110 RTC driver and its binding.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -26877,6 +26877,13 @@ S: Supported F: Documentation/devicetree/bindings/sound/starfive,jh7110-pwmdac.yaml F: sound/soc/starfive/jh7110_pwmdac.c +STARFIVE JH7110 RTC DRIVER +M: Owen O'Hehir <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/rtc/starfive,jh7110-rtc.yaml +F: drivers/rtc/rtc-jh7110.c + STARFIVE JH7110 SYSCON M: William Qiu <[email protected]> M: Xingyu Wu <[email protected]>
Signature · 1 line
2.43.0
PATCH v3 4/4 riscv: dts: starfive: jh7110: Add the RTC node
In reply to Owen O'HehirTested on a VisionFive 2 v1.3B.
--- arch/riscv/boot/dts/starfive/jh7110.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/riscv/boot/dts/starfive/jh7110.dtsi +14 -0
@@ -1206,6 +1206,20 @@ pwrc: power-controller@17030000 { #power-domain-cells = <1>; }; + soc_rtc: rtc@17040000 { + compatible = "starfive,jh7110-rtc"; + reg = <0x0 0x17040000 0x0 0x10000>; + interrupts = <10>, <11>, <12>; + interrupt-names = "ms-pulse", "sec-pulse", "rtc"; + clocks = <&aoncrg JH7110_AONCLK_RTC_APB>, + <&aoncrg JH7110_AONCLK_RTC_CAL>, + <&aoncrg JH7110_AONCLK_RTC_32K>; + clock-names = "apb", "cal", "32k"; + resets = <&aoncrg JH7110_AONRST_RTC_32K>, + <&aoncrg JH7110_AONRST_RTC_APB>, + <&aoncrg JH7110_AONRST_RTC_CAL>; + }; + csi2rx: csi@19800000 { compatible = "starfive,jh7110-csi2rx", "cdns,csi2rx"; reg = <0x0 0x19800000 0x0 0x10000>;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 4/4] riscv: dts: starfive: jh7110: Add the RTC node
Sashiko has reviewed this patch and found no issues.
Quoted 3 lines
Tested on a VisionFive 2 v1.3B.
Signed-off-by Owen O'Hehir <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4