* [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
2025-03-09 20:26 [PATCH v13 0/3] rtc: sophgo: add rtc support for CV1800 Alexander Sverdlin
@ 2025-03-09 20:26 ` Alexander Sverdlin
2025-03-10 9:13 ` Krzysztof Kozlowski
2025-04-07 1:09 ` Inochi Amaoto
2025-03-09 20:26 ` [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only) Alexander Sverdlin
2025-03-09 20:26 ` [PATCH v13 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC Alexander Sverdlin
2 siblings, 2 replies; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-09 20:26 UTC (permalink / raw)
To: sophgo, devicetree, linux-rtc
Cc: Jingbao Qiu, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen Wang, Inochi Amaoto, Alexandre Belloni, Arnd Bergmann,
Yangyu Chen, linux-kernel, Alexander Sverdlin
From: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
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.
Signed-off-by: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Changelog:
v13:
- Moved bindings from MFD into SOC subsystem
v12:
- maintainer Jingbao Qiu <qiujingbao.dlmu@gmail.com> -> sophgo@lists.linux.dev
- 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
diff --git a/Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml b/Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml
new file mode 100644
index 000000000000..5cf186c396c9
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/sophgo/sophgo,cv1800b-rtc.yaml
@@ -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:
+ - sophgo@lists.linux.dev
+
+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";
+ };
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
2025-03-09 20:26 ` [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series Alexander Sverdlin
@ 2025-03-10 9:13 ` Krzysztof Kozlowski
2025-04-07 1:09 ` Inochi Amaoto
1 sibling, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-10 9:13 UTC (permalink / raw)
To: Alexander Sverdlin
Cc: sophgo, devicetree, linux-rtc, Jingbao Qiu, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Chen Wang, Inochi Amaoto,
Alexandre Belloni, Arnd Bergmann, Yangyu Chen, linux-kernel
On Sun, Mar 09, 2025 at 09:26:23PM +0100, Alexander Sverdlin wrote:
> From: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
>
> 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.
>
> Signed-off-by: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> Changelog:
> v13:
> - Moved bindings from MFD into SOC subsystem
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
2025-03-09 20:26 ` [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series Alexander Sverdlin
2025-03-10 9:13 ` Krzysztof Kozlowski
@ 2025-04-07 1:09 ` Inochi Amaoto
2025-04-07 5:29 ` Alexander Sverdlin
1 sibling, 1 reply; 19+ messages in thread
From: Inochi Amaoto @ 2025-04-07 1:09 UTC (permalink / raw)
To: Alexander Sverdlin, sophgo, devicetree, linux-rtc
Cc: Jingbao Qiu, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen Wang, Inochi Amaoto, Alexandre Belloni, Arnd Bergmann,
Yangyu Chen, linux-kernel
On Sun, Mar 09, 2025 at 09:26:23PM +0100, Alexander Sverdlin wrote:
> From: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
>
> 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.
>
I think this is a mfd device, so why not moving this into mfd subsystem?
Regards,
Inochi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
2025-04-07 1:09 ` Inochi Amaoto
@ 2025-04-07 5:29 ` Alexander Sverdlin
2025-04-07 23:34 ` Inochi Amaoto
0 siblings, 1 reply; 19+ messages in thread
From: Alexander Sverdlin @ 2025-04-07 5:29 UTC (permalink / raw)
To: Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: Jingbao Qiu, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen Wang, Alexandre Belloni, Arnd Bergmann, Yangyu Chen,
linux-kernel
Hi Inochi!
On Mon, 2025-04-07 at 09:09 +0800, Inochi Amaoto wrote:
> > 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.
> >
>
> I think this is a mfd device, so why not moving this into mfd subsystem?
MFD is by far the most tricky subsystem to get into [1] ;-)
SOC looks much more realistic [2]
[1] https://lore.kernel.org/all/20250306003211.GA8350@google.com/
[2] https://lore.kernel.org/all/20250303-loud-mauve-coyote-1eefbb@krzk-bin/
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
2025-04-07 5:29 ` Alexander Sverdlin
@ 2025-04-07 23:34 ` Inochi Amaoto
2025-04-09 5:49 ` Chen Wang
0 siblings, 1 reply; 19+ messages in thread
From: Inochi Amaoto @ 2025-04-07 23:34 UTC (permalink / raw)
To: Alexander Sverdlin, Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: Jingbao Qiu, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen Wang, Alexandre Belloni, Arnd Bergmann, Yangyu Chen,
linux-kernel
On Mon, Apr 07, 2025 at 07:29:37AM +0200, Alexander Sverdlin wrote:
> Hi Inochi!
>
> On Mon, 2025-04-07 at 09:09 +0800, Inochi Amaoto wrote:
> > > 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.
> > >
> >
> > I think this is a mfd device, so why not moving this into mfd subsystem?
>
> MFD is by far the most tricky subsystem to get into [1] ;-)
> SOC looks much more realistic [2]
>
> [1] https://lore.kernel.org/all/20250306003211.GA8350@google.com/
> [2] https://lore.kernel.org/all/20250303-loud-mauve-coyote-1eefbb@krzk-bin/
>
Cool, let's keep it.
LGTM.
Reviewed-by: Inochi Amaoto <inochiama@gmail.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series
2025-04-07 23:34 ` Inochi Amaoto
@ 2025-04-09 5:49 ` Chen Wang
0 siblings, 0 replies; 19+ messages in thread
From: Chen Wang @ 2025-04-09 5:49 UTC (permalink / raw)
To: Inochi Amaoto
Cc: Jingbao Qiu, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Alexandre Belloni, Arnd Bergmann, Yangyu Chen, linux-kernel,
Alexander Sverdlin, sophgo, devicetree, linux-rtc
On 2025/4/8 7:34, Inochi Amaoto wrote:
> On Mon, Apr 07, 2025 at 07:29:37AM +0200, Alexander Sverdlin wrote:
>> Hi Inochi!
>>
>> On Mon, 2025-04-07 at 09:09 +0800, Inochi Amaoto wrote:
>>>> 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.
>>>>
>>> I think this is a mfd device, so why not moving this into mfd subsystem?
>> MFD is by far the most tricky subsystem to get into [1] ;-)
>> SOC looks much more realistic [2]
>>
>> [1] https://lore.kernel.org/all/20250306003211.GA8350@google.com/
>> [2] https://lore.kernel.org/all/20250303-loud-mauve-coyote-1eefbb@krzk-bin/
>>
> Cool, let's keep it.
>
> LGTM.
>
> Reviewed-by: Inochi Amaoto <inochiama@gmail.com>
Hi, Inochi
I think you were not reviewing the latest version of this patchset. The
latest version is v14
@https://lore.kernel.org/linux-rtc/20250315224921.3627852-1-alexander.sverdlin@gmail.com/
Chen
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-09 20:26 [PATCH v13 0/3] rtc: sophgo: add rtc support for CV1800 Alexander Sverdlin
2025-03-09 20:26 ` [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series Alexander Sverdlin
@ 2025-03-09 20:26 ` Alexander Sverdlin
2025-03-14 0:51 ` Inochi Amaoto
2025-03-09 20:26 ` [PATCH v13 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC Alexander Sverdlin
2 siblings, 1 reply; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-09 20:26 UTC (permalink / raw)
To: sophgo, devicetree, linux-rtc
Cc: Alexander Sverdlin, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen Wang, Inochi Amaoto, Alexandre Belloni,
Jingbao Qiu, Arnd Bergmann, Yangyu Chen, linux-kernel
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.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Changelog:
v13:
- Moved the driver from MFD into SOC subsystem
- Dropped unused "cv1800_rtcsys_rtc_subdev"
v12:
- new patch
MAINTAINERS | 1 +
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 ++++++++++++++++++++++++++++++
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
diff --git a/MAINTAINERS b/MAINTAINERS
index 3eee238c2ea2..ac15e448fffb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
W: https://github.com/sophgo/linux/wiki
T: git https://github.com/sophgo/linux.git
S: Maintained
+F: drivers/soc/sophgo/cv1800-rtcsys.c
N: sophgo
K: sophgo
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 6a8daeb8c4b9..11e2383c0654 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -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"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 2037a8695cb2..0381a0abdec8 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -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/
diff --git a/drivers/soc/sophgo/Kconfig b/drivers/soc/sophgo/Kconfig
new file mode 100644
index 000000000000..e50666e423a9
--- /dev/null
+++ b/drivers/soc/sophgo/Kconfig
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Sophgo/Cvitek SoC drivers
+#
+
+if ARCH_SOPHGO || COMPILE_TEST
+menu "Sophgo/Cvitek SoC drivers"
+
+config SOPHGO_CV1800_RTCSYS
+ tristate "Sophgo CV1800 RTC MFD"
+ default y if COMPILE_TEST
+ 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
diff --git a/drivers/soc/sophgo/Makefile b/drivers/soc/sophgo/Makefile
new file mode 100644
index 000000000000..8f22b4e79311
--- /dev/null
+++ b/drivers/soc/sophgo/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SOPHGO_CV1800_RTCSYS) += cv1800-rtcsys.o
diff --git a/drivers/soc/sophgo/cv1800-rtcsys.c b/drivers/soc/sophgo/cv1800-rtcsys.c
new file mode 100644
index 000000000000..cb271f02afcc
--- /dev/null
+++ b/drivers/soc/sophgo/cv1800-rtcsys.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * 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.
+ *
+ * Copyright (C) 2025 Alexander Sverdlin <alexander.sverdlin@gmail.com>
+ *
+ */
+
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/property.h>
+
+static struct resource cv1800_rtcsys_irq_resources[] = {
+ DEFINE_RES_IRQ_NAMED(0, "alarm"),
+};
+
+static const struct mfd_cell cv1800_rtcsys_subdev[] = {
+ {
+ .name = "cv1800-rtc",
+ .num_resources = 1,
+ .resources = &cv1800_rtcsys_irq_resources[0],
+ },
+};
+
+static int cv1800_rtcsys_probe(struct platform_device *pdev)
+{
+ int irq;
+
+ irq = platform_get_irq_byname(pdev, "alarm");
+ if (irq < 0)
+ return irq;
+ cv1800_rtcsys_irq_resources[0].start = irq;
+ cv1800_rtcsys_irq_resources[0].end = irq;
+
+ return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
+ cv1800_rtcsys_subdev,
+ ARRAY_SIZE(cv1800_rtcsys_subdev),
+ NULL, 0, NULL);
+}
+
+static const struct of_device_id cv1800_rtcsys_of_match[] = {
+ { .compatible = "sophgo,cv1800b-rtc" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cv1800_rtcsys_of_match);
+
+static struct platform_driver cv1800_rtcsys_mfd = {
+ .probe = cv1800_rtcsys_probe,
+ .driver = {
+ .name = "cv1800_rtcsys",
+ .of_match_table = cv1800_rtcsys_of_match,
+ },
+};
+module_platform_driver(cv1800_rtcsys_mfd);
+
+MODULE_AUTHOR("Alexander Sverdlin <alexander.sverdlin@gmail.com>");
+MODULE_DESCRIPTION("Sophgo CV1800 series SoC RTC subsystem driver");
+MODULE_LICENSE("GPL");
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-09 20:26 ` [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only) Alexander Sverdlin
@ 2025-03-14 0:51 ` Inochi Amaoto
2025-03-14 9:31 ` Alexander Sverdlin
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Inochi Amaoto @ 2025-03-14 0:51 UTC (permalink / raw)
To: Alexander Sverdlin, sophgo, devicetree, linux-rtc
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Inochi Amaoto, Alexandre Belloni, Jingbao Qiu, Arnd Bergmann,
Yangyu Chen, linux-kernel
On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> 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.
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> Changelog:
> v13:
> - Moved the driver from MFD into SOC subsystem
> - Dropped unused "cv1800_rtcsys_rtc_subdev"
> v12:
> - new patch
>
> MAINTAINERS | 1 +
> 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 ++++++++++++++++++++++++++++++
> 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
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3eee238c2ea2..ac15e448fffb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
> W: https://github.com/sophgo/linux/wiki
> T: git https://github.com/sophgo/linux.git
> S: Maintained
> +F: drivers/soc/sophgo/cv1800-rtcsys.c
Please change to the drivers/soc/sophgo/.
We should maintain all files under this.
> N: sophgo
> K: sophgo
>
> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
> index 6a8daeb8c4b9..11e2383c0654 100644
> --- a/drivers/soc/Kconfig
> +++ b/drivers/soc/Kconfig
> @@ -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"
> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
> index 2037a8695cb2..0381a0abdec8 100644
> --- a/drivers/soc/Makefile
> +++ b/drivers/soc/Makefile
> @@ -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/
> diff --git a/drivers/soc/sophgo/Kconfig b/drivers/soc/sophgo/Kconfig
> new file mode 100644
> index 000000000000..e50666e423a9
> --- /dev/null
> +++ b/drivers/soc/sophgo/Kconfig
> @@ -0,0 +1,24 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Sophgo/Cvitek SoC drivers
> +#
> +
> +if ARCH_SOPHGO || COMPILE_TEST
> +menu "Sophgo/Cvitek SoC drivers"
No Cvitek, only left Sophgo here.
> +
> +config SOPHGO_CV1800_RTCSYS
> + tristate "Sophgo CV1800 RTC MFD"
> + default y if COMPILE_TEST
I do not think it is necessary.
> + 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
> diff --git a/drivers/soc/sophgo/Makefile b/drivers/soc/sophgo/Makefile
> new file mode 100644
> index 000000000000..8f22b4e79311
> --- /dev/null
> +++ b/drivers/soc/sophgo/Makefile
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +obj-$(CONFIG_SOPHGO_CV1800_RTCSYS) += cv1800-rtcsys.o
> diff --git a/drivers/soc/sophgo/cv1800-rtcsys.c b/drivers/soc/sophgo/cv1800-rtcsys.c
> new file mode 100644
> index 000000000000..cb271f02afcc
> --- /dev/null
> +++ b/drivers/soc/sophgo/cv1800-rtcsys.c
> @@ -0,0 +1,63 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * 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.
> + *
> + * Copyright (C) 2025 Alexander Sverdlin <alexander.sverdlin@gmail.com>
> + *
> + */
> +
> +#include <linux/mfd/core.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/property.h>
> +
> +static struct resource cv1800_rtcsys_irq_resources[] = {
> + DEFINE_RES_IRQ_NAMED(0, "alarm"),
> +};
> +
> +static const struct mfd_cell cv1800_rtcsys_subdev[] = {
> + {
> + .name = "cv1800-rtc",
Make this a specifc one, like "sophgo,cv1800b-rtc"
> + .num_resources = 1,
> + .resources = &cv1800_rtcsys_irq_resources[0],
> + },
> +};
> +
> +static int cv1800_rtcsys_probe(struct platform_device *pdev)
> +{
> + int irq;
> +
> + irq = platform_get_irq_byname(pdev, "alarm");
> + if (irq < 0)
> + return irq;
> + cv1800_rtcsys_irq_resources[0].start = irq;
> + cv1800_rtcsys_irq_resources[0].end = irq;
> +
> + return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
> + cv1800_rtcsys_subdev,
> + ARRAY_SIZE(cv1800_rtcsys_subdev),
> + NULL, 0, NULL);
> +}
> +
> +static const struct of_device_id cv1800_rtcsys_of_match[] = {
> + { .compatible = "sophgo,cv1800b-rtc" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, cv1800_rtcsys_of_match);
> +
> +static struct platform_driver cv1800_rtcsys_mfd = {
> + .probe = cv1800_rtcsys_probe,
> + .driver = {
> + .name = "cv1800_rtcsys",
> + .of_match_table = cv1800_rtcsys_of_match,
> + },
> +};
> +module_platform_driver(cv1800_rtcsys_mfd);
> +
> +MODULE_AUTHOR("Alexander Sverdlin <alexander.sverdlin@gmail.com>");
> +MODULE_DESCRIPTION("Sophgo CV1800 series SoC RTC subsystem driver");
> +MODULE_LICENSE("GPL");
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-14 0:51 ` Inochi Amaoto
@ 2025-03-14 9:31 ` Alexander Sverdlin
2025-03-14 9:39 ` Inochi Amaoto
2025-03-15 1:11 ` Chen Wang
` (2 subsequent siblings)
3 siblings, 1 reply; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-14 9:31 UTC (permalink / raw)
To: Inochi Amaoto, sophgo, devicetree, linux-rtc; +Cc: linux-kernel
Hi Inochi!
On Fri, 2025-03-14 at 08:51 +0800, Inochi Amaoto wrote:
> On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> > 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.
> >
...
> > +++ b/drivers/soc/sophgo/cv1800-rtcsys.c
> > @@ -0,0 +1,63 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * 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.
> > + *
> > + * Copyright (C) 2025 Alexander Sverdlin <alexander.sverdlin@gmail.com>
> > + *
> > + */
> > +
> > +#include <linux/mfd/core.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/property.h>
> > +
> > +static struct resource cv1800_rtcsys_irq_resources[] = {
> > + DEFINE_RES_IRQ_NAMED(0, "alarm"),
> > +};
> > +
> > +static const struct mfd_cell cv1800_rtcsys_subdev[] = {
> > + {
>
> > + .name = "cv1800-rtc",
>
> Make this a specifc one, like "sophgo,cv1800b-rtc"
Could it be that you mixed up device instance name and "compatible"?
Please refer to all other MFD cells with `grep -C3 -R -F "struct mfd_cell"`
either in drivers/soc or in drivers/mfd, there are no vendor prefixes in the
names.
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-14 9:31 ` Alexander Sverdlin
@ 2025-03-14 9:39 ` Inochi Amaoto
0 siblings, 0 replies; 19+ messages in thread
From: Inochi Amaoto @ 2025-03-14 9:39 UTC (permalink / raw)
To: Alexander Sverdlin, Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: linux-kernel
On Fri, Mar 14, 2025 at 10:31:09AM +0100, Alexander Sverdlin wrote:
> Hi Inochi!
>
> On Fri, 2025-03-14 at 08:51 +0800, Inochi Amaoto wrote:
> > On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> > > 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.
> > >
>
> ...
>
> > > +++ b/drivers/soc/sophgo/cv1800-rtcsys.c
> > > @@ -0,0 +1,63 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +/*
> > > + * 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.
> > > + *
> > > + * Copyright (C) 2025 Alexander Sverdlin <alexander.sverdlin@gmail.com>
> > > + *
> > > + */
> > > +
> > > +#include <linux/mfd/core.h>
> > > +#include <linux/module.h>
> > > +#include <linux/of.h>
> > > +#include <linux/property.h>
> > > +
> > > +static struct resource cv1800_rtcsys_irq_resources[] = {
> > > + DEFINE_RES_IRQ_NAMED(0, "alarm"),
> > > +};
> > > +
> > > +static const struct mfd_cell cv1800_rtcsys_subdev[] = {
> > > + {
> >
> > > + .name = "cv1800-rtc",
> >
> > Make this a specifc one, like "sophgo,cv1800b-rtc"
>
> Could it be that you mixed up device instance name and "compatible"?
>
> Please refer to all other MFD cells with `grep -C3 -R -F "struct mfd_cell"`
> either in drivers/soc or in drivers/mfd, there are no vendor prefixes in the
> names.
>
Yeah, I misunderstand this, but at least please specific name as
"cv1800b-rtc". This is more accuracy.
Regards,
Inochi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-14 0:51 ` Inochi Amaoto
2025-03-14 9:31 ` Alexander Sverdlin
@ 2025-03-15 1:11 ` Chen Wang
2025-03-15 8:48 ` Alexander Sverdlin
2025-03-15 11:43 ` Alexander Sverdlin
2025-03-15 15:55 ` Alexander Sverdlin
3 siblings, 1 reply; 19+ messages in thread
From: Chen Wang @ 2025-03-15 1:11 UTC (permalink / raw)
To: Inochi Amaoto, Alexander Sverdlin, sophgo, devicetree, linux-rtc
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Belloni,
Jingbao Qiu, Arnd Bergmann, Yangyu Chen, linux-kernel
Hey, Alexander
On 2025/3/14 8:51, Inochi Amaoto wrote:
> On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
>> 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.
>>
>> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
>> ---
>> Changelog:
>> v13:
>> - Moved the driver from MFD into SOC subsystem
>> - Dropped unused "cv1800_rtcsys_rtc_subdev"
>> v12:
>> - new patch
>>
>> MAINTAINERS | 1 +
>> 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 ++++++++++++++++++++++++++++++
>> 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
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 3eee238c2ea2..ac15e448fffb 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
>> W: https://github.com/sophgo/linux/wiki
>> T: git https://github.com/sophgo/linux.git
>> S: Maintained
>> +F: drivers/soc/sophgo/cv1800-rtcsys.c
> Please change to the drivers/soc/sophgo/.
> We should maintain all files under this.
In addition to what Inochi mentioned, please add the following line:
F: Documentation/devicetree/bindings/soc/sophgo/
Thanks,
Chen
[......]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-15 1:11 ` Chen Wang
@ 2025-03-15 8:48 ` Alexander Sverdlin
2025-03-15 9:07 ` Chen Wang
0 siblings, 1 reply; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-15 8:48 UTC (permalink / raw)
To: Chen Wang, Inochi Amaoto, sophgo, devicetree, linux-rtc; +Cc: linux-kernel
Hi Chen!
On Sat, 2025-03-15 at 09:11 +0800, Chen Wang wrote:
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
> > > W: https://github.com/sophgo/linux/wiki
> > > T: git https://github.com/sophgo/linux.git
> > > S: Maintained
> > > +F: drivers/soc/sophgo/cv1800-rtcsys.c
> > Please change to the drivers/soc/sophgo/.
> > We should maintain all files under this.
>
> In addition to what Inochi mentioned, please add the following line:
>
> F: Documentation/devicetree/bindings/soc/sophgo/
Isn't it already covered by the existing "N: sophgo" entry?
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-15 8:48 ` Alexander Sverdlin
@ 2025-03-15 9:07 ` Chen Wang
0 siblings, 0 replies; 19+ messages in thread
From: Chen Wang @ 2025-03-15 9:07 UTC (permalink / raw)
To: Alexander Sverdlin, Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: linux-kernel
On 2025/3/15 16:48, Alexander Sverdlin wrote:
> Hi Chen!
>
> On Sat, 2025-03-15 at 09:11 +0800, Chen Wang wrote:
>>>> --- a/MAINTAINERS
>>>> +++ b/MAINTAINERS
>>>> @@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
>>>> W: https://github.com/sophgo/linux/wiki
>>>> T: git https://github.com/sophgo/linux.git
>>>> S: Maintained
>>>> +F: drivers/soc/sophgo/cv1800-rtcsys.c
>>> Please change to the drivers/soc/sophgo/.
>>> We should maintain all files under this.
>> In addition to what Inochi mentioned, please add the following line:
>>
>> F: Documentation/devicetree/bindings/soc/sophgo/
> Isn't it already covered by the existing "N: sophgo" entry?
Ok, just ignore my comment.
Thanks,
Chen
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-14 0:51 ` Inochi Amaoto
2025-03-14 9:31 ` Alexander Sverdlin
2025-03-15 1:11 ` Chen Wang
@ 2025-03-15 11:43 ` Alexander Sverdlin
2025-03-15 22:35 ` Inochi Amaoto
2025-03-15 15:55 ` Alexander Sverdlin
3 siblings, 1 reply; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-15 11:43 UTC (permalink / raw)
To: Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: Chen Wang, Jingbao Qiu, Yangyu Chen, linux-kernel
Hi Inochi!
On Fri, 2025-03-14 at 08:51 +0800, Inochi Amaoto wrote:
> On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> > 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.
> >
> > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
...
> >
> > MAINTAINERS | 1 +
> > 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 ++++++++++++++++++++++++++++++
> > 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
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 3eee238c2ea2..ac15e448fffb 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
> > W: https://github.com/sophgo/linux/wiki
> > T: git https://github.com/sophgo/linux.git
> > S: Maintained
>
> > +F: drivers/soc/sophgo/cv1800-rtcsys.c
>
> Please change to the drivers/soc/sophgo/.
> We should maintain all files under this.
>
> > N: sophgo
I suppose my F: entry is actually superfluous because of the above
N: entry and can be removed altogether?
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-15 11:43 ` Alexander Sverdlin
@ 2025-03-15 22:35 ` Inochi Amaoto
0 siblings, 0 replies; 19+ messages in thread
From: Inochi Amaoto @ 2025-03-15 22:35 UTC (permalink / raw)
To: Alexander Sverdlin, Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: Chen Wang, Jingbao Qiu, Yangyu Chen, linux-kernel
On Sat, Mar 15, 2025 at 12:43:19PM +0100, Alexander Sverdlin wrote:
> Hi Inochi!
>
> On Fri, 2025-03-14 at 08:51 +0800, Inochi Amaoto wrote:
> > On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> > > 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.
> > >
> > > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
>
> ...
>
> > >
> > > MAINTAINERS | 1 +
> > > 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 ++++++++++++++++++++++++++++++
> > > 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
> > >
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index 3eee238c2ea2..ac15e448fffb 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
> > > W: https://github.com/sophgo/linux/wiki
> > > T: git https://github.com/sophgo/linux.git
> > > S: Maintained
> >
> > > +F: drivers/soc/sophgo/cv1800-rtcsys.c
> >
> > Please change to the drivers/soc/sophgo/.
> > We should maintain all files under this.
> >
> > > N: sophgo
>
> I suppose my F: entry is actually superfluous because of the above
> N: entry and can be removed altogether?
>
It is fine to tell others we do maintain these files, so it
is fine for me to keep the entry point to "drivers/soc/sophgo/".
Regards,
Inochi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-14 0:51 ` Inochi Amaoto
` (2 preceding siblings ...)
2025-03-15 11:43 ` Alexander Sverdlin
@ 2025-03-15 15:55 ` Alexander Sverdlin
2025-03-15 22:41 ` Inochi Amaoto
3 siblings, 1 reply; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-15 15:55 UTC (permalink / raw)
To: Inochi Amaoto, sophgo, devicetree, linux-rtc; +Cc: linux-kernel
Hi Inochi!
On Fri, 2025-03-14 at 08:51 +0800, Inochi Amaoto wrote:
> On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> > 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.
> >
> > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
...
> > +++ b/drivers/soc/sophgo/Kconfig
> > @@ -0,0 +1,24 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +#
> > +# Sophgo/Cvitek SoC drivers
> > +#
> > +
> > +if ARCH_SOPHGO || COMPILE_TEST
>
> > +menu "Sophgo/Cvitek SoC drivers"
>
> No Cvitek, only left Sophgo here.
>
> > +
> > +config SOPHGO_CV1800_RTCSYS
> > + tristate "Sophgo CV1800 RTC MFD"
>
> > + default y if COMPILE_TEST
>
> I do not think it is necessary.
Maybe it should have been
tristate "Sophgo CV1800 RTC MFD" if COMPILE_TEST
like others do?
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
2025-03-15 15:55 ` Alexander Sverdlin
@ 2025-03-15 22:41 ` Inochi Amaoto
0 siblings, 0 replies; 19+ messages in thread
From: Inochi Amaoto @ 2025-03-15 22:41 UTC (permalink / raw)
To: Alexander Sverdlin, Inochi Amaoto, sophgo, devicetree, linux-rtc
Cc: linux-kernel
On Sat, Mar 15, 2025 at 04:55:57PM +0100, Alexander Sverdlin wrote:
> Hi Inochi!
>
> On Fri, 2025-03-14 at 08:51 +0800, Inochi Amaoto wrote:
> > On Sun, Mar 09, 2025 at 09:26:24PM +0100, Alexander Sverdlin wrote:
> > > 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.
> > >
> > > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
>
> ...
>
> > > +++ b/drivers/soc/sophgo/Kconfig
> > > @@ -0,0 +1,24 @@
> > > +# SPDX-License-Identifier: GPL-2.0-only
> > > +#
> > > +# Sophgo/Cvitek SoC drivers
> > > +#
> > > +
> > > +if ARCH_SOPHGO || COMPILE_TEST
> >
> > > +menu "Sophgo/Cvitek SoC drivers"
> >
> > No Cvitek, only left Sophgo here.
> >
> > > +
> > > +config SOPHGO_CV1800_RTCSYS
> > > + tristate "Sophgo CV1800 RTC MFD"
> >
> > > + default y if COMPILE_TEST
> >
> > I do not think it is necessary.
>
> Maybe it should have been
>
> tristate "Sophgo CV1800 RTC MFD" if COMPILE_TEST
>
> like others do?
>
No, you needn't. The first line "if ARCH_SOPHGO || COMPILE_TEST"
already does the expected things. This is equal to remove this
"if" and add a line "depends on ARCH_SOPHGO || COMPILE_TEST" to
this entry. Just remove the default line, and everything is OK.
Regards,
Inochi
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v13 3/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC
2025-03-09 20:26 [PATCH v13 0/3] rtc: sophgo: add rtc support for CV1800 Alexander Sverdlin
2025-03-09 20:26 ` [PATCH v13 1/3] dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series Alexander Sverdlin
2025-03-09 20:26 ` [PATCH v13 2/3] soc: sophgo: cv1800: rtcsys: New driver (handling RTC only) Alexander Sverdlin
@ 2025-03-09 20:26 ` Alexander Sverdlin
2 siblings, 0 replies; 19+ messages in thread
From: Alexander Sverdlin @ 2025-03-09 20:26 UTC (permalink / raw)
To: sophgo, devicetree, linux-rtc
Cc: Jingbao Qiu, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen Wang, Inochi Amaoto, Alexandre Belloni, Arnd Bergmann,
Yangyu Chen, linux-kernel, Alexander Sverdlin
From: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
Implement the RTC driver for CV1800, which able to provide time alarm.
Signed-off-by: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Changelog:
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
diff --git a/MAINTAINERS b/MAINTAINERS
index ac15e448fffb..be8fee50a49c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22354,6 +22354,7 @@ L: sophgo@lists.linux.dev
W: https://github.com/sophgo/linux/wiki
T: git https://github.com/sophgo/linux.git
S: Maintained
+F: drivers/rtc/rtc-cv1800.c
F: drivers/soc/sophgo/cv1800-rtcsys.c
N: sophgo
K: sophgo
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 0bbbf778ecfa..46593103db11 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -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
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 489b4ab07068..621b30a33dda 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -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
diff --git a/drivers/rtc/rtc-cv1800.c b/drivers/rtc/rtc-cv1800.c
new file mode 100644
index 000000000000..18bc542bbdb8
--- /dev/null
+++ b/drivers/rtc/rtc-cv1800.c
@@ -0,0 +1,218 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * rtc-cv1800.c: RTC driver for Sophgo cv1800 RTC
+ *
+ * Author: Jingbao Qiu <qiujingbao.dlmu@gmail.com>
+ */
+
+#include <linux/clk.h>
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/rtc.h>
+
+#define SEC_PULSE_GEN 0x1004
+#define ALARM_TIME 0x1008
+#define ALARM_ENABLE 0x100C
+#define SET_SEC_CNTR_VAL 0x1010
+#define SET_SEC_CNTR_TRIG 0x1014
+#define SEC_CNTR_VAL 0x1018
+
+/*
+ * When in VDDBKUP domain, this MACRO register
+ * does not power down
+ */
+#define MACRO_RO_T 0x14A8
+#define MACRO_RG_SET_T 0x1498
+
+#define ALARM_ENABLE_MASK BIT(0)
+#define SEL_SEC_PULSE BIT(31)
+
+struct cv1800_rtc_priv {
+ struct rtc_device *rtc_dev;
+ struct regmap *rtc_map;
+ struct clk *clk;
+ int irq;
+};
+
+static bool cv1800_rtc_enabled(struct device *dev)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+ u32 reg;
+
+ regmap_read(info->rtc_map, SEC_PULSE_GEN, ®);
+
+ return (reg & SEL_SEC_PULSE) == 0;
+}
+
+static void cv1800_rtc_enable(struct device *dev)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+
+ /* Sec pulse generated internally */
+ regmap_update_bits(info->rtc_map, SEC_PULSE_GEN, SEL_SEC_PULSE, 0);
+}
+
+static int cv1800_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+
+ regmap_write(info->rtc_map, ALARM_ENABLE, enabled);
+
+ return 0;
+}
+
+static int cv1800_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+ unsigned long alarm_time;
+
+ alarm_time = rtc_tm_to_time64(&alrm->time);
+
+ cv1800_rtc_alarm_irq_enable(dev, 0);
+
+ regmap_write(info->rtc_map, ALARM_TIME, alarm_time);
+
+ cv1800_rtc_alarm_irq_enable(dev, alrm->enabled);
+
+ return 0;
+}
+
+static int cv1800_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+ u32 enabled;
+ u32 time;
+
+ if (!cv1800_rtc_enabled(dev)) {
+ alarm->enabled = 0;
+ return 0;
+ }
+
+ regmap_read(info->rtc_map, ALARM_ENABLE, &enabled);
+
+ alarm->enabled = enabled & ALARM_ENABLE_MASK;
+
+ regmap_read(info->rtc_map, ALARM_TIME, &time);
+
+ rtc_time64_to_tm(time, &alarm->time);
+
+ return 0;
+}
+
+static int cv1800_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+ u32 sec;
+
+ if (!cv1800_rtc_enabled(dev))
+ return -EINVAL;
+
+ regmap_read(info->rtc_map, SEC_CNTR_VAL, &sec);
+
+ rtc_time64_to_tm(sec, tm);
+
+ return 0;
+}
+
+static int cv1800_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
+ unsigned long sec;
+
+ sec = rtc_tm_to_time64(tm);
+
+ regmap_write(info->rtc_map, SET_SEC_CNTR_VAL, sec);
+ regmap_write(info->rtc_map, SET_SEC_CNTR_TRIG, 1);
+
+ regmap_write(info->rtc_map, MACRO_RG_SET_T, sec);
+
+ cv1800_rtc_enable(dev);
+
+ return 0;
+}
+
+static irqreturn_t cv1800_rtc_irq_handler(int irq, void *dev_id)
+{
+ struct cv1800_rtc_priv *info = dev_id;
+
+ rtc_update_irq(info->rtc_dev, 1, RTC_IRQF | RTC_AF);
+
+ regmap_write(info->rtc_map, ALARM_ENABLE, 0);
+
+ return IRQ_HANDLED;
+}
+
+static const struct rtc_class_ops cv1800_rtc_ops = {
+ .read_time = cv1800_rtc_read_time,
+ .set_time = cv1800_rtc_set_time,
+ .read_alarm = cv1800_rtc_read_alarm,
+ .set_alarm = cv1800_rtc_set_alarm,
+ .alarm_irq_enable = cv1800_rtc_alarm_irq_enable,
+};
+
+static int cv1800_rtc_probe(struct platform_device *pdev)
+{
+ struct cv1800_rtc_priv *rtc;
+ int ret;
+
+ rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
+ if (!rtc)
+ return -ENOMEM;
+
+ rtc->rtc_map = device_node_to_regmap(pdev->dev.parent->of_node);
+ if (IS_ERR(rtc->rtc_map))
+ return dev_err_probe(&pdev->dev, PTR_ERR(rtc->rtc_map),
+ "cannot get parent regmap\n");
+
+ rtc->irq = platform_get_irq(pdev, 0);
+ if (rtc->irq < 0)
+ return rtc->irq;
+
+ rtc->clk = devm_clk_get_enabled(pdev->dev.parent, "rtc");
+ if (IS_ERR(rtc->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(rtc->clk),
+ "rtc clk not found\n");
+
+ platform_set_drvdata(pdev, rtc);
+
+ device_init_wakeup(&pdev->dev, 1);
+
+ rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(rtc->rtc_dev))
+ return PTR_ERR(rtc->rtc_dev);
+
+ rtc->rtc_dev->ops = &cv1800_rtc_ops;
+ rtc->rtc_dev->range_max = U32_MAX;
+
+ ret = devm_request_irq(&pdev->dev, rtc->irq, cv1800_rtc_irq_handler,
+ IRQF_TRIGGER_HIGH, "rtc alarm", rtc);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "cannot register interrupt handler\n");
+
+ return devm_rtc_register_device(rtc->rtc_dev);
+}
+
+static const struct platform_device_id cv1800_rtc_id[] = {
+ { .name = "cv1800-rtc" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(platform, cv1800_rtc_id);
+
+static struct platform_driver cv1800_rtc_driver = {
+ .driver = {
+ .name = "sophgo-cv1800-rtc",
+ },
+ .probe = cv1800_rtc_probe,
+ .id_table = cv1800_rtc_id,
+};
+
+module_platform_driver(cv1800_rtc_driver);
+MODULE_AUTHOR("Jingbao Qiu");
+MODULE_DESCRIPTION("Sophgo cv1800 RTC Driver");
+MODULE_LICENSE("GPL");
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread