Skip to contentSkip to conversation

rtc: sophgo: add rtc support for CV1800

PATCH Applied Alexander Sverdlin 3 participants 12 messages Mar 15, 2025 – May 7, 2025

Subsystems (3)

v14 of 15 Applied Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v14 cover rtc: sophgo: add rtc support for CV1800

Real Time Clock (RTC) is an independently powered module within the chip, which includes a 32KHz oscillator and a Power On Reset/POR submodule. It can be used for time display and timed alarm generation.

This series aims to provide complete DT bindings, but the drivers are only focusing on RTC implementation. Possible Power Management and remoteproc can be implemented later (hence the RTC driver is using syscon, because MMIO space is really interleaved among different functions).

Series is tested on Milk-V Duo Module 01 EVB (SG2000 SoC).

Changes since v13:
- Dropped MAINTAINERS drivers/soc/sophgo F: entry in favour of the existing N: entry
- mfd_cell and platform device names "cv1800-rtc" -> "cv1800b-rtc"
- Removed Cvitek brand from Kconfig
- cv1800-rtcsys.c not build by default if COMPILE_TEST

Changes since v12:
- Moved bindings and stub driver from MFD into SOC subsystem

Changes since v11:
- dropped restart handling (will be implemented in PSCI)
- split RTC driver into MFD stub and a platform RTC driver
- dropped Reviewed-by: Krzysztof Kozlowski from bindings, they've got a rework
- changed bindings maintainer from Jingbao Qiu <[email protected]> to [email protected]
- added link to TRM into bindings description
- bindings: mentioned 8051 core in the description
- bindings are now MFD, not RTC
- bindings: added "syscon" compatible
- bindings: added "interrupt-names", "clock-names" (because of added PM/remoteproc)
- bindings: main compatible "sophgo,cv1800-rtc" -> "sophgo,cv1800b-rtc"
- new patch "mfd: sophgo: cv1800: rtcsys: New driver (handling RTC only)"
- added both MFD and RTC drivers into MAINTAINERS file (N: K: entries didn't apply)
- RTC: depends on cv1800-rtcsys MFD driver
- RTC: use syscon for regmap
- RTC: get named clock from parent MFD
Changes since v10:
- only start RTC on set_time;
Changes since v9:
- further simplified bitmask macros;
- unconditional RTC start (rtc_enable_sec_counter()), otherwise didn't start on SG2000;
- dropped ANA_CALIB modification (has been forgotten in v8 with the drop of SW calibration to switch to HW calibration);
- successfully tested on SG2000;

Changes since v10:
- only start RTC on set_time;
- add machine restart handler (as separate patch 3/3);

Changes since v9:
- picked up orphaned series;
- further simplified bitmask macros;
- unconditional RTC start (rtc_enable_sec_counter());
- dropped ANA_CALIB modification;
- successfully tested on SG2000;

v9: https://lore.kernel.org/linux-riscv/[email protected]/

Changes since v8:
- delete unused macros
- using 0/1 instead of the DISABLE/ENABLE macro
- pass in the correct pointer when applying for IRQ
- convert the incoming pointer into an appropriate structure pointer in the irq handler

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

Changes since v7:
- pass checkpatch.pl --strict
- using u32 replace uint32
- using devm_kzalloc(*) replace devm_kzalloc(sizeof())
- sort header files alphabetically
- delete unnecessary header files
- fix wrap error
- drop dependent description
- using hardware automatic calibration replace software calibration. see documentation 197 page

v7: https://lore.kernel.org/all/[email protected]/
documentation: https://github.com/milkv-duo/duo-files/blob/main/duo/datasheet/CV1800B-CV1801B-Preliminary-Datasheet-full-en.pdf

Changes since v6:
- completely delete POR dt node
- remove syscon tag
- use devm_regmap_init_mmio() replace
syscon_node_to_regmap

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

Changes since v5:
- remove unnecessary lock
- fix cv1800_rtc_alarm_irq_enable()
- remove duplicate checks
- using alrm->enabled instead of unconditionally
enabling
- remove disable alarms on probe
- using rtc_update_irq() replace mess of alarm
- remove leak clk
- useing devm_rtc_allocate_device() and
devm_rtc_register_device() instead old way
- add judgment for rtc_enable_sec_counter()
- add POR nodes in DTS. This POR device shares
the register region with the RTC device

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

Changes since v4:
- remove POR dt-bindings because it empty
- remove MFD dt-bindings because SoC does
not have MFDs
- add syscon attribute to share registers
with POR

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

Changes since v3:
- temporarily not submitting RTC driver code
waiting for communication with IC designer
- add MFD dt-bindings
- add POR dt-bindings

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

Changes since v2:
- add mfd support for CV1800
- add rtc to mfd
- using regmap replace iomap
- merge register address in dts

v2: https://lore.kernel.org/lkml/[email protected]/

Changes since v1
- fix duplicate names in subject
- using RTC replace RTC controller
- improve the properties of dt-bindings
- using unevaluatedProperties replace additionalProperties
- dt-bindings passed the test
- using devm_platform_ioremap_resource() replace platform_get_resource() and devm_ioremap_resource()
- fix random order of the code
- fix wrong wrapping of the devm_request_irq() and map the flag with dts
- using devm_clk_get_enabled replace devm_clk_get() and clk_prepare_enable()
- fix return style
- add rtc clock calibration function
- use spinlock when write register on read/set time

v1: https://lore.kernel.org/lkml/[email protected]/

Alexander Sverdlin (1):
soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)

Jingbao Qiu (2):
dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
rtc: sophgo: add rtc support for Sophgo CV1800 SoC

 .../soc/sophgo/sophgo,cv1800b-rtc.yaml        |  86 +++++++
 MAINTAINERS                                   |   2 +
 drivers/rtc/Kconfig                           |  12 +
 drivers/rtc/Makefile                          |   1 +
 drivers/rtc/rtc-cv1800.c                      | 218 ++++++++++++++++++
 drivers/soc/Kconfig                           |   1 +
 drivers/soc/Makefile                          |   1 +
 drivers/soc/sophgo/Kconfig                    |  24 ++
 drivers/soc/sophgo/Makefile                   |   3 +
 drivers/soc/sophgo/cv1800-rtcsys.c            |  63 +++++
 10 files changed, 411 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml
 create mode 100644 drivers/rtc/rtc-cv1800.c
 create mode 100644 drivers/soc/sophgo/Kconfig
 create mode 100644 drivers/soc/sophgo/Makefile
 create mode 100644 drivers/soc/sophgo/cv1800-rtcsys.c
Signature · 1 line
2.48.1
#1 lore raw

PATCH v14 1/3 dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series

From: Jingbao Qiu <[email protected]>

Add RTC devicetree binding for Sophgo CV1800 series SoC. The device is called RTC, but contains control registers of other HW blocks in its address space, most notably of Power-on-Reset (PoR) module, DW8051 IP (MCU core), accompanying SRAM, hence putting it in SoC subsystem.

---
Changelog:
v14:
- no changes
v13:
- Moved bindings from MFD into SOC subsystem

v12:
- maintainer Jingbao Qiu <[email protected]> -> [email protected]
- dropped Reviewed-by: Krzysztof Kozlowski
- link to TRM
- mentioned 8051 core in the description
- binding is now MFD, not RTC
- added "syscon" compatible
- added "interrupt-names", "clock-names" (because of added PM/remoteproc)
- main compatible "sophgo,cv1800-rtc" -> "sophgo,cv1800b-rtc"

 .../soc/sophgo/sophgo,cv1800b-rtc.yaml        | 86 +++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml
Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml new file +86 -0
new file mode 100644
index 000000000000..5cf186c396c9
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sophgo/sophgo,cv1800b-rtc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Real Time Clock of the Sophgo CV1800 SoC
+
+description:
+  The RTC (Real Time Clock) is an independently powered module in the chip. It
+  contains a 32KHz oscillator and a Power-On-Reset (POR) sub-module, which can
+  be used for time display and scheduled alarm produce. In addition, the
+  hardware state machine provides triggering and timing control for chip
+  power-on, power-off and reset.
+
+  Furthermore, the 8051 subsystem is located within RTCSYS and is independently
+  powered. System software can use the 8051 to manage wake conditions and wake
+  the system while the system is asleep, and communicate with external devices
+  through peripheral controllers.
+
+  Technical Reference Manual available at
+    https://github.com/sophgo/sophgo-doc/tree/main/SG200X/TRM
+
+maintainers:
+  - [email protected]
+
+allOf:
+  - $ref: /schemas/rtc/rtc.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: sophgo,cv1800b-rtc
+      - const: syscon
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: RTC Alarm
+      - description: RTC Longpress
+      - description: VBAT DET
+
+  interrupt-names:
+    items:
+      - const: alarm
+      - const: longpress
+      - const: vbat
+
+  clocks:
+    items:
+      - description: RTC clock source
+      - description: DW8051 MCU clock source
+
+  clock-names:
+    items:
+      - const: rtc
+      - const: mcu
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-names
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/sophgo,cv1800.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    rtc@5025000 {
+        compatible = "sophgo,cv1800b-rtc", "syscon";
+        reg = <0x5025000 0x2000>;
+        interrupts = <17 IRQ_TYPE_LEVEL_HIGH>,
+                     <18 IRQ_TYPE_LEVEL_HIGH>,
+                     <19 IRQ_TYPE_LEVEL_HIGH>;
+        interrupt-names = "alarm", "longpress", "vbat";
+        clocks = <&clk CLK_RTC_25M>,
+                 <&clk CLK_SRC_RTC_SYS_0>;
+        clock-names = "rtc", "mcu";
+    };
Signature · 1 line
2.48.1
maintainer Reviewed-by on v14 1/3
#2 lore raw

Re: [PATCH v14 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series

Quoted 27 lines · Alexander Sverdlin

From: Jingbao Qiu <[email protected]>

Add RTC devicetree binding for Sophgo CV1800 series SoC. The device is called RTC, but contains control registers of other HW blocks in its address space, most notably of Power-on-Reset (PoR) module, DW8051 IP (MCU core), accompanying SRAM, hence putting it in SoC subsystem.

---
Changelog:
v14:
- no changes
v13:
- Moved bindings from MFD into SOC subsystem

v12:
- maintainer Jingbao Qiu <[email protected]> -> [email protected]
- dropped Reviewed-by: Krzysztof Kozlowski
- link to TRM
- mentioned 8051 core in the description
- binding is now MFD, not RTC
- added "syscon" compatible
- added "interrupt-names", "clock-names" (because of added PM/remoteproc)
- main compatible "sophgo,cv1800-rtc" -> "sophgo,cv1800b-rtc"

Quoted 3 lines
 .../soc/sophgo/sophgo,cv1800b-rtc.yaml        | 86 +++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml

LGTM.

#3 lore raw

PATCH v14 2/3 soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)

In reply to Alexander Sverdlin

Add driver for Sophgo CV1800 series SoC RTC subsystem. The RTC module comprises a 32kHz oscillator, Power-on-Reset (PoR) sub-module, HW state machine to control chip power-on, power-off and reset. Furthermore, the 8051 subsystem is located within RTCSYS including associated SRAM block.

This patch only populates RTC sub-device.

---
Changelog:
v14:
- Dropped MAINTAINERS F: entry in favour of the existing N: entry
- mfd_cell name "cv1800-rtc" -> "cv1800b-rtc"
- Removed Cvitek brand from Kconfig
- Not built by default if COMPILE_TEST
v13:
- Moved the driver from MFD into SOC subsystem
- Dropped unused "cv1800_rtcsys_rtc_subdev"
v12:
- new patch

 drivers/soc/Kconfig                |  1 +
 drivers/soc/Makefile               |  1 +
 drivers/soc/sophgo/Kconfig         | 23 ++++++++++++
 drivers/soc/sophgo/Makefile        |  3 ++
 drivers/soc/sophgo/cv1800-rtcsys.c | 63 ++++++++++++++++++++++++++++++
 6 files changed, 93 insertions(+)
 create mode 100644 drivers/soc/sophgo/Kconfig
 create mode 100644 drivers/soc/sophgo/Makefile
 create mode 100644 drivers/soc/sophgo/cv1800-rtcsys.c
drivers/soc/Kconfig +1 -0
index 6a8daeb8c4b9..11e2383c0654 100644
@@ -23,6 +23,7 @@ source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/renesas/Kconfig"
 source "drivers/soc/rockchip/Kconfig"
 source "drivers/soc/samsung/Kconfig"
+source "drivers/soc/sophgo/Kconfig"
 source "drivers/soc/sunxi/Kconfig"
 source "drivers/soc/tegra/Kconfig"
 source "drivers/soc/ti/Kconfig"
drivers/soc/Makefile +1 -0
index 2037a8695cb2..0381a0abdec8 100644
@@ -29,6 +29,7 @@ obj-y				+= qcom/
 obj-y				+= renesas/
 obj-y				+= rockchip/
 obj-$(CONFIG_SOC_SAMSUNG)	+= samsung/
+obj-y				+= sophgo/
 obj-y				+= sunxi/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-y				+= ti/
drivers/soc/sophgo/Kconfig new file +23 -0
new file mode 100644
index 000000000000..e50666e423a9
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Sophgo SoC drivers
+#
+
+if ARCH_SOPHGO || COMPILE_TEST
+menu "Sophgo SoC drivers"
+
+config SOPHGO_CV1800_RTCSYS
+	tristate "Sophgo CV1800 RTC MFD"
+	select MFD_CORE
+	help
+	  If you say yes here you get support the RTC MFD driver for Sophgo
+	  CV1800 series SoC. The RTC module comprises a 32kHz oscillator,
+	  Power-on-Reset (PoR) sub-module, HW state machine to control chip
+	  power-on, power-off and reset. Furthermore, the 8051 subsystem is
+	  located within RTCSYS including associated SRAM block.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called cv1800-rtcsys.
+
+endmenu
+endif
drivers/soc/sophgo/Makefile new file +3 -0
new file mode 100644
index 000000000000..8f22b4e79311
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SOPHGO_CV1800_RTCSYS)	+= cv1800-rtcsys.o
drivers/soc/sophgo/cv1800-rtcsys.c new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.48.1
maintainer Reviewed-by on v14 2/3
#4 lore raw

Re: [PATCH v14 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)

Quoted 21 lines · Alexander Sverdlin

Add driver for Sophgo CV1800 series SoC RTC subsystem. The RTC module comprises a 32kHz oscillator, Power-on-Reset (PoR) sub-module, HW state machine to control chip power-on, power-off and reset. Furthermore, the 8051 subsystem is located within RTCSYS including associated SRAM block.

This patch only populates RTC sub-device.

---
Changelog:
v14:
- Dropped MAINTAINERS F: entry in favour of the existing N: entry
- mfd_cell name "cv1800-rtc" -> "cv1800b-rtc"
- Removed Cvitek brand from Kconfig
- Not built by default if COMPILE_TEST
v13:
- Moved the driver from MFD into SOC subsystem
- Dropped unused "cv1800_rtcsys_rtc_subdev"
v12:
- new patch

Quoted 10 lines
 drivers/soc/Kconfig                |  1 +
 drivers/soc/Makefile               |  1 +
 drivers/soc/sophgo/Kconfig         | 23 ++++++++++++
 drivers/soc/sophgo/Makefile        |  3 ++
 drivers/soc/sophgo/cv1800-rtcsys.c | 63 ++++++++++++++++++++++++++++++
 6 files changed, 93 insertions(+)
 create mode 100644 drivers/soc/sophgo/Kconfig
 create mode 100644 drivers/soc/sophgo/Makefile
 create mode 100644 drivers/soc/sophgo/cv1800-rtcsys.c

LGTM.

#5 lore raw

PATCH v14 3/3 rtc: sophgo: add rtc support for Sophgo CV1800 SoC

In reply to Alexander Sverdlin

From: Jingbao Qiu <[email protected]>

Implement the RTC driver for CV1800, which able to provide time alarm.

---
Changelog:
v14:
- platform device name "cv1800-rtc" -> "cv1800b-rtc"
v13:
- Change in the Kconfig dependency caused by the move of the previous patch from MFD into SOC
v12:
- added MAINTAINERS entry
- depends on cv1800-rtcsys MFD driver
- use syscon for regmap
- get named clock from parent MFD
- corresponding platform device is expected to be instantiated by MFD stub Changes since v10:
- only start RTC on set_time;
Changes since v9:
- further simplified bitmask macros;
- unconditional RTC start (rtc_enable_sec_counter()), otherwise didn't start on SG2000;
- dropped ANA_CALIB modification (has been forgotten in v8 with the drop of SW calibration to switch to HW calibration);
- successfully tested on SG2000;

 MAINTAINERS              |   1 +
 drivers/rtc/Kconfig      |  12 +++
 drivers/rtc/Makefile     |   1 +
 drivers/rtc/rtc-cv1800.c | 218 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 232 insertions(+)
 create mode 100644 drivers/rtc/rtc-cv1800.c
MAINTAINERS +1 -0
index ac15e448fffb..be8fee50a49c 100644
@@ -22354,6 +22354,7 @@ L:	[email protected]
 W:	https://github.com/sophgo/linux/wiki
 T:	git https://github.com/sophgo/linux.git
 S:	Maintained
+F:	drivers/rtc/rtc-cv1800.c
 N:	sophgo
 K:	sophgo
 
drivers/rtc/Kconfig +12 -0
index 0bbbf778ecfa..46593103db11 100644
@@ -1395,6 +1395,18 @@ config RTC_DRV_ASM9260
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-asm9260.
 
+config RTC_DRV_CV1800
+	tristate "Sophgo CV1800 RTC"
+	depends on SOPHGO_CV1800_RTCSYS || COMPILE_TEST
+	select MFD_SYSCON
+	select REGMAP
+	help
+	  If you say yes here you get support the RTC driver for Sophgo CV1800
+	  series SoC.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called rtc-cv1800.
+
 config RTC_DRV_DIGICOLOR
 	tristate "Conexant Digicolor RTC"
 	depends on ARCH_DIGICOLOR || COMPILE_TEST
drivers/rtc/Makefile +1 -0
index 489b4ab07068..621b30a33dda 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_RTC_DRV_CADENCE)	+= rtc-cadence.o
 obj-$(CONFIG_RTC_DRV_CMOS)	+= rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_CPCAP)	+= rtc-cpcap.o
 obj-$(CONFIG_RTC_DRV_CROS_EC)	+= rtc-cros-ec.o
+obj-$(CONFIG_RTC_DRV_CV1800)	+= rtc-cv1800.o
 obj-$(CONFIG_RTC_DRV_DA9052)	+= rtc-da9052.o
 obj-$(CONFIG_RTC_DRV_DA9055)	+= rtc-da9055.o
 obj-$(CONFIG_RTC_DRV_DA9063)	+= rtc-da9063.o
drivers/rtc/rtc-cv1800.c new file +218 -0

218 lines not on this page · raw message

Signature · 1 line
2.48.1
#6 lore raw

Re: [PATCH v14 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC

Hi, Inochi,

I see Alexander add "drivers/rtc/rtc-cv1800.c" in "SOPHGO DEVICETREES and DRIVERS" of MAINTAINERS, would you like to take this?

Regards,

Chen

Quoted 48 lines · Alexander Sverdlin

From: Jingbao Qiu <[email protected]>

Implement the RTC driver for CV1800, which able to provide time alarm.

---
Changelog:
v14:
- platform device name "cv1800-rtc" -> "cv1800b-rtc"
v13:
- Change in the Kconfig dependency caused by the move of the previous patch from MFD into SOC
v12:
- added MAINTAINERS entry
- depends on cv1800-rtcsys MFD driver
- use syscon for regmap
- get named clock from parent MFD
- corresponding platform device is expected to be instantiated by MFD stub Changes since v10:
- only start RTC on set_time;
Changes since v9:
- further simplified bitmask macros;
- unconditional RTC start (rtc_enable_sec_counter()), otherwise didn't start on SG2000;
- dropped ANA_CALIB modification (has been forgotten in v8 with the drop of SW calibration to switch to HW calibration);
- successfully tested on SG2000;

  MAINTAINERS              |   1 +
  drivers/rtc/Kconfig      |  12 +++
  drivers/rtc/Makefile     |   1 +
  drivers/rtc/rtc-cv1800.c | 218 +++++++++++++++++++++++++++++++++++++++
  4 files changed, 232 insertions(+)

create mode 100644 drivers/rtc/rtc-cv1800.c

MAINTAINERS +1 -0
index ac15e448fffb..be8fee50a49c 100644
@@ -22354,6 +22354,7 @@ L:	[email protected]
  W:	https://github.com/sophgo/linux/wiki
  T:	git https://github.com/sophgo/linux.git
  S:	Maintained
+F:	drivers/rtc/rtc-cv1800.c
  N:	sophgo
  K:	sophgo

[......]

maintainer
#7 lore raw

Re: [PATCH v14 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC

Quoted 9 lines · Chen Wang

Hi, Inochi,

I see Alexander add "drivers/rtc/rtc-cv1800.c" in "SOPHGO DEVICETREES and DRIVERS" of MAINTAINERS, would you like to take this?

Regards,

Chen

If it is not covered by our entry. It is fine for me to take it.

Regards,
Inochi

#8 lore raw

Re: [PATCH v14 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC

In reply to Chen Wang

Hi, Alexander Sverdlin,

I just find there is an exiting "REAL TIME CLOCK (RTC) SUBSYSTEM" section in MAINTAINERS, seems we should not pick the rtc file in "SOPHGO DEVICETREES and DRIVERS".

Chen

Quoted 63 lines · Chen Wang

Hi, Inochi,

I see Alexander add "drivers/rtc/rtc-cv1800.c" in "SOPHGO DEVICETREES and DRIVERS" of MAINTAINERS, would you like to take this?

Regards,

Chen

Quoted 49 lines · Alexander Sverdlin

From: Jingbao Qiu <[email protected]>

Implement the RTC driver for CV1800, which able to provide time alarm.

---
Changelog:
v14:
- platform device name "cv1800-rtc" -> "cv1800b-rtc"
v13:
- Change in the Kconfig dependency caused by the move of the previous patch from MFD into SOC
v12:
- added MAINTAINERS entry
- depends on cv1800-rtcsys MFD driver
- use syscon for regmap
- get named clock from parent MFD
- corresponding platform device is expected to be instantiated by MFD stub
Changes since v10:
- only start RTC on set_time;
Changes since v9:
- further simplified bitmask macros;
- unconditional RTC start (rtc_enable_sec_counter()), otherwise didn't start on SG2000;
- dropped ANA_CALIB modification (has been forgotten in v8 with the drop of SW calibration to switch to HW calibration);
- successfully tested on SG2000;

  MAINTAINERS              |   1 +
  drivers/rtc/Kconfig      |  12 +++
  drivers/rtc/Makefile     |   1 +
  drivers/rtc/rtc-cv1800.c | 218 +++++++++++++++++++++++++++++++++++++++

  4 files changed, 232 insertions(+)

  create mode 100644 drivers/rtc/rtc-cv1800.c

MAINTAINERS +0 -0
index ac15e448fffb..be8fee50a49c 100644
@@ -22354,6 +22354,7 @@ L:    [email protected]

  W:    https://github.com/sophgo/linux/wiki
  T:    git https://github.com/sophgo/linux.git
  S:    Maintained
+F:    drivers/rtc/rtc-cv1800.c
  N:    sophgo
  K:    sophgo

[......]

#9 lore raw

Re: [PATCH v14 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC

Hi Chen!

Quoted 3 lines · Chen Wang

I just find there is an exiting "REAL TIME CLOCK (RTC) SUBSYSTEM" section in MAINTAINERS, seems we should not pick the rtc file in "SOPHGO DEVICETREES and DRIVERS".

But then the below mailing list will not get notified on the changes to Sophgo-specific RTC driver. I'd say it's rather about providing timely feedback, like Tested-by: and Reviewed-by: than any other more serious burden. What do you think?

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
MAINTAINERS +0 -0
@@ -22354,6 +22354,7 @@ L:    [email protected]

  W:    https://github.com/sophgo/linux/wiki
  T:    git https://github.com/sophgo/linux.git
  S:    Maintained
+F:    drivers/rtc/rtc-cv1800.c
  N:    sophgo
  K:    sophgo

Signature · 1 line
Alexander Sverdlin.
#10 lore raw

Re: [PATCH v14 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC

Hi, Alexander,

Quoted 10 lines · Alexander Sverdlin

Hi Chen!

Quoted 3 lines · Chen Wang

I just find there is an exiting "REAL TIME CLOCK (RTC) SUBSYSTEM" section in MAINTAINERS, seems we should not pick the rtc file in "SOPHGO DEVICETREES and DRIVERS".

But then the below mailing list will not get notified on the changes to Sophgo-specific RTC driver. I'd say it's rather about providing timely feedback, like Tested-by: and Reviewed-by: than any other more serious burden. What do you think?

The rtc driver, especially the cv18xx rtc driver, is not a special case. Other sophgo drivers have not been added like this. If it is required to draw the attention of those who need it, we can copy [email protected] when submitting patches.

In addition, regarding the rtc driver, it has not been determined whether we are responsible for the PR or the RTC subsystem. I suggest to discuss this when it is determined.

Regards,

Chen

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
MAINTAINERS +1 -0
@@ -22354,6 +22354,7 @@ L:    [email protected]
   W:    https://github.com/sophgo/linux/wiki
   T:    git https://github.com/sophgo/linux.git
   S:    Maintained
+F:    drivers/rtc/rtc-cv1800.c
   N:    sophgo
   K:    sophgo
maintainer Applied
#11 lore raw

Re: (subset) [PATCH v14 0/3] rtc: sophgo: add rtc support for CV1800

In reply to Alexander Sverdlin
Quoted 10 lines · Alexander Sverdlin

Real Time Clock (RTC) is an independently powered module within the chip, which includes a 32KHz oscillator and a Power On Reset/POR submodule. It can be used for time display and timed alarm generation.

This series aims to provide complete DT bindings, but the drivers are only focusing on RTC implementation. Possible Power Management and remoteproc can be implemented later (hence the RTC driver is using syscon, because MMIO space is really interleaved among different functions).

[...]

Applied to soc-for-next, thanks!

[1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series

      https://github.com/sophgo/linux/commit/76517429dbfd8eca16fe85482cdb8024bbbd06bd
[2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
      https://github.com/sophgo/linux/commit/c8754c7deab4cbfa947fa2d656cbaf83771828ef

Thanks,
Inochi